在模块实例化中输入对另一个模块的引用? (SystemVerilog)
Input a reference to another module in a module instantiation? (SystemVerilog)
我有专门的测试台模块,用于 printing/tracing 关于我的测试台中 DUT 的信息。我想避免将所有有趣的(内部)信号连接到 tb 模块。
举个例子,假设我的 DUT 中有一个内部信号 a
。如何在 printer.sv
中访问它而无需创建匹配输入?素描:
/---- TB.sv -----------------------------------------\
| |
| /--dut.sv--\ /--printer.sv-------------\ |
| | wire a; | -> | always @(posedge clk) | |
| | | | $display("a is %d", a); | |
| \----------/ \-------------------------/ |
| |
\----------------------------------------------------/
我一直在查看 bind
关键字,看它是否可以帮助我,但我不明白。
printer.vs 需要的信号数量很大,所以我真的很想避免必须将所有内容都声明为输入,这非常乏味。
是否有某种方法可以将分层引用传递给实例化的 dut 模块?
可以在绑定的打印机模块中使用向上引用
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
bind DUT printer p(clk);
endmodule
并不是说向上名称引用是独立于 bind
的 Verilog 功能。绑定功能的工作方式与您在 DUT 中编写实例完全一样。这与您可以使用顶级模块名称作为引用开头的原因相同。
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
printer p(clk); // what bind is actually doing
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
endmodule
我有专门的测试台模块,用于 printing/tracing 关于我的测试台中 DUT 的信息。我想避免将所有有趣的(内部)信号连接到 tb 模块。
举个例子,假设我的 DUT 中有一个内部信号 a
。如何在 printer.sv
中访问它而无需创建匹配输入?素描:
/---- TB.sv -----------------------------------------\
| |
| /--dut.sv--\ /--printer.sv-------------\ |
| | wire a; | -> | always @(posedge clk) | |
| | | | $display("a is %d", a); | |
| \----------/ \-------------------------/ |
| |
\----------------------------------------------------/
我一直在查看 bind
关键字,看它是否可以帮助我,但我不明白。
printer.vs 需要的信号数量很大,所以我真的很想避免必须将所有内容都声明为输入,这非常乏味。
是否有某种方法可以将分层引用传递给实例化的 dut 模块?
可以在绑定的打印机模块中使用向上引用
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
bind DUT printer p(clk);
endmodule
并不是说向上名称引用是独立于 bind
的 Verilog 功能。绑定功能的工作方式与您在 DUT 中编写实例完全一样。这与您可以使用顶级模块名称作为引用开头的原因相同。
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
printer p(clk); // what bind is actually doing
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
endmodule