File size: 1,412 Bytes
035592e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module testbench;

    reg clk;
    reg reset;
    wire [7:0] out;

    ring_counter ring_counter_inst (
        .clk(clk),
        .reset(reset),
        .out(out)
    );

    always begin
        #5 clk <= ~clk;
    end

    

    reg [3:0] i;
    reg [7:0] data [0:9];  // ICARUS PORT: was a declaration initializer {8'b00000001, ..., 8'b00000001}
    initial begin
        data[0] = 8'b00000001; data[1] = 8'b00000001; data[2] = 8'b00000010; data[3] = 8'b00000100; data[4] = 8'b00001000;
        data[5] = 8'b00010000; data[6] = 8'b00100000; data[7] = 8'b01000000; data[8] = 8'b10000000; data[9] = 8'b00000001;
    end

    initial begin
        clk = 0;
        reset = 1;
        i=0;
        #10 reset = 0;
    end
    // Monitor for displaying output
    always @(posedge clk) begin
        
        if (out !== data[i]) begin
            $display("Failed at i=%d, out=%b, expected=%b", i, out, data[i]);
            // $finish;
        end
        i = i + 1;
    end

    // Stop simulation after checking all values
    always @(posedge clk) begin
        #0;  // ICARUS PORT: run after the checker block's `i = i + 1` in the same time step (same-timestep race)
        if (i == 9) begin
            $display("=========== Your Design Passed ===========");
            $finish;
        end
    end
    // Stop simulation after 100 clock cycles
    initial begin
        #100 $finish;
    end

endmodule