data/full_repos/permissive/478243883/Bitcoin_Wrapper.v
1: b'%Error: data/full_repos/permissive/478243883/Bitcoin_Wrapper.v:120: Cannot find file containing module: \'SHA_256_Top\'\nSHA_256_Top SHA_256_inst(\n^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/478243883,data/full_repos/permissive/478243883/SHA_256_Top\n             data/full_repos/permissive/478243883,data/full_repos/permissive/478243883/SHA_256_Top.v\n             data/full_repos/permissive/478243883,data/full_repos/permissive/478243883/SHA_256_Top.sv\n             SHA_256_Top\n             SHA_256_Top.v\n             SHA_256_Top.sv\n             obj_dir/SHA_256_Top\n             obj_dir/SHA_256_Top.v\n             obj_dir/SHA_256_Top.sv\n%Warning-WIDTH: data/full_repos/permissive/478243883/Bitcoin_Wrapper.v:189: Operator ADD expects 128 bits on the RHS, but RHS\'s VARREF \'nonce\' generates 32 bits.\n                                                                          : ... In instance Bitcoin_Wrapper\n                input_message <= {Block_Header_reg[127:0]+nonce,384\'h800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280};\n                                                         ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/478243883/Bitcoin_Wrapper.v:244: Operator LT expects 24 bits on the LHS, but LHS\'s REPLICATE generates 6 bits.\n                                                                          : ... In instance Bitcoin_Wrapper\n                if ((digest[17:0] == 0) & ({digest[19:18],digest[21:20],digest[23:22]} < 24\'h0a3773))\n                                                                                       ^\n%Error: Exiting due to 1 error(s), 2 warning(s)\n'
module Bitcoin_Wrapper(
    clk,
    Block_Header,
    Block_Header_Valid,

    Golden_Hash,
    Hash_Valid
);








input clk;
input [639:0] Block_Header;
input Block_Header_Valid;



output reg [255:0] Golden_Hash;
output reg Hash_Valid;








reg [639:0] Block_Header_reg; 
reg [255:0] First_Block_Digest;


reg [2:0] Hashing_State;   
reg [31:0] nonce;        
reg Hashing_Loop;








reg ready_to_hash;
reg [511:0] input_message;
reg [255:0] initial_hashes;


wire [255:0] digest;
wire Hashing_Done;


SHA_256_Top SHA_256_inst(
    .ready_to_hash(ready_to_hash),
    .clk(clk),
    .input_message(input_message),
    .initial_hashes(initial_hashes),
    .digest(digest),
    .Hashing_Done(Hashing_Done)
);







always@(posedge clk)
begin



if (Block_Header_Valid == 1)
    begin
    nonce <= 0;
    Hashing_State = 3'd1;
    Block_Header_reg <= Block_Header;
    Hashing_Loop <= 0;

    ready_to_hash <= 0;
    input_message <= 512'b0;
    initial_hashes <= 256'b0;
    end


else 
    begin
    case(Hashing_State)




        3'd0:
            begin
            Hash_Valid      <= 0;            
            ready_to_hash   <= 0; 
            input_message   <= 512'b0;
            initial_hashes  <= 256'b0;
            end



        3'd1:
            begin
            Hash_Valid      <= 0; 
            ready_to_hash   <= 1; 
            input_message   <= Block_Header_reg[639:128];
            initial_hashes  <= 256'h6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19;
            Hashing_State   <= 3'd2;
            end 




        3'd2:
            begin    
            Hash_Valid <= 0;         

            if (Hashing_Done|Hashing_Loop)
                begin
                ready_to_hash <= 1; 
                input_message <= {Block_Header_reg[127:0]+nonce,384'h800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280};
                if (Hashing_Loop)
                    begin
                    Hashing_Loop    <= 0;
                    initial_hashes  <= First_Block_Digest;
                    Hashing_State   <= 3'd2;
                    end
                else
                    begin
                    initial_hashes      <= digest;
                    First_Block_Digest  <= digest;
                    Hashing_State       <= 3'd3;
                    end
                end
            else
                begin
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd2;
                end
            end




        3'd3:
            begin
            Hash_Valid <= 0; 
            if (Hashing_Done == 1)
                begin
                ready_to_hash   <= 1; 
                input_message   <= {digest, 256'h8000000000000000000000000000000000000000000000000000000000000100};
                initial_hashes  <= 256'h6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19;
                Hashing_State   <= 3'd4;
                end
            else
                begin
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd3;
                end
            end






        3'd4:
            begin
            if (Hashing_Done == 1)
                begin

                if ((digest[17:0] == 0) & ({digest[19:18],digest[21:20],digest[23:22]} < 24'h0a3773))
                    begin
                    Hash_Valid      <= 1;                     
                    Golden_Hash     <= digest; 
                    Hashing_State   <= 3'd0;

                    end
                else
                    begin
                    Hash_Valid      <= 0; 
                    ready_to_hash   <= 0; 
                    nonce           <= nonce + 1;
                    Hashing_Loop    <= 1;
                    Hashing_State   <= 3'd2;
                    end
                end
            else
                begin
                Hash_Valid      <= 0; 
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd4;
                end  
            end 

        default: Hashing_State = 3'd0;
    endcase
    end
end



endmodule
module Bitcoin_Wrapper(
    clk,
    Block_Header,
    Block_Header_Valid,

    Golden_Hash,
    Hash_Valid
);









input clk;
input [639:0] Block_Header;
input Block_Header_Valid;



output reg [255:0] Golden_Hash;
output reg Hash_Valid;








reg [639:0] Block_Header_reg; 
reg [255:0] First_Block_Digest;


reg [2:0] Hashing_State;   
reg [31:0] nonce;        
reg Hashing_Loop;








reg ready_to_hash;
reg [511:0] input_message;
reg [255:0] initial_hashes;


wire [255:0] digest;
wire Hashing_Done;


SHA_256_Top SHA_256_inst(
    .ready_to_hash(ready_to_hash),
    .clk(clk),
    .input_message(input_message),
    .initial_hashes(initial_hashes),
    .digest(digest),
    .Hashing_Done(Hashing_Done)
);







always@(posedge clk)
begin



if (Block_Header_Valid == 1)
    begin
    nonce <= 0;
    Hashing_State = 3'd1;
    Block_Header_reg <= Block_Header;
    Hashing_Loop <= 0;

    ready_to_hash <= 0;
    input_message <= 512'b0;
    initial_hashes <= 256'b0;
    end


else 
    begin
    case(Hashing_State)




        3'd0:
            begin
            Hash_Valid      <= 0;            
            ready_to_hash   <= 0; 
            input_message   <= 512'b0;
            initial_hashes  <= 256'b0;
            end



        3'd1:
            begin
            Hash_Valid      <= 0; 
            ready_to_hash   <= 1; 
            input_message   <= Block_Header_reg[639:128];
            initial_hashes  <= 256'h6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19;
            Hashing_State   <= 3'd2;
            end 




        3'd2:
            begin    
            Hash_Valid <= 0;         

            if (Hashing_Done|Hashing_Loop)
                begin
                ready_to_hash <= 1; 
                input_message <= {Block_Header_reg[127:0]+nonce,384'h800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280};
                if (Hashing_Loop)
                    begin
                    Hashing_Loop    <= 0;
                    initial_hashes  <= First_Block_Digest;
                    Hashing_State   <= 3'd2;
                    end
                else
                    begin
                    initial_hashes      <= digest;
                    First_Block_Digest  <= digest;
                    Hashing_State       <= 3'd3;
                    end
                end
            else
                begin
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd2;
                end
            end




        3'd3:
            begin
            Hash_Valid <= 0; 
            if (Hashing_Done == 1)
                begin
                ready_to_hash   <= 1; 
                input_message   <= {digest, 256'h8000000000000000000000000000000000000000000000000000000000000100};
                initial_hashes  <= 256'h6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19;
                Hashing_State   <= 3'd4;
                end
            else
                begin
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd3;
                end
            end






        3'd4:
            begin
            if (Hashing_Done == 1)
                begin

                if ((digest[17:0] == 0) & ({digest[19:18],digest[21:20],digest[23:22]} < 24'h0a3773))
                    begin
                    Hash_Valid      <= 1;                     
                    Golden_Hash     <= digest; 
                    Hashing_State   <= 3'd0;

                    end
                else
                    begin
                    Hash_Valid      <= 0; 
                    ready_to_hash   <= 0; 
                    nonce           <= nonce + 1;
                    Hashing_Loop    <= 1;
                    Hashing_State   <= 3'd2;
                    end
                end
            else
                begin
                Hash_Valid      <= 0; 
                ready_to_hash   <= 0; 
                input_message   <= 512'b0;
                initial_hashes  <= 256'b0;
                Hashing_State   <= 3'd4;
                end  
            end 

        default: Hashing_State = 3'd0;
    endcase
    end
end



endmodule