data/full_repos/permissive/172307681/tb.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/172307681/tb.v:43: Unsupported: Ignoring delay on this delayed statement.\n    #100;\n    ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/172307681/tb.v:47: Unsupported: Ignoring delay on this delayed statement.\n    #100;\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/172307681/tb.v:50: Unsupported: Ignoring delay on this delayed statement.\n    #100;\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/172307681/tb.v:55: Unsupported: Ignoring delay on this delayed statement.\nalways #5 clk = ~clk;\n       ^\n%Warning-WIDTH: data/full_repos/permissive/172307681/tb.v:51: Operator ASSIGN expects 1 bits on the Assign RHS, but Assign RHS\'s CONST \'?32?sh2\' generates 32 or 2 bits.\n                                                            : ... In instance tb\n    ready_to_decod = 2;\n                   ^\n%Error: data/full_repos/permissive/172307681/tb.v:57: Cannot find file containing module: \'bmp_decoder\'\nbmp_decoder bmp_decoder_ins(\n^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/172307681,data/full_repos/permissive/172307681/bmp_decoder\n             data/full_repos/permissive/172307681,data/full_repos/permissive/172307681/bmp_decoder.v\n             data/full_repos/permissive/172307681,data/full_repos/permissive/172307681/bmp_decoder.sv\n             bmp_decoder\n             bmp_decoder.v\n             bmp_decoder.sv\n             obj_dir/bmp_decoder\n             obj_dir/bmp_decoder.v\n             obj_dir/bmp_decoder.sv\n%Error: Exiting due to 1 error(s), 5 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module tb;



parameter buffer_deep = 61926;
parameter h_size = 701;
parameter v_size = 703;

reg [7:0] bmp_buffer [buffer_deep - 1:0];
reg [23:0] buffer     [h_size * v_size - 1: 0];

reg clk;
reg rst_n;

reg       bmp_dataen;
reg [7:0] bmp_data;

reg ready_to_decod;

reg [31:0] cnt;

reg [31:0] cnt1;

wire       decode_val;
wire [23:0] decode_data;

wire [15:0] decode_Xaddress;
wire [15:0] decode_Yaddress;

wire decod_done;

integer i, fp;

initial begin 
    clk = 0;
    rst_n = 0;
    ready_to_decod = 0;

    $readmemh("../b_1bit", bmp_buffer);
    fp=$fopen("../figureRGB3", "w");
    #100;
    
    ready_to_decod = 1;
    
    #100;
    rst_n = 1;

    #100;
    ready_to_decod = 2;

end 

always #5 clk = ~clk;

bmp_decoder bmp_decoder_ins(
   .clk            (clk),
   .rst_n          (rst_n),
   .bmp_dataen     (bmp_dataen),
   .bmp_data       (bmp_data),
   .ready_to_decod (ready_to_decod),
   .decode_val     (decode_val),
   .decode_Xaddress(decode_Xaddress),
   .decode_Yaddress(decode_Yaddress),
   .decode_data    (decode_data),



    
   .decod_done     (decod_done)
);

always @(posedge clk, negedge rst_n) begin 
    if(rst_n == 1'd0) begin 
        cnt1 <= 32'd0;
    end 
    else begin 
        if(decode_val) begin 
            buffer[decode_Yaddress * h_size + decode_Xaddress] <= decode_data;
        end 
        
        if(decod_done) begin 
        

            $fdisplay(fp,"%02h", buffer[cnt1][23:16]);
            $fdisplay(fp,"%02h", buffer[cnt1][15:8]);
            $fdisplay(fp,"%02h", buffer[cnt1][7:0]);
        
            if(cnt1 == (h_size * v_size - 1)) begin 
                $fclose(fp);
                $stop;
            end 
            else begin 
                cnt1 <= cnt1 + 1'd1;
            end
        end 
    end 
end 

always @(posedge clk, negedge rst_n) begin 
    if(rst_n == 1'd0) begin 
        bmp_dataen <= 1'd0;
        bmp_data   <= 8'd0;
        cnt        <= 32'd0;
    end 
    else begin 
        if(cnt == buffer_deep) begin 
            cnt <= cnt;
            bmp_dataen <= 1'd0;
        end 
        else begin 
            bmp_dataen <= 1'd1;
            bmp_data   <= bmp_buffer[cnt];
            cnt        <= cnt + 32'd1;
        end 
    end 
end 

endmodule
module tb;




parameter buffer_deep = 61926;
parameter h_size = 701;
parameter v_size = 703;

reg [7:0] bmp_buffer [buffer_deep - 1:0];
reg [23:0] buffer     [h_size * v_size - 1: 0];

reg clk;
reg rst_n;

reg       bmp_dataen;
reg [7:0] bmp_data;

reg ready_to_decod;

reg [31:0] cnt;

reg [31:0] cnt1;

wire       decode_val;
wire [23:0] decode_data;

wire [15:0] decode_Xaddress;
wire [15:0] decode_Yaddress;

wire decod_done;

integer i, fp;

initial begin 
    clk = 0;
    rst_n = 0;
    ready_to_decod = 0;

    $readmemh("../b_1bit", bmp_buffer);
    fp=$fopen("../figureRGB3", "w");
    #100;
    
    ready_to_decod = 1;
    
    #100;
    rst_n = 1;

    #100;
    ready_to_decod = 2;

end 

always #5 clk = ~clk;

bmp_decoder bmp_decoder_ins(
   .clk            (clk),
   .rst_n          (rst_n),
   .bmp_dataen     (bmp_dataen),
   .bmp_data       (bmp_data),
   .ready_to_decod (ready_to_decod),
   .decode_val     (decode_val),
   .decode_Xaddress(decode_Xaddress),
   .decode_Yaddress(decode_Yaddress),
   .decode_data    (decode_data),



    
   .decod_done     (decod_done)
);

always @(posedge clk, negedge rst_n) begin 
    if(rst_n == 1'd0) begin 
        cnt1 <= 32'd0;
    end 
    else begin 
        if(decode_val) begin 
            buffer[decode_Yaddress * h_size + decode_Xaddress] <= decode_data;
        end 
        
        if(decod_done) begin 
        

            $fdisplay(fp,"%02h", buffer[cnt1][23:16]);
            $fdisplay(fp,"%02h", buffer[cnt1][15:8]);
            $fdisplay(fp,"%02h", buffer[cnt1][7:0]);
        
            if(cnt1 == (h_size * v_size - 1)) begin 
                $fclose(fp);
                $stop;
            end 
            else begin 
                cnt1 <= cnt1 + 1'd1;
            end
        end 
    end 
end 

always @(posedge clk, negedge rst_n) begin 
    if(rst_n == 1'd0) begin 
        bmp_dataen <= 1'd0;
        bmp_data   <= 8'd0;
        cnt        <= 32'd0;
    end 
    else begin 
        if(cnt == buffer_deep) begin 
            cnt <= cnt;
            bmp_dataen <= 1'd0;
        end 
        else begin 
            bmp_dataen <= 1'd1;
            bmp_data   <= bmp_buffer[cnt];
            cnt        <= cnt + 32'd1;
        end 
    end 
end 

endmodule