Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use parameterized interfaces?

I am struggling to understand interfaces. At first, they seem simple enough, but once I started to work with parameterized interfaces, I just can't get the pieces to fall into place.

I have this interface:

interface my_if #( 
    parameter H_WIDTH = 64,
    parameter L_WIDTH = 8
);
logic [H_WIDTH -1:0]  a;
logic [L_WIDTH -1:0]  b;
logic                 ready;
modport in ( input a, input b, output valid);
modport out( output a, output b, input ready);
endinterface;

and I want to use that as a port in my module:

module my_module (
logic input clk,
logic input rst,
my_if.in    my_if
);

I don't see how to set the parameters of my interface.
I have tried the following instead of the above:

my_if(#.H_WIDTH((64), .L_WIDTH(64)) my_if()

and

my_if(#.H_WIDTH((64), .L_WIDTH(64)).in my_if()

which does not compile.

How do I then set the parameters of my interface?

The solution has to synthesize as this is not for verification.

like image 968
rasmus Avatar asked Jul 19 '26 19:07

rasmus


2 Answers

You set parameters of an interface instance exactly the same way you set parameters of module; when it is instantiated. There is no syntax that allows you to set the parameters of an interface port. The parameter values are based on the interface instance connected to the port when instantiating the module.

This presents a problem when the top level module you are synthesizing has an interface port. It similar to when the top-level module has parameters that needs to be overridden. You need to check the synthesis manual of the tool you are using to see how to manually override the parameters.

like image 50
dave_59 Avatar answered Jul 21 '26 17:07

dave_59


You are almost there! In your top module (where you instantiate the interface), you only have to change:

my_if(#.H_WIDTH((64), .L_WIDTH(64)) my_if()

to

my_if # (.H_WIDTH(64), .L_WIDTH(64)) my_if()

And you should be good to go. The IEEE 1800-2012 LRM has a section (25.8 Parameterized interfaces) on this topic that you should go over.

like image 28
AndresM Avatar answered Jul 21 '26 19:07

AndresM