|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
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 |
|