From 7973f4e2e339991a300032a49183cd02049203d2 Mon Sep 17 00:00:00 2001 From: bsdevlin Date: Sat, 28 Sep 2019 11:36:28 +0800 Subject: [PATCH] Update testbench for loading RAM values, change back to use accum_mult 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 --- ip_cores/accum_mult_mod/scripts/generate_files.py | 4 ++-- zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv | 6 +++--- zcash_fpga/src/tb/bls12_381_top_tb.sv | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ip_cores/accum_mult_mod/scripts/generate_files.py b/ip_cores/accum_mult_mod/scripts/generate_files.py index dc7a617..edc8848 100644 --- a/ip_cores/accum_mult_mod/scripts/generate_files.py +++ b/ip_cores/accum_mult_mod/scripts/generate_files.py @@ -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 @@ -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 diff --git a/zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv b/zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv index 1599108..ba1f7ad 100644 --- a/zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv +++ b/zcash_fpga/src/rtl/top/zcash_fpga_pkg.sv @@ -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}, @@ -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 diff --git a/zcash_fpga/src/tb/bls12_381_top_tb.sv b/zcash_fpga/src/tb/bls12_381_top_tb.sv index ce92fac..c3f634d 100644 --- a/zcash_fpga/src/tb/bls12_381_top_tb.sv +++ b/zcash_fpga/src/tb/bls12_381_top_tb.sv @@ -818,7 +818,7 @@ task init_ram(); max_rams = i; break; end - $fclose(fd); + $fclose(fd); end if (max_rams == 99) @@ -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]));