modelsim仿真出错了
时间:10-02
整理:3721RD
点击:

这是quartus中的block图,我把它转为verilog在modelsim中仿真,结果却不对,如下图所示

但是我自己写的verilog程序dff_3仿真就正确
module dff_3(in,clk,reset,out,cd);
input in;
input clk;
input reset;
output out;
reg out;
output reg cd;
reg out1;
always @(posedge clk or negedge reset)
if(!reset)
begin
out1<=0;
cd<=0;
out<=0;
end
else
begin
out1<=in;
cd<=out1;
out<=cd;
end
endmodule
这是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有什么问题啊。
quartus转化的代码有问题,在时序逻辑描述(本例中是@(posedge clk)),这样的描述里面应该用非阻塞赋值,你看你自己写的都是非阻塞赋值的。
Quartus转化的Verilog代码或许综合后和你quartus绘制的block图功能一致,但是仿真的时候会导致不一样的结果。
这个问题就是我们在设计中经常说的“simulation mismatch with synthesis",也就是说,仿真器和综合器对这种verilog语句的解释原理不一样,会导致解释出来的结果不一样,所以仿真和综合的结果不一样。因为我们都是通过仿真来模拟模块功能的,如果仿真和综合的结果不一样,那么仿真就无效,这样可能会导致非常严重的设计问题。所以综上所述,这种verilog代码在设计千万不要使用。
你列出的这个问题是quartus工具的问题,quartus作为FPGA公司,其软件可能有一些不好的地方,我们需要掌握verilog和集成电路设计的基础知识,在使用它的工具后,自己要能发现,辨明,修复这些存在问题的地方。
没看出来什么问题 非阻塞语句才会产生移位
希望高手指点一下
按时序仿真的理解好像这个仿真结果是对的
你的代码能不能搞点缩进啊!看着头大!
