data/full_repos/permissive/126216465/cryptonight.v
 line:1 column:1: Illegal character '\x00'
1: b"%Error: data/full_repos/permissive/126216465/cryptonight.v:130: Cannot find file containing module: 'encstepnew'\nencstepnew encstep_f(.clk(clk), .cxx(cx), .key({{ah0[0+7:0], ah0[0+15:0+8], ah0[0+23:0+16], ah0[0+31:0+24], ah0[0+39:0+32], ah0[0+47:0+40], ah0[0+55:0+48], ah0[0+63:0+56]},{al0[0+7:0], al0[0+15:0+8], al0[0+23:0+16], al0[0+31:0+24], al0[0+39:0+32], al0[0+47:0+40], al0[0+55:0+48], al0[0+63:0+56]}}), .enc(cxenc));\n^~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/126216465,data/full_repos/permissive/126216465/encstepnew\n             data/full_repos/permissive/126216465,data/full_repos/permissive/126216465/encstepnew.v\n             data/full_repos/permissive/126216465,data/full_repos/permissive/126216465/encstepnew.sv\n             encstepnew\n             encstepnew.v\n             encstepnew.sv\n             obj_dir/encstepnew\n             obj_dir/encstepnew.v\n             obj_dir/encstepnew.sv\n%Error: data/full_repos/permissive/126216465/cryptonight.v:133: Cannot find file containing module: 'gen_big_buffer'\ngen_big_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) big0\n^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/126216465/cryptonight.v:140: Cannot find file containing module: 'gen_small_buffer'\ngen_small_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) small0\n^~~~~~~~~~~~~~~~\n%Error: Exiting due to 3 error(s)\n"
module cryptonight#
  (
        parameter RAM_DEPTH = 64
  )
  (input clk, input rstn, input [1535:0] start_short_hash, output reg done, output reg [31:0] gen_big_buffer_counter, 
  output reg [31:0] shuffle_counter, output reg [31:0] small_buffer_counter, output [1023:0] newhash);


localparam MMASK = RAM_DEPTH * 16 - 16;
localparam NUM_GEN_ROUNDS = RAM_DEPTH/8;
localparam enc_rounds = RAM_DEPTH*4;

reg [63:0] ah0;
reg [63:0] al0;
reg [127:0] bx0;
wire [127:0] mx;
reg [127:0] cx;
wire [127:0] cxenc;
reg [127:0] old;
reg [63:0] idx0;


reg [127:0] wr;
reg [127:0] wr2;
reg [63:0] ma;
reg [31:0] idx1;
reg [31:0] idx2;
reg [4:0] counter;
reg [31:0] block_counter;
reg start_shuffle_flag;
reg shuffle_done_flag;
reg [31:0] start_mem_offset;
reg gen_buf_write_done;
wire [3:0] gen_buf_write_flag;
wire gen_buf_ready;
wire [31:0] gen_buf_mem_offset;
wire [31:0] small_buf_mem_offset;
wire [127:0] gen0, gen1, gen2, gen3, gen4, gen5, gen6, gen7;
reg [127:0] mem0, mem1, mem2, mem3, mem4, mem5, mem6, mem7;
reg buf_read_done;
wire buf_read_start;
wire small_buf_ready;



reg [127:0] my_memory [RAM_DEPTH-1:0];


  function integer clogb2;
    input integer depth;
      for (clogb2=0; depth>0; clogb2=clogb2+1)
        depth = depth >> 1;
  endfunction
  

initial begin
  counter <= 0;
  block_counter <= 0;
  start_shuffle_flag <= 0;
  start_mem_offset <= 0;
  gen_buf_write_done <= 0;
  gen_big_buffer_counter <= 0;
  small_buffer_counter <= 0;
  shuffle_counter <= 0;
  buf_read_done <= 0;
  done <= 0;
  old <= 0;
  idx0 <= 0;
  shuffle_done_flag <= 0;

  $display("RAM_DEPTH 0x%H", RAM_DEPTH);
  $display("MMASK 0x%H", MMASK);
  $display("NUM_GEN_ROUNDS 0x%H", NUM_GEN_ROUNDS);
  $display("enc_rounds 0x%H", enc_rounds);
end


encstepnew encstep_f(.clk(clk), .cxx(cx), .key({`rev64(ah0,0),`rev64(al0,0)}), .enc(cxenc));


gen_big_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) big0
 (.clk(clk), .rstn(rstn), .start_mem_offset(start_mem_offset), .write_done(gen_buf_write_done), 
  .hs1(start_short_hash[255:0]), .hs3(start_short_hash[1535:512]),
  .start_write(gen_buf_write_flag), .mem_offset(gen_buf_mem_offset), .buf_done(gen_buf_ready),
  .gen0(gen0), .gen1(gen1), .gen2(gen2), .gen3(gen3), .gen4(gen4), .gen5(gen5), .gen6(gen6), .gen7(gen7));


gen_small_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) small0
 (.clk(clk), .rstn(rstn), .start_mem_offset(start_mem_offset), .prev_buf_done(shuffle_done_flag), .read_done(buf_read_done),
  .hs2(start_short_hash[511:256]), .hs3(start_short_hash[1535:512]),
  .mem0(mem0), .mem1(mem1), .mem2(mem2), .mem3(mem3), .mem4(mem4), .mem5(mem5), .mem6(mem6), .mem7(mem7),
  .start_read(buf_read_start), .mem_offset(small_buf_mem_offset), .buf_done(small_buf_ready), .newhash(newhash) );

mult_gen_0 mul128bit0 (
  .CLK(clk),
  .A(idx0),
  .B(`rev64(old,64)),
  .P(mx)
);

always @(posedge clk) begin
  if (rstn == 0)
  begin
    gen_big_buffer_counter <= 0;
  end
  else if (gen_buf_ready == 0)
  begin
    gen_big_buffer_counter <= gen_big_buffer_counter + 1;
  end
end
        
  
always @(posedge clk) begin
  if (rstn == 0)
  begin
    shuffle_done_flag <= 0;
    start_shuffle_flag <= 0;

    shuffle_counter <= 0;
    counter <= 0;
    gen_buf_write_done <= 0;
  end

  else if (gen_buf_ready && start_shuffle_flag == 0)
  begin
      $display("first buffer ready");
      $display(gen_big_buffer_counter);
      start_shuffle_flag <= 1;
      counter <= 1;
  end



  else if (gen_buf_ready == 0 && gen_buf_write_flag == 0 && gen_buf_write_done == 1)
  begin
    gen_buf_write_done <= 0;
  end
  else if ((start_shuffle_flag && block_counter < enc_rounds) ||
           (gen_buf_ready == 0 && gen_buf_write_flag > 0) )
  begin
    case(counter)
      0:begin
        case (gen_buf_write_flag)
        1:begin
          my_memory[(gen_buf_mem_offset>>4)+0] <= gen0;
          gen_buf_write_done <= 0;

          end
        2:begin
          my_memory[(gen_buf_mem_offset>>4)+1] <= gen1;

          end
        3:begin
          my_memory[(gen_buf_mem_offset>>4)+2] <= gen2;
          end
        4:begin
          my_memory[(gen_buf_mem_offset>>4)+3] <= gen3;
          end
        5:begin
          my_memory[(gen_buf_mem_offset>>4)+4] <= gen4;
          end
        6:begin
          my_memory[(gen_buf_mem_offset>>4)+5] <= gen5;
          end
        7:begin
          my_memory[(gen_buf_mem_offset>>4)+6] <= gen6;
          end
        8:begin
          my_memory[(gen_buf_mem_offset>>4)+7] <= gen7;
          gen_buf_write_done <= 1;
          end
        endcase


      end
      1:begin


        ah0 <= `rev64(start_short_hash,1*64) ^ `rev64(start_short_hash,5*64);
        al0 <= `rev64(start_short_hash,0) ^ `rev64(start_short_hash,4*64);
        bx0 <= {`h64(start_short_hash,3) ^ `h64(start_short_hash,7), `h64(start_short_hash,2) ^ `h64(start_short_hash,6)};
        idx1 <= ((`rev32(start_short_hash,96) ^ `rev32(start_short_hash,352)) & MMASK) >> 4;

        cx <= my_memory[((`rev32(start_short_hash,96) ^ `rev32(start_short_hash,352)) & MMASK) >> 4];
        counter <= 2;
        old <= 0;
        idx0 <= 0;
        shuffle_counter <= shuffle_counter + 1;
        end
      2:begin




        wr <= bx0 ^ cxenc;
        my_memory[idx1] <= bx0 ^ cxenc;
        $display("XXX %d [%d] %H => %H", block_counter, idx1, cx, (bx0 ^ cxenc)); 
        bx0 <= cxenc;


        idx1 <= (`rev32(cxenc,96) & MMASK) >> 4;

        counter <= 3;
        shuffle_counter <= shuffle_counter + 1;
        end

      3:begin

        old <= my_memory[idx1];
        idx0 <= `rev64(cxenc,64);

        counter <= 4;
        shuffle_counter <= shuffle_counter + 1;
        end
      4:begin

        counter <= 5;
        shuffle_counter <= shuffle_counter + 1;
        end
      5:begin
        ma <= `rev64(old,64);


        ah0 <= ah0 + mx[127:64];
        al0 <= al0 + mx[63:0];
        wr <= {al0 + mx[63:0],ah0 + mx[127:64]};
        wr2 <= { `rev64_op($unsigned(ah0 + mx[127:64])), `rev64_op($unsigned(al0 + mx[63:0]))} ;
        my_memory[idx1] <= {`rev64_op((ah0 + mx[127:64])), `rev64_op((al0 + mx[63:0]))};
        $display("YYY %d [%d] %H => %H", block_counter, idx1, old, ({ `rev64_op((ah0 + mx[127:64])), `rev64_op((al0 + mx[63:0]))}));

        counter <= 6;
        shuffle_counter <= shuffle_counter + 1;
        end
      6:begin
        idx1 <= ((ah0[31:0] ^ `rev32(old,96)) & MMASK) >> 4;
        ah0 <= ah0 ^ `rev64(old,64);
        al0 <= al0 ^ `rev64(old,0);
        cx <= my_memory[((ah0[31:0] ^ `rev32(old,96)) & MMASK) >> 4];
        counter <= 2;
        old <= 0;
        idx0 <= 0;
        shuffle_counter <= shuffle_counter + 1;
        block_counter <= block_counter + 1;
        end
    endcase
  end
  else if (shuffle_done_flag == 0 && start_shuffle_flag && block_counter == enc_rounds)
  begin
        shuffle_done_flag <= 1;

        counter <= 0;
        $display("shuffle buffer ready");
        $display(shuffle_counter);
  end



  else if (shuffle_done_flag && small_buf_ready == 0)
  begin
    if (buf_read_start)
    begin
        small_buffer_counter <= small_buffer_counter + 1;
          mem0 <= my_memory[(small_buf_mem_offset>>4)+0];
          mem1 <= my_memory[(small_buf_mem_offset>>4)+1];
          mem2 <= my_memory[(small_buf_mem_offset>>4)+2];
          mem3 <= my_memory[(small_buf_mem_offset>>4)+3];
          mem4 <= my_memory[(small_buf_mem_offset>>4)+4];
          mem5 <= my_memory[(small_buf_mem_offset>>4)+5];
          mem6 <= my_memory[(small_buf_mem_offset>>4)+6];
          mem7 <= my_memory[(small_buf_mem_offset>>4)+7];
        buf_read_done <= 1;
        small_buffer_counter <= small_buffer_counter + 1;
    end
    else begin
        buf_read_done <= 0;
        small_buffer_counter <= small_buffer_counter + 1;
    end
  end
  else if (small_buf_ready && done == 0)
  begin

    $display("small buffer ready");
    $display(small_buffer_counter);
    done <= 1;
  end
end

endmodule
module cryptonight#
  (
        parameter RAM_DEPTH = 64
  )
  (input clk, input rstn, input [1535:0] start_short_hash, output reg done, output reg [31:0] gen_big_buffer_counter, 
  output reg [31:0] shuffle_counter, output reg [31:0] small_buffer_counter, output [1023:0] newhash);



localparam MMASK = RAM_DEPTH * 16 - 16;
localparam NUM_GEN_ROUNDS = RAM_DEPTH/8;
localparam enc_rounds = RAM_DEPTH*4;

reg [63:0] ah0;
reg [63:0] al0;
reg [127:0] bx0;
wire [127:0] mx;
reg [127:0] cx;
wire [127:0] cxenc;
reg [127:0] old;
reg [63:0] idx0;


reg [127:0] wr;
reg [127:0] wr2;
reg [63:0] ma;
reg [31:0] idx1;
reg [31:0] idx2;
reg [4:0] counter;
reg [31:0] block_counter;
reg start_shuffle_flag;
reg shuffle_done_flag;
reg [31:0] start_mem_offset;
reg gen_buf_write_done;
wire [3:0] gen_buf_write_flag;
wire gen_buf_ready;
wire [31:0] gen_buf_mem_offset;
wire [31:0] small_buf_mem_offset;
wire [127:0] gen0, gen1, gen2, gen3, gen4, gen5, gen6, gen7;
reg [127:0] mem0, mem1, mem2, mem3, mem4, mem5, mem6, mem7;
reg buf_read_done;
wire buf_read_start;
wire small_buf_ready;



reg [127:0] my_memory [RAM_DEPTH-1:0];


  function integer clogb2;
    input integer depth;
      for (clogb2=0; depth>0; clogb2=clogb2+1)
        depth = depth >> 1;
  endfunction
  

initial begin
  counter <= 0;
  block_counter <= 0;
  start_shuffle_flag <= 0;
  start_mem_offset <= 0;
  gen_buf_write_done <= 0;
  gen_big_buffer_counter <= 0;
  small_buffer_counter <= 0;
  shuffle_counter <= 0;
  buf_read_done <= 0;
  done <= 0;
  old <= 0;
  idx0 <= 0;
  shuffle_done_flag <= 0;

  $display("RAM_DEPTH 0x%H", RAM_DEPTH);
  $display("MMASK 0x%H", MMASK);
  $display("NUM_GEN_ROUNDS 0x%H", NUM_GEN_ROUNDS);
  $display("enc_rounds 0x%H", enc_rounds);
end


encstepnew encstep_f(.clk(clk), .cxx(cx), .key({`rev64(ah0,0),`rev64(al0,0)}), .enc(cxenc));


gen_big_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) big0
 (.clk(clk), .rstn(rstn), .start_mem_offset(start_mem_offset), .write_done(gen_buf_write_done), 
  .hs1(start_short_hash[255:0]), .hs3(start_short_hash[1535:512]),
  .start_write(gen_buf_write_flag), .mem_offset(gen_buf_mem_offset), .buf_done(gen_buf_ready),
  .gen0(gen0), .gen1(gen1), .gen2(gen2), .gen3(gen3), .gen4(gen4), .gen5(gen5), .gen6(gen6), .gen7(gen7));


gen_small_buffer #(.NUM_ROUNDS(NUM_GEN_ROUNDS)) small0
 (.clk(clk), .rstn(rstn), .start_mem_offset(start_mem_offset), .prev_buf_done(shuffle_done_flag), .read_done(buf_read_done),
  .hs2(start_short_hash[511:256]), .hs3(start_short_hash[1535:512]),
  .mem0(mem0), .mem1(mem1), .mem2(mem2), .mem3(mem3), .mem4(mem4), .mem5(mem5), .mem6(mem6), .mem7(mem7),
  .start_read(buf_read_start), .mem_offset(small_buf_mem_offset), .buf_done(small_buf_ready), .newhash(newhash) );

mult_gen_0 mul128bit0 (
  .CLK(clk),
  .A(idx0),
  .B(`rev64(old,64)),
  .P(mx)
);

always @(posedge clk) begin
  if (rstn == 0)
  begin
    gen_big_buffer_counter <= 0;
  end
  else if (gen_buf_ready == 0)
  begin
    gen_big_buffer_counter <= gen_big_buffer_counter + 1;
  end
end
        
  
always @(posedge clk) begin
  if (rstn == 0)
  begin
    shuffle_done_flag <= 0;
    start_shuffle_flag <= 0;

    shuffle_counter <= 0;
    counter <= 0;
    gen_buf_write_done <= 0;
  end

  else if (gen_buf_ready && start_shuffle_flag == 0)
  begin
      $display("first buffer ready");
      $display(gen_big_buffer_counter);
      start_shuffle_flag <= 1;
      counter <= 1;
  end



  else if (gen_buf_ready == 0 && gen_buf_write_flag == 0 && gen_buf_write_done == 1)
  begin
    gen_buf_write_done <= 0;
  end
  else if ((start_shuffle_flag && block_counter < enc_rounds) ||
           (gen_buf_ready == 0 && gen_buf_write_flag > 0) )
  begin
    case(counter)
      0:begin
        case (gen_buf_write_flag)
        1:begin
          my_memory[(gen_buf_mem_offset>>4)+0] <= gen0;
          gen_buf_write_done <= 0;

          end
        2:begin
          my_memory[(gen_buf_mem_offset>>4)+1] <= gen1;

          end
        3:begin
          my_memory[(gen_buf_mem_offset>>4)+2] <= gen2;
          end
        4:begin
          my_memory[(gen_buf_mem_offset>>4)+3] <= gen3;
          end
        5:begin
          my_memory[(gen_buf_mem_offset>>4)+4] <= gen4;
          end
        6:begin
          my_memory[(gen_buf_mem_offset>>4)+5] <= gen5;
          end
        7:begin
          my_memory[(gen_buf_mem_offset>>4)+6] <= gen6;
          end
        8:begin
          my_memory[(gen_buf_mem_offset>>4)+7] <= gen7;
          gen_buf_write_done <= 1;
          end
        endcase


      end
      1:begin


        ah0 <= `rev64(start_short_hash,1*64) ^ `rev64(start_short_hash,5*64);
        al0 <= `rev64(start_short_hash,0) ^ `rev64(start_short_hash,4*64);
        bx0 <= {`h64(start_short_hash,3) ^ `h64(start_short_hash,7), `h64(start_short_hash,2) ^ `h64(start_short_hash,6)};
        idx1 <= ((`rev32(start_short_hash,96) ^ `rev32(start_short_hash,352)) & MMASK) >> 4;

        cx <= my_memory[((`rev32(start_short_hash,96) ^ `rev32(start_short_hash,352)) & MMASK) >> 4];
        counter <= 2;
        old <= 0;
        idx0 <= 0;
        shuffle_counter <= shuffle_counter + 1;
        end
      2:begin




        wr <= bx0 ^ cxenc;
        my_memory[idx1] <= bx0 ^ cxenc;
        $display("XXX %d [%d] %H => %H", block_counter, idx1, cx, (bx0 ^ cxenc)); 
        bx0 <= cxenc;


        idx1 <= (`rev32(cxenc,96) & MMASK) >> 4;

        counter <= 3;
        shuffle_counter <= shuffle_counter + 1;
        end

      3:begin

        old <= my_memory[idx1];
        idx0 <= `rev64(cxenc,64);

        counter <= 4;
        shuffle_counter <= shuffle_counter + 1;
        end
      4:begin

        counter <= 5;
        shuffle_counter <= shuffle_counter + 1;
        end
      5:begin
        ma <= `rev64(old,64);


        ah0 <= ah0 + mx[127:64];
        al0 <= al0 + mx[63:0];
        wr <= {al0 + mx[63:0],ah0 + mx[127:64]};
        wr2 <= { `rev64_op($unsigned(ah0 + mx[127:64])), `rev64_op($unsigned(al0 + mx[63:0]))} ;
        my_memory[idx1] <= {`rev64_op((ah0 + mx[127:64])), `rev64_op((al0 + mx[63:0]))};
        $display("YYY %d [%d] %H => %H", block_counter, idx1, old, ({ `rev64_op((ah0 + mx[127:64])), `rev64_op((al0 + mx[63:0]))}));

        counter <= 6;
        shuffle_counter <= shuffle_counter + 1;
        end
      6:begin
        idx1 <= ((ah0[31:0] ^ `rev32(old,96)) & MMASK) >> 4;
        ah0 <= ah0 ^ `rev64(old,64);
        al0 <= al0 ^ `rev64(old,0);
        cx <= my_memory[((ah0[31:0] ^ `rev32(old,96)) & MMASK) >> 4];
        counter <= 2;
        old <= 0;
        idx0 <= 0;
        shuffle_counter <= shuffle_counter + 1;
        block_counter <= block_counter + 1;
        end
    endcase
  end
  else if (shuffle_done_flag == 0 && start_shuffle_flag && block_counter == enc_rounds)
  begin
        shuffle_done_flag <= 1;

        counter <= 0;
        $display("shuffle buffer ready");
        $display(shuffle_counter);
  end



  else if (shuffle_done_flag && small_buf_ready == 0)
  begin
    if (buf_read_start)
    begin
        small_buffer_counter <= small_buffer_counter + 1;
          mem0 <= my_memory[(small_buf_mem_offset>>4)+0];
          mem1 <= my_memory[(small_buf_mem_offset>>4)+1];
          mem2 <= my_memory[(small_buf_mem_offset>>4)+2];
          mem3 <= my_memory[(small_buf_mem_offset>>4)+3];
          mem4 <= my_memory[(small_buf_mem_offset>>4)+4];
          mem5 <= my_memory[(small_buf_mem_offset>>4)+5];
          mem6 <= my_memory[(small_buf_mem_offset>>4)+6];
          mem7 <= my_memory[(small_buf_mem_offset>>4)+7];
        buf_read_done <= 1;
        small_buffer_counter <= small_buffer_counter + 1;
    end
    else begin
        buf_read_done <= 0;
        small_buffer_counter <= small_buffer_counter + 1;
    end
  end
  else if (small_buf_ready && done == 0)
  begin

    $display("small buffer ready");
    $display(small_buffer_counter);
    done <= 1;
  end
end

endmodule