Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17254 Discussions

Generic interfaces in Quartus II

Altera_Forum
Honored Contributor II
1,279 Views

I use interfaces a lot in my designs. They are indispensable. 

 

I noted that Quartus II 9.0 supposedly supports generic interfaces. I have tried a number of ways to do this, but have not been successful. I assume that since QII supports both parameterized and generic interfaces, there is a way to implement them. 

 

I have a parameterized interface, so I cannot fully specify the interface in the module definitions. Things work fine to specify the module at the top level and provide the paramter, but how to pass to a lower level module the parameterized interface? I tried a generic, but Quartus complains that you cannot use a generic interface without module binding.. perhaps the module order is wrong?  

 

Here is a scaled down example of what I am trying to do: 

 

 

interface IF_IOChannel 

# (parameter size=5); 

 

logic OE; 

logic Out; 

logic In; 

 

modport master ( 

output OE, Out, 

input In 

); 

 

modport drv( 

input OE,Out 

); 

 

modport rd( 

output In 

); 

 

endinterface 

 

module Ch1Mod ( 

.. 

interface _if 

); 

 

.. 

 

endmodule 

 

/// similar for Ch2Mod 

 

 

module top(...) 

IF_IOChannel # (.size(3)) if_ch1; 

IF_IOChannel# (.size(8)) if_ch2; 

 

Ch1Mod mc1inst(._if(if_ch1)); 

Ch2Mod mc2inst(._if(if_ch2)); 

endmodule
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
549 Views

I 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
0 Kudos
Reply