Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Array of interfaces in SV

Hi all,

I want to write a module, which accepts an array of I/F.

is this possible? I see that it runs in simulation but I can't synthesize it...

could someone please advice me?

thanks!

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can do it, but you have to do it a certain way for Quartus to synthesize it. The module port must be an unpacked array of interface modport's. You need an unpacked array of interfaces to connect to it. When you instantiate the module, make the port connection with the name of the interface array only, not the modports.

    
    interface iface();
        logic a;
        logic b;
        modport mport(input a, output b);
    endinterface
    module mod (
        iface.mport iface_array 
    );
        ...
    endmodule
    module top ();
        iface top_iface_array  ();
        mod mod_inst(.iface_array(top_iface_array));
        ...
    endmodule
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thanks!

    followup question - in case I do exactly like you showed above.

    how can I forward an interface-array to a submodule?? (this is my main problem...)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can forward the whole array to the sub-module like this:

    
    interface iface();
        logic a;
        logic b;
        modport mport(input a, output b);
    endinterface
    module submod (
        iface.mport iface_array 
    );
        ...
    endmodule
    module mod (
        iface.mport iface_array 
    );
        submod submod_inst(.iface_array(iface_array));
    endmodule
    module top ();
        iface top_iface_array  ();
        mod mod_inst(.iface_array(top_iface_array));
    endmodule
    
    Or you can break out the array to a set of sub-modules like this:

    
    interface iface();
        logic a;
        logic b;
        modport mport(input a, output b);
    endinterface
    module submod (
        iface.mport iface_port
    );
        ...
    endmodule
    module mod (
        iface.mport iface_array 
    );
        genvar i;
        generate
            for(i=0; i<4; i++) begin : submod_lp
                submod submod_inst(.iface_port(iface_array));
            end
        endgenerate
    endmodule
    module top ();
        iface top_iface_array  ();
        mod mod_inst(.iface_array(top_iface_array));
    endmodule
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Does anyone know how to deal with the array of interface scenario presented in this thread if you were to add some input ports to the interface?

    Example:

    interface iface(input logic clk)

    logic a;

    logic b;

    modport mport (input a, output b);

    endinterface

    ** How would you instantiate the array of interfaces so each interface in the array could have it's own clk wired to a unique clock? If I do as follows:

    iface top_iface_array [3:0] (.clk (my_clk));

    I have only wired up to a single clock and it really doesn't make sense when I'm referencing an array of interfaces.

    Thanks.

    ----------------------------------

    --- Quote Start ---

    You can do it, but you have to do it a certain way for Quartus to synthesize it. The module port must be an unpacked array of interface modport's. You need an unpacked array of interfaces to connect to it. When you instantiate the module, make the port connection with the name of the interface array only, not the modports.

    
    interface iface();
        logic a;
        logic b;
        modport mport(input a, output b);
    endinterface
    module mod (
        iface.mport iface_array 
    );
        ...
    endmodule
    module top ();
        iface top_iface_array  ();
        mod mod_inst(.iface_array(top_iface_array));
        ...
    endmodule
    

    --- Quote End ---