Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheritance-like feature for interfaces

A great feature of SystemVerilog is inheritance, which AFAIK is limited to classes.

I was wondering if there is a way to mimic inheritance and overloading for interfaces.

For example, suppose interface2 has all signals defined in interface1 pluse sig1001 and modport2. What is the best way of defining interface2 without rewriting everything?

interface interface1;
   logic sig1;
   ...
   logic sig1000;

   modport modport1(....);
   task task1;
   ...
   endtask
endinterface

interface interface2;
   logic sig1;                    //similar to interface1
   ...
   logic sig1000;                 //similar to interface1
   logic sig1001;

   modport modport1(....);        //similar to interface1
   modport modport2(....);

   task task1;                   //similar to interface1
   ...
   endtask
endinterface

I need it to be synthesizable. My goal is not to maintain several interfaces as my code evolves I was thinking of defining a parameter and use if/generate. Any ideas are welcome.

like image 607
Ari Avatar asked Dec 19 '25 01:12

Ari


1 Answers

There is no way to compose a SystemVerilog interface from other interfaces either by using inheritance or encapsulating them hierarchically. The only way to achieve something similar is to put sections of the interface in separate files and `include them as needed.

If you need to do this for a testbench, then you are better off using classes instead.

like image 135
dave_59 Avatar answered Dec 20 '25 20:12

dave_59



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!