data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v
1: b'%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:67: Operator ASSIGN expects 32 bits on the Assign RHS, but Assign RHS\'s CONST \'20\'h29d36\' generates 20 bits.\n                                                                                                                                 : ... In instance Psychic5_screensim\n                        BITMAP_LINE_ADDRESS = 20\'h29D36;  \n                                            ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:89: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                 : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:90: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                 : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:91: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                 : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:101: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:102: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:103: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:133: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:134: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Warning-WIDTH: data/full_repos/permissive/521104862/resources/Psychic5_core_ModelSim/Psychic5_videoboard/Psychic5_screensim.v:135: Bit extraction of array[31:0] requires 5 bit index, not 4 bits.\n                                                                                                                                  : ... In instance Psychic5_screensim\n                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18\'h1;\n                                                                            ^\n%Error: Exiting due to 10 warning(s)\n'
module Psychic5_screensim
(
    input   wire            i_EMU_MCLK,
    input   wire            i_EMU_CLK6MPCEN_n,
    input   wire            i_EMU_MRST_n,

    input   wire    [8:0]   i_HCOUNTER,
    input   wire    [8:0]   i_VCOUNTER,
    input   wire    [11:0]  i_VIDEODATA
);




reg     [7:0]   RESNET_CONSTANT[31:0];
reg     [7:0]   BITMAP_HEADER[63:0];
integer         BITMAP_LINE_ADDRESS = 32'h29D36;

reg     [7:0]   BITMAP_FILE_BUFFER[0:172085];

wire    [3:0]   R = i_VIDEODATA[11:8];
wire    [3:0]   G = i_VIDEODATA[7:4];
wire    [3:0]   B = i_VIDEODATA[3:0];

integer         fd;
integer         i;
reg             screen_active = 1'b0;
reg     [17:0]  buffer_pointer = 18'h0;
reg     [15:0]  frame = 16'd0;

initial begin
    $readmemh("screensim/debug_resnet_level.txt", RESNET_CONSTANT);
    $readmemh("screensim/debug_bitmap_header.txt", BITMAP_HEADER);
end

always @(posedge i_EMU_MCLK) begin
    if(i_EMU_MRST_n == 1'b1) begin
        if(!i_EMU_CLK6MPCEN_n) begin
            if(i_VCOUNTER >= 9'd272 && i_VCOUNTER <= 9'd496) begin 
                if(i_VCOUNTER == 9'd272) begin
                    if(i_HCOUNTER == 9'd267) begin
                        BITMAP_LINE_ADDRESS = 20'h29D36;

                        for(i = 0; i < 54; i = i + 1) begin
                            BITMAP_FILE_BUFFER[i] = BITMAP_HEADER[i];
                        end  



                        $display("Start of frame %d", frame);
                    end
                    else if(i_HCOUNTER == 9'd268) begin

                        buffer_pointer = BITMAP_LINE_ADDRESS[17:0];
                    end
                    else if(i_HCOUNTER >= 9'd269) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else begin
                        
                    end
                end

                else if(i_VCOUNTER == 9'd496) begin
                    if(i_HCOUNTER <= 9'd140) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else if(i_HCOUNTER == 9'd141) begin


                    fd = $fopen($sformatf("screensim/p5_frame%0d.bmp", frame), "wb");

                    $display("Frame %d saved", frame);
                    for(i = 0; i < 172086; i = i + 1) begin
                        $fwrite(fd, "%c", BITMAP_FILE_BUFFER[i]);
                    end
                    $fclose(fd);

                    frame = frame + 16'd1;
                    end
                    else begin
                        
                    end
                end

                else begin
                    if(i_HCOUNTER == 9'd141) begin
                        BITMAP_LINE_ADDRESS = BITMAP_LINE_ADDRESS - 32'h300;
                    end
                    else if(i_HCOUNTER == 9'd268) begin

                        buffer_pointer = BITMAP_LINE_ADDRESS[17:0];
                    end
                    else if(i_HCOUNTER >= 9'd269 || i_HCOUNTER <= 9'd140) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else begin
                        
                    end
                end
            end
        end
    end
end


endmodule
module Psychic5_screensim
(
    input   wire            i_EMU_MCLK,
    input   wire            i_EMU_CLK6MPCEN_n,
    input   wire            i_EMU_MRST_n,

    input   wire    [8:0]   i_HCOUNTER,
    input   wire    [8:0]   i_VCOUNTER,
    input   wire    [11:0]  i_VIDEODATA
);





reg     [7:0]   RESNET_CONSTANT[31:0];
reg     [7:0]   BITMAP_HEADER[63:0];
integer         BITMAP_LINE_ADDRESS = 32'h29D36;

reg     [7:0]   BITMAP_FILE_BUFFER[0:172085];

wire    [3:0]   R = i_VIDEODATA[11:8];
wire    [3:0]   G = i_VIDEODATA[7:4];
wire    [3:0]   B = i_VIDEODATA[3:0];

integer         fd;
integer         i;
reg             screen_active = 1'b0;
reg     [17:0]  buffer_pointer = 18'h0;
reg     [15:0]  frame = 16'd0;

initial begin
    $readmemh("screensim/debug_resnet_level.txt", RESNET_CONSTANT);
    $readmemh("screensim/debug_bitmap_header.txt", BITMAP_HEADER);
end

always @(posedge i_EMU_MCLK) begin
    if(i_EMU_MRST_n == 1'b1) begin
        if(!i_EMU_CLK6MPCEN_n) begin
            if(i_VCOUNTER >= 9'd272 && i_VCOUNTER <= 9'd496) begin 
                if(i_VCOUNTER == 9'd272) begin
                    if(i_HCOUNTER == 9'd267) begin
                        BITMAP_LINE_ADDRESS = 20'h29D36;

                        for(i = 0; i < 54; i = i + 1) begin
                            BITMAP_FILE_BUFFER[i] = BITMAP_HEADER[i];
                        end  



                        $display("Start of frame %d", frame);
                    end
                    else if(i_HCOUNTER == 9'd268) begin

                        buffer_pointer = BITMAP_LINE_ADDRESS[17:0];
                    end
                    else if(i_HCOUNTER >= 9'd269) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else begin
                        
                    end
                end

                else if(i_VCOUNTER == 9'd496) begin
                    if(i_HCOUNTER <= 9'd140) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else if(i_HCOUNTER == 9'd141) begin


                    fd = $fopen($sformatf("screensim/p5_frame%0d.bmp", frame), "wb");

                    $display("Frame %d saved", frame);
                    for(i = 0; i < 172086; i = i + 1) begin
                        $fwrite(fd, "%c", BITMAP_FILE_BUFFER[i]);
                    end
                    $fclose(fd);

                    frame = frame + 16'd1;
                    end
                    else begin
                        
                    end
                end

                else begin
                    if(i_HCOUNTER == 9'd141) begin
                        BITMAP_LINE_ADDRESS = BITMAP_LINE_ADDRESS - 32'h300;
                    end
                    else if(i_HCOUNTER == 9'd268) begin

                        buffer_pointer = BITMAP_LINE_ADDRESS[17:0];
                    end
                    else if(i_HCOUNTER >= 9'd269 || i_HCOUNTER <= 9'd140) begin

                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[B]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[G]; buffer_pointer = buffer_pointer + 18'h1;
                        BITMAP_FILE_BUFFER[buffer_pointer] = RESNET_CONSTANT[R]; buffer_pointer = buffer_pointer + 18'h1;
                    end
                    else begin
                        
                    end
                end
            end
        end
    end
end


endmodule