interface_bundle.sv 737 Bytes
Newer Older
1
interface bundle;
2 3 4
    logic [1:0] index = 0;
    logic clock = 0;
    logic [3:0] inp = '1;
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 33 34 35 36 37 38 39 40
    logic out;
endinterface

module rotator(bundle b);
    always @(posedge b.clock)
        b.index <= b.index + 1;
endmodule

module setter(bundle b);
    always @(posedge b.clock)
        b.inp[b.index] <= b.out;
endmodule

module reducer(bundle b);
    assign b.out = ^b.inp;
endmodule

module clocker(bundle b);
    initial begin
        forever
            #5 b.clock <= ~b.clock;
    end
endmodule

module top;
    bundle b();
    rotator rot(b);
    setter set(b);
    reducer red(b);
    clocker clk(b);
    initial begin
        $monitor("%b %b %b %b", b.index, b.clock, b.inp, b.out);
        #100;
        $finish;
    end
endmodule