data/full_repos/permissive/166008742/src/buf_updater_squares.v
1: b'%Error: data/full_repos/permissive/166008742/src/buf_updater_squares.v:38: Cannot find include file: globals.vh\n    `include "globals.vh" \n             ^~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/166008742/src,data/full_repos/permissive/166008742/globals.vh\n             data/full_repos/permissive/166008742/src,data/full_repos/permissive/166008742/globals.vh.v\n             data/full_repos/permissive/166008742/src,data/full_repos/permissive/166008742/globals.vh.sv\n             globals.vh\n             globals.vh.v\n             globals.vh.sv\n             obj_dir/globals.vh\n             obj_dir/globals.vh.v\n             obj_dir/globals.vh.sv\n%Error: data/full_repos/permissive/166008742/src/buf_updater_squares.v:107: Define or directive not defined: \'`IMG_HEIGHT\'\n    wire last_row = (row_cnt == `IMG_HEIGHT-1);\n                                ^~~~~~~~~~~\n%Error: data/full_repos/permissive/166008742/src/buf_updater_squares.v:108: Define or directive not defined: \'`IMG_WIDTH\'\n    wire last_col = (col_cnt == `IMG_WIDTH-1);\n                                ^~~~~~~~~~\n%Error: data/full_repos/permissive/166008742/src/buf_updater_squares.v:124: Define or directive not defined: \'`IMG_WIDTH\'\n            if (col_cnt != `IMG_WIDTH-1) begin\n                           ^~~~~~~~~~\n%Error: Exiting due to 4 error(s)\n'
module buf_updater_squares #(parameter ADDR_WIDTH = 16, parameter DATA_WIDTH = 32)
(
    input      reset,
    input      clk,


    output     [ADDR_WIDTH-1:0] wbm_address,
    output     [DATA_WIDTH-1:0] wbm_writedata,
    input      [DATA_WIDTH-1:0] wbm_readdata,
    output     wbm_strobe,
    output     wbm_cycle,
    output     wbm_write,
    input      wbm_ack,


    input      [DATA_WIDTH-1:0] buf_id,
    input      update_buf,
    output     buf_updated
);

    `include "globals.vh"

    localparam ST_IDLE            = 0;
    localparam ST_INIT_COUNTERS   = 1;
    localparam ST_UPDATE_COUNTERS = 2;
    localparam ST_SEND_COLOR      = 3;
    localparam ST_COLOR_SENT      = 4;
    localparam ST_DONE            = 5;

    reg [2:0] state, next_state;

    always @(posedge clk or posedge reset) begin
        if (reset) begin
            state <= ST_IDLE;
        end
        else begin
            state <= next_state;
        end
    end

    always @(*) begin
        next_state = state;
        case (state)
            ST_IDLE: begin
                if (update_buf) next_state = ST_INIT_COUNTERS;
            end
            ST_INIT_COUNTERS: begin
                next_state = ST_SEND_COLOR;
            end
            ST_UPDATE_COUNTERS: begin
                next_state = ST_SEND_COLOR;
            end
            ST_SEND_COLOR: begin
                if (wbm_ack) next_state = ST_COLOR_SENT;
            end
            ST_COLOR_SENT: begin
                next_state = (last_row & last_col) ? ST_DONE : ST_UPDATE_COUNTERS;
            end
            ST_DONE: begin
                next_state = ST_IDLE;
            end
            default: begin
                next_state = ST_IDLE;
            end
        endcase
    end

    assign buf_updated = (state == ST_DONE);


    assign wbm_strobe    = (state == ST_SEND_COLOR);
    assign wbm_cycle     = (state == ST_SEND_COLOR);
    assign wbm_write     = 1;
    assign wbm_writedata = color;
    assign wbm_address   = img_pixel_addr;



    wire [31:0] color = last_col ? 32'b0 : 
       {   8'b0,
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}},
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}},
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}} };


    reg [ADDR_WIDTH-1:0] row_cnt;
    reg [ADDR_WIDTH-1:0] col_cnt;
    reg [ADDR_WIDTH-1:0] img_pixel_addr;

    wire last_row = (row_cnt == `IMG_HEIGHT-1);
    wire last_col = (col_cnt == `IMG_WIDTH-1);

    always @(posedge clk or posedge reset) begin
        if (reset) begin
            row_cnt        <= 0;
            col_cnt        <= 0;
            img_pixel_addr <= 0;
        end
        else if (state == ST_INIT_COUNTERS) begin
            row_cnt        <= 0;
            col_cnt        <= 0;
            img_pixel_addr <= addr_for_buf_id(buf_id);
        end
        else if (state == ST_UPDATE_COUNTERS) begin
            img_pixel_addr <= img_pixel_addr + DATA_WIDTH/8;
            
            if (col_cnt != `IMG_WIDTH-1) begin
                col_cnt    <= col_cnt + 1;
            end
            else begin
                col_cnt    <= 0;
                row_cnt    <= row_cnt + 1;
            end
        end
    end


endmodule
module buf_updater_squares #(parameter ADDR_WIDTH = 16, parameter DATA_WIDTH = 32)
(
    input      reset,
    input      clk,


    output     [ADDR_WIDTH-1:0] wbm_address,
    output     [DATA_WIDTH-1:0] wbm_writedata,
    input      [DATA_WIDTH-1:0] wbm_readdata,
    output     wbm_strobe,
    output     wbm_cycle,
    output     wbm_write,
    input      wbm_ack,


    input      [DATA_WIDTH-1:0] buf_id,
    input      update_buf,
    output     buf_updated
);


    `include "globals.vh"

    localparam ST_IDLE            = 0;
    localparam ST_INIT_COUNTERS   = 1;
    localparam ST_UPDATE_COUNTERS = 2;
    localparam ST_SEND_COLOR      = 3;
    localparam ST_COLOR_SENT      = 4;
    localparam ST_DONE            = 5;

    reg [2:0] state, next_state;

    always @(posedge clk or posedge reset) begin
        if (reset) begin
            state <= ST_IDLE;
        end
        else begin
            state <= next_state;
        end
    end

    always @(*) begin
        next_state = state;
        case (state)
            ST_IDLE: begin
                if (update_buf) next_state = ST_INIT_COUNTERS;
            end
            ST_INIT_COUNTERS: begin
                next_state = ST_SEND_COLOR;
            end
            ST_UPDATE_COUNTERS: begin
                next_state = ST_SEND_COLOR;
            end
            ST_SEND_COLOR: begin
                if (wbm_ack) next_state = ST_COLOR_SENT;
            end
            ST_COLOR_SENT: begin
                next_state = (last_row & last_col) ? ST_DONE : ST_UPDATE_COUNTERS;
            end
            ST_DONE: begin
                next_state = ST_IDLE;
            end
            default: begin
                next_state = ST_IDLE;
            end
        endcase
    end

    assign buf_updated = (state == ST_DONE);


    assign wbm_strobe    = (state == ST_SEND_COLOR);
    assign wbm_cycle     = (state == ST_SEND_COLOR);
    assign wbm_write     = 1;
    assign wbm_writedata = color;
    assign wbm_address   = img_pixel_addr;



    wire [31:0] color = last_col ? 32'b0 : 
       {   8'b0,
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}},
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}},
           5'b0, {3{col_cnt[1] ^ row_cnt[1]}} };


    reg [ADDR_WIDTH-1:0] row_cnt;
    reg [ADDR_WIDTH-1:0] col_cnt;
    reg [ADDR_WIDTH-1:0] img_pixel_addr;

    wire last_row = (row_cnt == `IMG_HEIGHT-1);
    wire last_col = (col_cnt == `IMG_WIDTH-1);

    always @(posedge clk or posedge reset) begin
        if (reset) begin
            row_cnt        <= 0;
            col_cnt        <= 0;
            img_pixel_addr <= 0;
        end
        else if (state == ST_INIT_COUNTERS) begin
            row_cnt        <= 0;
            col_cnt        <= 0;
            img_pixel_addr <= addr_for_buf_id(buf_id);
        end
        else if (state == ST_UPDATE_COUNTERS) begin
            img_pixel_addr <= img_pixel_addr + DATA_WIDTH/8;
            
            if (col_cnt != `IMG_WIDTH-1) begin
                col_cnt    <= col_cnt + 1;
            end
            else begin
                col_cnt    <= 0;
                row_cnt    <= row_cnt + 1;
            end
        end
    end


endmodule