nonblocking vs blocking funny example

 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
10 endmodule

hwsan

 

 1 `timescale 1ns/100ps;  
 2 module tb;
 3   reg clk;
 4   
 5   
 6   integer Count;
 7   reg [7:0] rcnt;
 8   /////////////////////
 9   integer fdt;   
10   ////////////////
11 
12   initial 
13   begin
14     fdt = $fopen("datat.txt""w");
15     clk=0;
16     Count=0;
17     rcnt = 8'h0;
18     #10;
19     forever
20     #5 clk =~clk;   
21   end 
22   always@(posedge clk)
23   begin 
24     $fwrite(fdt, "tb:\t(integer=%d,reg=%d) ", Count,rcnt);
25     Count=Count+1;
26     rcnt<=rcnt+1;
27     $fwrite(fdt, " <+1> [integer=%d,reg=%d]", Count,rcnt);
28     if (Count==124
29     begin
30       $fwrite(fdt, "\tif {integer=%d,reg=%d} ", Count,rcnt);
31       Count=0;
32       rcnt<=0;
33       $fwrite(fdt, "<=0> |integer=%d,reg=%d| ", Count,rcnt);
34     end  
35     $fwrite(fdt, "\n");
36   end
37 endmodule 

 tb

 


 

 you will see the difference

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted on 2014-02-14 22:28  testset  阅读(182)  评论(0编辑  收藏  举报

导航