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
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
相关文章推荐
- Blocking vs. non-blocking sockets
- nodejs中的阻塞和非阻塞(https://nodejs.org/en/docs/guides/blocking-vs-non-blocking/)
- Blocking/Non-Blocking VS Sync/Async VS Overlapped
- Blocking vs. Non-Blocking Sockets 阻塞与非阻塞式套接字
- asynchronous vs non-blocking
- asynchronous vs non-blocking
- Node.js[译] Overview of Blocking vs Non-Blocking
- Asynchronous vs Nonblocking
- Blocking vs. Non-Blocking Sockets
- Blocking VS. Nonblcoking
- I/O Concept - Blocking/Non-Blocking VS Sync/Async
- P2P non-blocking
- Example: A simple blocking HTTP client
- Merlin brings nonblocking I/O to the Java platform
- 同步(Synchronous)异步(Asynchronous) 阻塞(Blocking)和非阻塞(Non-blocking)的概念
- non-blocking and blocking mode
- Asynchronous file io in eventlet (aka non-thread blocking read)
- LinkedBlockingQueue vs ConcurrentLinkedQueue
- [译]Atomic VS. Non-Atomic 操作
- Javascript Array Methods: Mutating vs. Non-Mutating