假设我们正在尝试为模块编写名为 SC_TB 的 Verilog/SystemVerilog 测试台代码sample_code
。有没有更实用的方法可以查看测试台上正在做什么reg B
,wire Cw
而无需为它们创建端口?
module sample_code(
input A,
output Z
);
reg B;
wire Cw;
*stuff happens in this code*
endmodule
///测试台代码
module SC_TB();
reg A;
wire Z;
sample_code SCInst(
.A(A),
.Z(Z)
);
initial begin
A=0
#x a=value;
end
initial begin
$monitor(A,Z)
end
目前,要查看“reg B”和“wire Cw”在做什么,我会为它们创建端口,然后将这些端口包含在我的测试台代码中。对于内部声明的 wires(sample_code 中的 Cw),我会将它们注释掉,然后创建一个具有类似名称的输出 wire 端口。对于内部声明的 reg(sample_code 中的 reg B),我还将创建一个输出 wire 端口,然后将内部 reg 分配到该 wire 端口。我的代码和基于 sample_code 和 SC_TB 的测试台代码最终看起来像这样。
module sample_code(
input A,
output Z,
output wire Cw,
output wire Bw
);
reg B;
//wire Cw;
assign Bw = B;
*stuff happens in this code*
endmodule
///测试台代码
module SC_TB();
reg A;
wire Z;
wire Cw;
wire Bw;
sample_code SCInst(
.A(A),
.Z(Z),
.Cw(Cw),
.Bw(Bw)
);
initial begin
A=0
#x a=value;
end
initial begin
$monitor(A,Z,Cw,Bw) //it doesnt have to be "monitor", "$display" or just the timing diagram works.
end