我可以使用来自顶级模块的连线作为绑定模块实例化中的输入吗? (SystemVerilog)
Can I use wires from top module as inputs in a bind module instantiation? (SystemVerilog)
我有一个简单的打印机模块,我想通过绑定到一个测试平台 BIG_TB 中的另一个模块 BIG_DUT 来实例化它。 BIG_DUT 有另一个模块 SMALL_DUT 的实例,其中包含我想在 PRINTER 中使用的大部分内容。我有另一个测试台 SMALL_TB,它有一个 SMALL_DUT 实例和一个 PRINTER 实例,在这个测试台中,我想将 PRINTER 绑定到 SMALL_DUT.
在我的 PRINTER 模块中,我需要一根存在于任一测试台以及 BIG_DUT、 但不存在于 SMALL_DUT 中的电线。有什么方法可以使用测试台的电线而不是尝试访问 BIG_DUT/SMALL_DUT 内部的电线,同时仍然可以轻松访问 SMALL_DUT 中的其他 wires/stuff?
示例代码:
module SMALL_DUT();
// Stuff I want to use in the PRINTER
...
endmodule
module BIG_DUT(
input wire big_dut_input
);
SMALL_DUT small_dut_in_big();
endmodule
module PRINTER(
// Can I take input here from tb?
);
// For BIG_TB, I could use big_dut_input and small_dut_in_big.stuff_i_want_to_use
// For SMALL_TB, there is no wire I could use, but I can reference stuff_i_want_to_use
endmodule
module BIG_TB();
wire my_tb_wire_big; // Want to use this in PRINTER, also present in BIG_DUT
BIG_DUT big_dut(
.big_dut_input(my_tb_wire_big)
);
// I could potentially do
// bind big_dut.small_dut_in_big
// here to get the same access pattern to stuff inside PRINTER
bind big_dut
PRINTER big_printer(
// Could I input my_tb_wire_big here?
);
endmodule
module SMALL_TB();
wire my_tb_wire_small; // Same usage as my_tb_wire_big in PRINTER
...
SMALL_DUT small_dut();
bind small_dut
PRINTER small_printer(
// Could I input my_tb_wire_small here?
);
endmodule
(在这个简单的示例中,我当然可以向 SMALL_DUT 添加另一个输入,但在我的实际代码中使用了它,我不希望那里有额外的输入。)
您始终可以在实例端口连接中放置分层引用。无论是否使用 bind
结构都是如此。
module SMALL_DUT();
bit stuff;
...
endmodule
module BIG_DUT(
input wire big_dut_input
);
SMALL_DUT small_dut_in_big();
endmodule
module PRINTER(
input signal1, signal2, signal3)
// stuff
endmodule
module BIG_TB();
wire my_tb_wire_big; // Want to use this in PRINTER, also present in BIG_DUT
BIG_DUT big_dut(
.big_dut_input(my_tb_wire_big)
);
bind big_dut
PRINTER big_printer(
BIG_TB.my_tb_wire_big, small_dut_in_big.stuff);
);
endmodule
module SMALL_TB();
wire my_tb_wire_small; // Same usage as my_tb_wire_big in PRINTER
...
SMALL_DUT small_dut();
bind small_dut
PRINTER small_printer(
SMALL_TB.my_tb_wire_small, stuff
);
endmodule
我有一个简单的打印机模块,我想通过绑定到一个测试平台 BIG_TB 中的另一个模块 BIG_DUT 来实例化它。 BIG_DUT 有另一个模块 SMALL_DUT 的实例,其中包含我想在 PRINTER 中使用的大部分内容。我有另一个测试台 SMALL_TB,它有一个 SMALL_DUT 实例和一个 PRINTER 实例,在这个测试台中,我想将 PRINTER 绑定到 SMALL_DUT.
在我的 PRINTER 模块中,我需要一根存在于任一测试台以及 BIG_DUT、 但不存在于 SMALL_DUT 中的电线。有什么方法可以使用测试台的电线而不是尝试访问 BIG_DUT/SMALL_DUT 内部的电线,同时仍然可以轻松访问 SMALL_DUT 中的其他 wires/stuff?
示例代码:
module SMALL_DUT();
// Stuff I want to use in the PRINTER
...
endmodule
module BIG_DUT(
input wire big_dut_input
);
SMALL_DUT small_dut_in_big();
endmodule
module PRINTER(
// Can I take input here from tb?
);
// For BIG_TB, I could use big_dut_input and small_dut_in_big.stuff_i_want_to_use
// For SMALL_TB, there is no wire I could use, but I can reference stuff_i_want_to_use
endmodule
module BIG_TB();
wire my_tb_wire_big; // Want to use this in PRINTER, also present in BIG_DUT
BIG_DUT big_dut(
.big_dut_input(my_tb_wire_big)
);
// I could potentially do
// bind big_dut.small_dut_in_big
// here to get the same access pattern to stuff inside PRINTER
bind big_dut
PRINTER big_printer(
// Could I input my_tb_wire_big here?
);
endmodule
module SMALL_TB();
wire my_tb_wire_small; // Same usage as my_tb_wire_big in PRINTER
...
SMALL_DUT small_dut();
bind small_dut
PRINTER small_printer(
// Could I input my_tb_wire_small here?
);
endmodule
(在这个简单的示例中,我当然可以向 SMALL_DUT 添加另一个输入,但在我的实际代码中使用了它,我不希望那里有额外的输入。)
您始终可以在实例端口连接中放置分层引用。无论是否使用 bind
结构都是如此。
module SMALL_DUT();
bit stuff;
...
endmodule
module BIG_DUT(
input wire big_dut_input
);
SMALL_DUT small_dut_in_big();
endmodule
module PRINTER(
input signal1, signal2, signal3)
// stuff
endmodule
module BIG_TB();
wire my_tb_wire_big; // Want to use this in PRINTER, also present in BIG_DUT
BIG_DUT big_dut(
.big_dut_input(my_tb_wire_big)
);
bind big_dut
PRINTER big_printer(
BIG_TB.my_tb_wire_big, small_dut_in_big.stuff);
);
endmodule
module SMALL_TB();
wire my_tb_wire_small; // Same usage as my_tb_wire_big in PRINTER
...
SMALL_DUT small_dut();
bind small_dut
PRINTER small_printer(
SMALL_TB.my_tb_wire_small, stuff
);
endmodule