In your approach you can not pass interface between two modules. Interfaces are passed to modules through instantiation ports. In classical verilog approach you need to have yet another top
module to instantiate all of it:
module tb(MyInterface i);
...
endmodule
module test(MyInteface i);
...
endmodule
interface MyInterface;
...
endinterface
module top();
MyInterface myIntf;
tb tb(myIntf);
test test(myIntf);
endmodule
It is possible to go a bit ugly and instantiate your interface inside tb and pass it to the test as the following
module top();
tb tb();
test test (tb.myIntf);
endmodule
The other approach is to instantiate your test within the testbench. This will save you all the above trouble and you can naturally pass the interface to it:
module test...
module tb();
MyInterface myIf;
test test(myIf);
...
endmodule
Or even better, in system verilog you can design your test as a class and pass virtual interfaces around.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…