I have the following Verilog file named main.v
:
module m1(input a, b, output wire c);
assign c = a & b;
endmodule
module main(input x, y, output wire z);
wire k;
m1 m1_inst(.a(x), .b(y), .c(k));
assign z = x ^ k;
endmodule
After that, I have a test bench named tb_main.v
which has an instantiation as shown below:
`include "main.v"
reg a, b;
wire b;
main main_dut(a, b, c);
$display("%b", main_dut.m1.a);
$display("%b", main_dut.main.y);
$display("%b", m1.a);
When I simulate that testbench, I get the error unresolved reference to m1
and unresolved reference to main
.
How do I solve this problem? I do not want to separate modules in the main.v
file into different files.
Any help will be appreciated.