[英]Verilog Testbench signal value not updating
`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
This is the code I have been working on.这是我一直在研究的代码。 The signal in test_module: port_match
updates correctly, but the same signal value is not reflected in the testbench. test_module: port_match
的信号正确更新,但相同的信号值未反映在测试平台中。 port_match_tb
value goes x when testing.测试时, port_match_tb
值变为 x。
Attaching a screenshot of the simulation of the above code.附上上面代码模拟的截图。 If anybody could help me out with where this is going wrong.如果有人可以帮助我解决哪里出错了。
The port_match_tb
wire has multiple drivers: the wire
declaration where you continuously drive it as 0, and the test_module_t
output. port_match_tb
线路有多个驱动程序:您连续将其驱动为 0 的wire
声明,以及test_module_t
输出。 Change:改变:
wire [31:0] port_match_tb = 0;
to:到:
wire [31:0] port_match_tb;
This eliminates the x and allows port_match_tb
to match port_match
.这消除了 x 并允许port_match_tb
匹配port_match
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.