【问题标题】:Verilog Testbench signal value not updatingVerilog Testbench 信号值未更新
【发布时间】:2021-12-01 17:59:36
【问题描述】:
`timescale 1ns / 1ps

module test_module_t( 
     input              clk_net,
     /* Network interfaces */                   
     input      [63:0]  rx_data_net,
     input              rx_sof_net,
     input              rx_eof_net,
     input              rx_vld_net,
     output reg [31:0]  port_match=0
    );
    
always @(posedge clk_net) begin
    if(rx_vld_net && rx_sof_net)
        port_match <= 0;
    else if(rx_vld_net)
        port_match <= port_match+1;
    if (rx_vld_net && rx_eof_net)
        port_match <= 0;
end

endmodule


module test_module_tb;

reg         clk_net_tb = 0;
reg  [63:0] rx_data_net_tb;
reg         rx_sof_net_tb;
reg         rx_eof_net_tb;
reg         rx_vld_net_tb;

wire [31:0]  port_match_tb = 0;

integer i;

always #0.5  clk_net_tb = ~clk_net_tb;

initial  begin : full_packet
  
    rx_eof_net_tb = 1'b0;
    rx_sof_net_tb = 1'b0;
    rx_vld_net_tb = 1'b0;
    rx_data_net_tb = 64'h0000000000000000;
    #10

    rx_eof_net_tb = 1'b0;
    rx_sof_net_tb = 1'b1;
    rx_vld_net_tb = 1'b0;
    rx_data_net_tb = 64'h0000a94d00000000;   
    #1;
    
    rx_vld_net_tb = 1'b1;
    #1;
    
    rx_sof_net_tb = 1'b0;
    rx_vld_net_tb = 1'b0;
    rx_eof_net_tb = 1'b0;
    rx_data_net_tb = 64'h00000000002d0000;
    #1
    
    rx_vld_net_tb = 1'b1;
    #1
    
    rx_sof_net_tb = 1'b0;
    rx_vld_net_tb = 1'b0;
    rx_data_net_tb = 64'hdeadbeef;
    #1
    
    rx_vld_net_tb = 1'b1;
    #1
    
    rx_eof_net_tb = 1'b1;
    rx_vld_net_tb = 1'b0;
    rx_data_net_tb = 64'h000decaf;
    #1
    
    rx_vld_net_tb = 1'b1;
    #1
    
    rx_eof_net_tb = 1'b0;
    rx_vld_net_tb = 1'b0;   
    rx_data_net_tb = 64'h0000000000000000; 
    $stop;
end

       test_module_t test_module_i
       (
        .clk_net(clk_net_tb),
        .rx_sof_net(rx_sof_net_tb),
        .rx_vld_net(rx_vld_net_tb),
        .rx_data_net(rx_data_net_tb),
        .rx_eof_net(rx_eof_net_tb),
        .port_match(port_match_tb)
       );
    
endmodule

这是我一直在处理的代码。 test_module 中的信号:port_match 正确更新,但相同的信号值没有反映在测试台中。 port_match_tb 值在测试时变为 x。

附上上面代码的模拟截图。如果有人可以帮助我解决问题所在。

【问题讨论】:

    标签: verilog test-bench


    【解决方案1】:

    port_match_tb 线有多个驱动程序:wire 声明,您将其连续驱动为 0,以及test_module_t 输出。变化:

    wire [31:0]  port_match_tb = 0;
    

    到:

    wire [31:0]  port_match_tb;
    

    这消除了 x 并允许 port_match_tb 匹配 port_match

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多