Skip to content

Commit

Permalink
Update testbench for loading RAM values, change back to use accum_mult
Browse files Browse the repository at this point in the history
multiplier, change generate script to always generate RAM_A_W bits worth
(makes testbench easier), and set default build to jus tbe bls12-381
coprocessor
  • Loading branch information
bsdevlin authored and bsdevlin committed Sep 28, 2019
1 parent 60cee42 commit 7973f4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ip_cores/accum_mult_mod/scripts/generate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ def get_accum_gen():
end_padding = max(start+max_bits-end-start_padding, 0)
coef_l.append('{{{{{}{{1\'d0}}}},mul_grid[{}][{}][{}+:{}],{{{}{{1\'d0}}}}}}'.format(end_padding, j[0], j[1], start-offset, bitwidth, start_padding))



coef.append(coef_l)

# Create compressor trees and output
Expand Down Expand Up @@ -144,6 +142,8 @@ def get_accum_gen():

# Generate the init file lines - need to take into account earlier address bits
max_bits_value = max_bits + ram_bit_low
if (max_bits_value < RAM_A_W):
max_bits_value = RAM_A_W
#print("max_bits {} ram_bit_low {}".format( max_bits, ram_bit_low))
for i in range(1 << max_bits_value):
# The value of a bit here will depend on the GRID and posisition of bit
Expand Down
6 changes: 3 additions & 3 deletions zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ package zcash_fpga_pkg;
parameter FPGA_VERSION = 32'h01_04_02; //v1.4.2

// What features are enabled in this build
parameter bit ENB_VERIFY_SECP256K1_SIG = 1;
parameter bit ENB_VERIFY_EQUIHASH = 1;
parameter bit ENB_VERIFY_SECP256K1_SIG = 0;
parameter bit ENB_VERIFY_EQUIHASH = 0;
parameter bit ENB_BLS12_381 = 1;

localparam [63:0] FPGA_CMD_CAP = {{60'd0},
Expand All @@ -40,7 +40,7 @@ package zcash_fpga_pkg;
(ENB_VERIFY_EQUIHASH && equihash_pkg::N == 144 && equihash_pkg::K == 5), // N = 144, K = 5 for VERIFY_EQUIHASH command
(ENB_VERIFY_EQUIHASH && equihash_pkg::N == 200 && equihash_pkg::K == 9)}; // N = 200, K = 9 for VERIFY_EQUIHASH command

localparam BLS12_381_USE_KARATSUBA = "YES"; // ["YES" | "NO"], defines to use Karatsuba multiplier ("YES"), otherwise accum_mod with RAM reduction
localparam BLS12_381_USE_KARATSUBA = "NO"; // ["YES" | "NO"], defines to use Karatsuba multiplier ("YES"), otherwise accum_mod with RAM reduction

// These are all the command types the FPGA supports
// Reply messages from the FPGA to host all have the last
Expand Down
12 changes: 7 additions & 5 deletions zcash_fpga/src/tb/bls12_381_top_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ task init_ram();
max_rams = i;
break;
end
$fclose(fd);
$fclose(fd);
end

if (max_rams == 99)
Expand All @@ -833,15 +833,17 @@ task init_ram();
for (int i = 0; i < max_rams; i++) begin
fd = $fopen ($sformatf("mod_ram_%0d.mem", i), "r");
curr_line = 0;
eod = $feof(fd);
while((curr_line <= nxt_line) && (eod == 0)) begin

while((curr_line <= nxt_line)) begin
eod = $feof(fd);
if (eod) break;
$fscanf(fd,"%h\n", dat);
curr_line++;
end
dat_flat[i*381 +: 381] = dat;
$fclose(fd);
$fclose(fd);
end

// Now shift in data
for (int j = ((max_rams*381+31)/32); j >= 0; j--) begin
axi_lite_if.poke(.addr(32'h18), .data(dat_flat[j*32 +: 32]));
Expand Down

0 comments on commit 7973f4e

Please sign in to comment.