Forum Discussion
Altera_Forum
Honored Contributor
17 years agoI figured out how to do this.. and I will post the solution.
I was pretty close to begin with. Build the parameterized interface, use modports as normal. For modules that use the interface, use the generic name "interface" as the port type. When you instantiate a module, specify the modport to use in the instantation. Ex: module top(...) IF_IOChannel # (.size(3)) if_ch1; IF_IOChannel# (.size(8)) if_ch2; Ch1Mod mc1inst(._if(if_ch1.slave)); Ch2Mod mc2inst(._if(if_ch2.master)); endmodule I did not realize that it was possible to specify the modport in the module definition OR in the instantation. In this case, it makes sense to use the instantation. The next thing to resolve is the size of any logic or loops in the using modules. I found that what works best (synthesizes in Quartus) is to use a parameter in your "Using" module. When you instantiate the using module, override the parameter but use the $size operator. Ch1Mod# (.size($size(if_ch1.OE)) mc1inst(._if(if_ch1.slave)); Ch2Mod# (.size($size(if_ch2.OE)) mc2inst(._if(if_ch2.master)); In the above case it does not matter which parameter you use, i.e. check the size of OE, Out, etc. since they are all the same. If you instantiate the interface and the using modules at the same level, you can just use the same parameter.. but I found that the $size works even if you instantiate a module at a lower level.. meaning you have a top level module taking the generic interface, then inside of that module you instantiate another module that uses this generic interface. At that point, you could use the $size... You could also pass the parameter down through the modules, but I like the $size better. Cheers, Ed