data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv
 line:51: before: ";"
1: b'%Warning-STMTDLY: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:129: Unsupported: Ignoring delay on this delayed statement.\n    always #100000 px_clk = ~px_clk;\n           ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:134: Unsupported: wait statements\n        wait(~dut.rst)\n        ^~~~\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:144: Unsupported: wait statements\n            wait (dut.s_state == dut.S_WAIT_UART);\n            ^~~~\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:148: syntax error, unexpected \'@\'\n            @(posedge dut.clk);\n            ^\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:151: Unsupported: wait statements\n            wait(dut.s_state == dut.S_WAIT_FRAME);\n            ^~~~\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:153: syntax error, unexpected \'@\'\n            repeat (100) @(posedge px_clk);\n                         ^\n%Error: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:159: Unsupported: wait statements\n            wait (dut.s_state == dut.S_WAIT_UART);\n            ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/204736068/SoM/RTL/vision/tb/tb_blink_himax.sv:161: Unsupported: Ignoring delay on this delayed statement.\n        #10000000;\n        ^\n%Error: Exiting due to 6 error(s), 2 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module tb_blink_himax;

    parameter NUM_ROWS       = 30;
    parameter NUM_COLS       = 40;
    parameter UART_PERIOD    = 6 ;
    parameter NUM_HIMAX_CMDS = 1 ;

    logic       uart_rx        ;
    logic       uart_tx        ;
    logic [2:0] gpio           ;
    logic       host_intr      ;
    tri1        i2c_scl        ;
    tri1        i2c_sda        ;
    logic       sensor_clk     ;
    logic       px_clk     = '0;
    logic       px_fv          ;
    logic       px_lv          ;
    logic [7:0] pxd            ;
    logic       sensor_led     ;
    logic       led_red        ;
    logic       led_green      ;
    logic       led_blue       ;

    blink_himax #(.UART_PERIOD(UART_PERIOD), .NUM_HIMAX_CMDS(NUM_HIMAX_CMDS)) dut (
        .uart_rx   (uart_rx   ),
        .uart_tx   (uart_tx   ),
        .gpio      (gpio      ),
        .host_intr (host_intr),
        .i2c_scl   (i2c_scl   ),
        .i2c_sda   (i2c_sda   ),
        .sensor_clk(sensor_clk),
        .px_clk    (px_clk    ),
        .px_fv     (px_fv     ),
        .px_lv     (px_lv     ),
        .pxd       (pxd[3:0]  ),
        .sensor_led(sensor_led),
        .led_red   (led_red   ),
        .led_green (led_green ),
        .led_blue  (led_blue  )
    );


    i2c_slave_model #(.I2C_ADR(7'b010_0100) ) i_i2c_slave_model (.scl(i2c_scl), .sda(i2c_sda));


    camera_model #(.FOUR_BITS("TRUE"), .WIDTH(8), .HOR_BLANK(4), .MAX_ROWS(NUM_ROWS), .MAX_COLS(NUM_COLS)) camera (
        .clk  (px_clk),
        .pixel(pxd   ),
        .vsync(px_fv ),
        .hsync(px_lv )
    );


    logic [7:0] uart_din, uart_dout;
    logic uart_din_valid, uart_dout_valid;
    logic uart_empty;
    lsc_uart #(.PERIOD    (UART_PERIOD)) i_lsc_uart (
        .ref_clk(dut.clk        ),
        .clk    (dut.clk        ),
        .resetn (~dut.rst       ),
        .i_din  (uart_din       ),
        .i_valid(uart_din_valid ),
        .o_empty(               ),
        .o_dout (uart_dout      ),
        .o_valid(uart_dout_valid),
        .i_rxd  (uart_tx        ),
        .o_txd  (uart_rx        )
    );


    always @(posedge uart_dout_valid) begin
        $display("%t:::UART_RX_DATA: 0x%x", $time, uart_dout);
    end


    logic [7:0] uart_dout_d;

    always_ff @(posedge dut.clk) begin
        if(uart_dout_valid) begin
            if (uart_dout_d + 'd1 != uart_dout)
                $error("%t::: UART pixels out of sequence! Expected: 0x%x, got: 0x%x", $time, uart_dout_d, uart_dout);

            uart_dout_d <= uart_dout;

        end
    end



    always #100000 px_clk = ~px_clk;

    logic [7:0] stimulus[0:NUM_COLS*NUM_ROWS-1];
    initial begin

        wait(~dut.rst)


        dut.timer = 'hffff0;


        for (int i=0; i<NUM_COLS*NUM_ROWS; i++)
            stimulus[i] = i;

        repeat (2) begin
            wait (dut.s_state == dut.S_WAIT_UART);

            uart_din = '1;
            uart_din_valid = '1;
            @(posedge dut.clk);
            uart_din_valid = '0;

            wait(dut.s_state == dut.S_WAIT_FRAME);

            repeat (100) @(posedge px_clk);

            camera.write_frame(NUM_COLS, NUM_ROWS, stimulus);

            $display("Done sending frame...");

            wait (dut.s_state == dut.S_WAIT_UART);
        end
        #10000000;
        $finish;       

    end
endmodule
module tb_blink_himax;


    parameter NUM_ROWS       = 30;
    parameter NUM_COLS       = 40;
    parameter UART_PERIOD    = 6 ;
    parameter NUM_HIMAX_CMDS = 1 ;

    logic       uart_rx        ;
    logic       uart_tx        ;
    logic [2:0] gpio           ;
    logic       host_intr      ;
    tri1        i2c_scl        ;
    tri1        i2c_sda        ;
    logic       sensor_clk     ;
    logic       px_clk     = '0;
    logic       px_fv          ;
    logic       px_lv          ;
    logic [7:0] pxd            ;
    logic       sensor_led     ;
    logic       led_red        ;
    logic       led_green      ;
    logic       led_blue       ;

    blink_himax #(.UART_PERIOD(UART_PERIOD), .NUM_HIMAX_CMDS(NUM_HIMAX_CMDS)) dut (
        .uart_rx   (uart_rx   ),
        .uart_tx   (uart_tx   ),
        .gpio      (gpio      ),
        .host_intr (host_intr),
        .i2c_scl   (i2c_scl   ),
        .i2c_sda   (i2c_sda   ),
        .sensor_clk(sensor_clk),
        .px_clk    (px_clk    ),
        .px_fv     (px_fv     ),
        .px_lv     (px_lv     ),
        .pxd       (pxd[3:0]  ),
        .sensor_led(sensor_led),
        .led_red   (led_red   ),
        .led_green (led_green ),
        .led_blue  (led_blue  )
    );


    i2c_slave_model #(.I2C_ADR(7'b010_0100) ) i_i2c_slave_model (.scl(i2c_scl), .sda(i2c_sda));


    camera_model #(.FOUR_BITS("TRUE"), .WIDTH(8), .HOR_BLANK(4), .MAX_ROWS(NUM_ROWS), .MAX_COLS(NUM_COLS)) camera (
        .clk  (px_clk),
        .pixel(pxd   ),
        .vsync(px_fv ),
        .hsync(px_lv )
    );


    logic [7:0] uart_din, uart_dout;
    logic uart_din_valid, uart_dout_valid;
    logic uart_empty;
    lsc_uart #(.PERIOD    (UART_PERIOD)) i_lsc_uart (
        .ref_clk(dut.clk        ),
        .clk    (dut.clk        ),
        .resetn (~dut.rst       ),
        .i_din  (uart_din       ),
        .i_valid(uart_din_valid ),
        .o_empty(               ),
        .o_dout (uart_dout      ),
        .o_valid(uart_dout_valid),
        .i_rxd  (uart_tx        ),
        .o_txd  (uart_rx        )
    );


    always @(posedge uart_dout_valid) begin
        $display("%t:::UART_RX_DATA: 0x%x", $time, uart_dout);
    end


    logic [7:0] uart_dout_d;

    always_ff @(posedge dut.clk) begin
        if(uart_dout_valid) begin
            if (uart_dout_d + 'd1 != uart_dout)
                $error("%t::: UART pixels out of sequence! Expected: 0x%x, got: 0x%x", $time, uart_dout_d, uart_dout);

            uart_dout_d <= uart_dout;

        end
    end



    always #100000 px_clk = ~px_clk;

    logic [7:0] stimulus[0:NUM_COLS*NUM_ROWS-1];
    initial begin

        wait(~dut.rst)


        dut.timer = 'hffff0;


        for (int i=0; i<NUM_COLS*NUM_ROWS; i++)
            stimulus[i] = i;

        repeat (2) begin
            wait (dut.s_state == dut.S_WAIT_UART);

            uart_din = '1;
            uart_din_valid = '1;
            @(posedge dut.clk);
            uart_din_valid = '0;

            wait(dut.s_state == dut.S_WAIT_FRAME);

            repeat (100) @(posedge px_clk);

            camera.write_frame(NUM_COLS, NUM_ROWS, stimulus);

            $display("Done sending frame...");

            wait (dut.s_state == dut.S_WAIT_UART);
        end
        #10000000;
        $finish;       

    end
endmodule