新闻  |   论坛  |   博客  |   在线研讨会
非阻塞赋值
chen3bing | 2024-06-21 14:43:55    阅读:40   发布文章

代码;

non_blocking:

module blocking(clk,a,b,c);
  output [3:0] b,c;
  input  [3:0] a;
  input        clk;
  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

non_blocking.vt

`timescale 1 ns/ 100 ps
module blocking_vlg_tst();
// constants                                           
// general purpose registers

// test vector input registers
reg [3:0] a;
reg clk;
// wires                                               
wire [3:0]  b;
wire [3:0]  c;

// assign statements (if any)                          
blocking i1 (
// port map - connection between master ports and signals/registers   
	.a(a),
	.b(b),
	.c(c),
	.clk(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
  
  blocking      blocking(clk,a,b2,c2);

                                      
endmodule

仿真

2.jpg

3.jpg4.jpg

5.jpg

# ____________________________

# Non_Blocking: a =  3, b =  x, c =  x 

# Non_Blocking: a =  3, b =  x, c =  x 

# ____________________________

# Non_Blocking: a =  7, b =  3, c =  x 

# Non_Blocking: a =  7, b =  3, c =  x 

# ____________________________

# Non_Blocking: a = 15, b =  7, c =  3 

# Non_Blocking: a = 15, b =  7, c =  3 

# ____________________________

# Non_Blocking: a = 10, b = 15, c =  7 

# Non_Blocking: a = 10, b = 15, c =  7 

# ____________________________

# Non_Blocking: a =  2, b = 10, c = 15 

# Non_Blocking: a =  2, b = 10, c = 15 


*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
1
最近文章
方波振荡电路
2024-09-14 14:59:39
6V3A电路
2024-09-14 14:18:10
MOS管点灯仿真
2024-09-12 15:43:13
推荐文章
最近访客