在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2199|回复: 2

[原创] modelsim中关于$display的使用举例

[复制链接]
发表于 2015-10-27 14:39:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
做了几年了$display,第一次使用,所以赶紧记下来,方便以后在modelsim仿真的时候使用。

`timescale 1ns/1ns    //设置时钟精度
module comparetop;

wire
[3:0]
b1,b2,c1,c2;
reg
[3:0]
a;
reg
clk;

initial
begin

clk = 0;

forever #50 clk = ~clk;
end


initial
begin

a = 4'h3;

$display("__________");

#100 a = 4'h7;

$display("__________");

#100 a = 4'hf;

$display("__________");

#100 a = 4'ha;

$display("__________");

#100 a = 4'h2;

$display("__________");

#100 $display("__________");

$stop;
end

non_blocking non_blocking(clk,a,b2,c2);
blocking
blocking(clk,a,b1,c1);

endmodule


`timescale 1ns/1ns    //设置时钟精度
module blocking(
input
clk,
input
[3:0]
a,
output
reg
[3:0]
b,c
);


always@(posedge clk)
begin

b = a ;

c = b ;

$display("blocking:a=%d,b=%d,c=%d.",a,b,c);
end

endmodule


`timescale 1ns/1ns    //设置时钟精度
module non_blocking(
input
clk,
input
[3:0]
a,
output
reg
[3:0]
b,c
);


always@(posedge clk)
begin

b <= a ;

c <= b ;

$display("non_blocking:a=%d,b=%d,c=%d.",a,b,c);
end

endmodule


在modelsim中Transcript中的显示如下:

# Refreshing F:\wsz\test\20151023\comparetop\work.comparetop
# Loading work.comparetop
# Refreshing F:\wsz\test\20151023\comparetop\work.non_blocking
# Loading work.non_blocking
# Refreshing F:\wsz\test\20151023\comparetop\work.blocking
# Loading work.blocking
# __________
# blocking:a= 3,b= 3,c= 3.
# non_blocking:a= 3,b= x,c= x.
# __________
# blocking:a= 7,b= 7,c= 7.
# non_blocking:a= 7,b= 3,c= x.
# __________
# blocking:a=15,b=15,c=15.
# non_blocking:a=15,b= 7,c= 3.
# __________
# blocking:a=10,b=10,c=10.
# non_blocking:a=10,b=15,c= 7.
# __________
# blocking:a= 2,b= 2,c= 2.
# non_blocking:a= 2,b=10,c=15.
# __________
# Break in Module comparetop at F:/wsz/test/20151023/comparetop/comparetop.v line 28
# Simulation Breakpoint: Break in Module comparetop at F:/wsz/test/20151023/comparetop/comparetop.v line 28
# MACRO ./sim.do PAUSED at line 15
 楼主| 发表于 2015-10-27 19:46:44 | 显示全部楼层
$display相关的使用问题可以参考verilog相关标准文档。

IEEEStandardforVerilogHardwareDescriptionLanguage[IEEEStd1364-2005](完整且有目录).pdf

5.84 MB, 下载次数: 7 , 下载积分: 资产 -3 信元, 下载支出 3 信元

发表于 2017-4-6 14:34:05 | 显示全部楼层
$display相关的使用问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-12 00:54 , Processed in 0.023316 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表