Search code examples
interfaceverilogsystem-verilog

How to use system Verilog hierarchical interfaces


Can the top module in system verilog have interface ports? I am trying to define a hierarchical interface and then trying to use that interface for the top module.

Please check below example code and let me know if I am missing something

interface bank_inf (
                inout logic [20:0] data_io,
                inout logic qsb_io,
                inout logic ctrl_io);
endinterface

interface channel_inf #(parameter numbanks = 7)
        ( bank_inf banks[numbanks-1:0] );
endinterface


interface ss1_inf #(parameter numchannels = 8, parameter numbanks = 7)
        ( channel_inf channels[numchannels-1:0]);
endinterface

module die1 (ss1_inf ss);
endmodule
module die2 (ss1_inf ss);
endmodule

module top (
ss1_inf ss1,
ss1_inf ss2
                );
   die1 inst1(ss1);
   die2 inst2(ss1);
endmodule

I am getting below error:
Error-[SV-UIP] Unconnected interface port
../test.v, 22
"ss1"
  The port 'ss1' of top-level module 'top' whose type is interface 'ss1_inf'
  is left unconnected. It is illegal to leave the interface ports unconnected.
  Please make sure that all the interface ports are connected.

Solution

  • From a language and simulation perspective, the top level module cannot have interface ports. Interface ports represent references to hierarchical interface instances. Those instances are where allocation of variables and other processes exist. Also, interfaces may be parameterized and the only way to specify that parameterization is through an actual instance. There is no syntax that allows parameterization in the port declaration.

    But from the synthesis perspective, the highest level you provide to a synthesis tool may allow interface ports. But you should check with the particular synthesis tool vendor you are using.