interface_module.sv 639 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
interface InterfaceA;
    logic x;
    modport M(input x);
endinterface

interface InterfaceB;
    logic y;
    modport N(input y);
endinterface

module ModuleA(modport_a);
    InterfaceA modport_a;
    initial $display("ModuleA %b", modport_a.x);
endmodule

module ModuleB(modport_b);
    InterfaceB modport_b;
    InterfaceA interface_a();
    ModuleA module_a(interface_a.M);
    initial $display("ModuleB %b", modport_b.y);
    assign interface_a.x = 0;
endmodule

module ModuleC;
    InterfaceB interface_b();
    ModuleB module_b(interface_b.N);
    assign interface_b.y = 1;
endmodule

module top;
    ModuleC module_c();
endmodule