Forum Discussion

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

How to use a module or interface instance in an interface?

Hello,every one!

I have some problem in using interface of SystemVerilog:

I have a predefined module and interface, and I want to use them in another interface. The example code of module in interface is:


module predef_mod(
     input clk,
     input rst,
     output reg cntr_o
);
    always_ff @(posedge clk)
        if (rst) cntr_o <= 4'd0;
        else cntr_o <= cntr_o + 4'd1;
endmodule
interface use_predef_mod_if(
    input clk,
    input rst,
    output wire cntr
);
    predef_mod modi(
        .clk(clk),
        .rst(rst),
        .cntr_o(cntr)
    );
endinterface

The example code of interface in interface is:


interface predef_if(
    input clk,
    input rst,
    output reg cntr_o
);
    always_ff @(posedge clk)
        if (rst) cntr_o <= 4'd0;
        else cntr_o <= cntr_o + 4'd1;
endinterface
interface use_predef_intf_if(
    input clk,
    input rst,
    output wire cntr
);
    predef_if ifi(
        .clk(clk),
        .rst(rst),
        .cntr_o(cntr)
    );
endinterface

The synthesizing result about the first code in QuartusII is reporting an error message like 'instantiation of module in interface is not allowed'.

The result about the second code is raising an assertion failure in quartus_map.exe.

I have read the interface section of SystemVerilog standard document:IEEE.1800-2012, and it seems that the standard had never announced that the usage like above is illegal.

Maybe there are some syntax error? Please help me, Thanks!

BTW:

I have to say sorry for the possible typos in the code, For I'm typing these example code immediately on the forum, and I have no time to test them....

11 Replies