您的位置:首页 > 其它

nonblocking vs blocking funny example

2014-02-14 22:28 169 查看
1 module hwscan;
2 integer fd;
3 initial
4 begin
5 fd = $fopen("data2o.txt", "w");
6 end
7 always @(posedge tb.clk) begin
8 $fwrite(fd,"hw:\t(int=%d,reg=%d)\n",tb.Count,tb.rcnt);
9 end
endmodulehwsan

1 `timescale 1ns/100ps;
2 module tb;
3 reg clk;
4
5
6 integer Count;
7 reg [7:0] rcnt;
8 /////////////////////
9 integer fdt;
////////////////

initial
begin
fdt = $fopen("datat.txt", "w");
clk=0;
Count=0;
rcnt = 8'h0;
#10;
forever
#5 clk =~clk;
end
always@(posedge clk)
begin
$fwrite(fdt, "tb:\t(integer=%d,reg=%d) ", Count,rcnt);
Count=Count+1;
rcnt<=rcnt+1;
$fwrite(fdt, " <+1> [integer=%d,reg=%d]", Count,rcnt);
if (Count==124)
begin
$fwrite(fdt, "\tif {integer=%d,reg=%d} ", Count,rcnt);
Count=0;
rcnt<=0;
$fwrite(fdt, "<=0> |integer=%d,reg=%d| ", Count,rcnt);
end
$fwrite(fdt, "\n");
end
endmodule tb



you will see the difference
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: