a,b,c的值是多少?

时间:2017-08-29 20:18:31

标签: verilog system-verilog blocking nonblocking

据我所知,不推荐混合阻止和非阻塞。但如果它确实存在,那么a,b,c的值是什么?

module TB; 
reg a, b, c;
initial begin 
  a = 3;
  b = 4;
  $display ("a = %d, b = %d, c=%d\n", a, b, c);
  c <=  a + b;
  $display ("a = %d, b = %d, c=%d\n", a, b, c);
  a <= 10;
  b  <= 2;
  c = a + b;
  $display ("a = %d, b = %d, c=%d\n", a, b, c);
end
endmodule

1 个答案:

答案 0 :(得分:1)

module TB; 
reg ***[2:0]*** a, b, c;
initial begin 
   a = 3;
   b = 4;
$display ("a = %d, b = %d, c=%d\n", a, b, c);
c <=  a + b;
$display ("a = %d, b = %d, c=%d\n", a, b, c);
a <= 10;
b  <= 2;
c = a + b;
$display ("a = %d, b = %d, c=%d\n", a, b, c);
end
endmodule

a = 3,b = 4且c = 7

Verilog的时间队列分为四个部分: 活动区域 - &gt;不活跃 - &gt; NBA - &gt;缓行 阻止分配得到评估,并在ACTIVE区域中与$ display()一起分配。非阻塞分配在ACTIVE区域中进行评估,并在非阻塞分配(NBA)区域中进行分配。因此,对a,b,c进行的任何更新都不会使用display语句进行打印。您可以使用$ monitor在延期区域执行。