| |
问题:
一段很简单的两级flop代码,用quartus转的
这是quartus转的verilog代码
// Copyright (C) 1991-2009 Altera Corporation
// Your use of Altera Corporation's design tools, logic functions
// and other software and tools, and its AMPP partner logic
// functions, and any output files from any of the foregoing
// (including device programming or simulation files), and any
// associated documentation or information are expressly subject
// to the terms and conditions of the Altera Program License
// Subscription Agreement, Altera MegaCore Function License
// Agreement, or other applicable license agreement, including,
// without limitation, that your use is for the sole purpose of
// programming logic devices manufactured by Altera and sold by
// Altera or its authorized distributors. Please refer to the
// applicable agreement for further details.
// PROGRAM "Quartus II"
// VERSION "Version 9.1 Build 222 10/21/2009 SJ Full Version"
// CREATED "Tue Mar 08 17:59:23 2011"
module gg(
in,
clk,
reset,
out,
cd
);
input in;
input clk;
input reset;
output out;
reg out;
output cd;
reg cd_ALTERA_SYNTHESIZED;
reg DFF_inst;
always@(posedge clk or negedge reset)
begin
if (!reset)
begin
DFF_inst = 0;
end
else
begin
DFF_inst = in;
end
end
always@(posedge clk or negedge reset)
begin
if (!reset)
begin
cd_ALTERA_SYNTHESIZED = 0;
end
else
begin
cd_ALTERA_SYNTHESIZED = DFF_inst;
end
end
always@(posedge clk or negedge reset)
begin
if (!reset)
begin
out = 0;
end
else
begin
out = cd_ALTERA_SYNTHESIZED;
end
end
assign cd = cd_ALTERA_SYNTHESIZED;
endmodule
没看出quartus转的verilog有什么问题啊。
用modelsim仿真的结果出问题,仿真发现只有一级flop
我的解答:
quartus转化的代码有问题,在时序逻辑描述(本例中是@(posedge clk)),这样的描述里面应该用非阻塞赋值,你看你自己写的都是非阻塞赋值的。
Quartus转化的Verilog代码或许综合后和你quartus绘制的block图功能一致,但是仿真的时候会导致不一样的结果。
这个问题就是我们在设计中经常说的“simulation mismatch with synthesis",也就是说,仿真器和综合器对这种verilog语句的解释原理不一样,会导致解释出来的结果不一样,所以仿真和综合的结果不一样。因为我们都是通过仿真来模拟模块功能的,如果仿真和综合的结果不一样,那么仿真就无效,这样可能会导致非常严重的设计问题。所以综上所述,这种verilog代码在设计千万不要使用。
你列出的这个问题是quartus工具的问题,quartus作为FPGA公司,其软件可能有一些不好的地方,我们需要掌握verilog和集成电路设计的基础知识,在使用它的工具后,自己要能发现,辨明,修复这些存在问题的地方。
我的评论:请大家在写verilog代码的时候一定要避免simulation和synthesis不一样的情况出现。学好verilog和集成电路设计基础。
注1:如果各位觉得我包含在自己日志里面对您不妥,或者涉及隐私的话,请告知我,我删除。
注2:问题的解答我只列举我自己的想法,不保证可以一直追踪到真正正确的解答,所以请如果有看客的话,解答仅作参考之用,也欢迎大家在blog里留言评论。