[Cryptech-Commits] [core/math/modexpng] branch master updated: Increase NUM_MULTS to 32.
git at cryptech.is
git at cryptech.is
Mon Mar 16 18:05:48 UTC 2020
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch master
in repository core/math/modexpng.
The following commit(s) were added to refs/heads/master by this push:
new 62495c5 Increase NUM_MULTS to 32.
62495c5 is described below
commit 62495c597ca8b60f733682661afdad9e0d3e0e2d
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Mon Mar 16 13:58:08 2020 -0400
Increase NUM_MULTS to 32.
This required finding and fixing every function that had a baked-in
assumption that NUM_MULTS=8.
---
rtl/modexpng_mmm_dual.v | 30 +++--------------
rtl/modexpng_parameters_x8.vh | 2 +-
rtl/modexpng_recombinator_block.v | 68 +++++++--------------------------------
3 files changed, 17 insertions(+), 83 deletions(-)
diff --git a/rtl/modexpng_mmm_dual.v b/rtl/modexpng_mmm_dual.v
index 9346a42..fd39943 100644
--- a/rtl/modexpng_mmm_dual.v
+++ b/rtl/modexpng_mmm_dual.v
@@ -829,18 +829,8 @@ module modexpng_mmm_dual
input [NUM_MULTS_HALF_AUX-1:0] col_index_value;
input [OP_ADDR_W -1:0] narrow_xy_addr_value;
//
- if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value)
- case (narrow_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_mac_mode_z_square = {1'b1, 8'b11111110};
- 3'b001: calc_mac_mode_z_square = {1'b1, 8'b11111101};
- 3'b010: calc_mac_mode_z_square = {1'b1, 8'b11111011};
- 3'b011: calc_mac_mode_z_square = {1'b1, 8'b11110111};
- 3'b100: calc_mac_mode_z_square = {1'b1, 8'b11101111};
- 3'b101: calc_mac_mode_z_square = {1'b1, 8'b11011111};
- 3'b110: calc_mac_mode_z_square = {1'b1, 8'b10111111};
- 3'b111: calc_mac_mode_z_square = {1'b1, 8'b01111111};
- endcase
- else calc_mac_mode_z_square = {1'b1, 8'b11111111};
+ if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) calc_mac_mode_z_square = ~({{NUM_MULTS_AUX-1{1'b0}}, 1'b1} << narrow_xy_addr_value[MAC_INDEX_W-1:0]);
+ else calc_mac_mode_z_square = {NUM_MULTS_AUX{1'b1}};
endfunction
function [NUM_MULTS_AUX -1:0] calc_mac_mode_z_rectangle;
@@ -848,20 +838,8 @@ module modexpng_mmm_dual
input [NUM_MULTS_HALF_AUX -1:0] col_index_value;
input [OP_ADDR_W -1:0] narrow_xy_addr_value;
//
- begin
- if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value)
- case (narrow_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_mac_mode_z_rectangle = {1'b1, 8'b11111110};
- 3'b001: calc_mac_mode_z_rectangle = {1'b1, 8'b11111101};
- 3'b010: calc_mac_mode_z_rectangle = {1'b1, 8'b11111011};
- 3'b011: calc_mac_mode_z_rectangle = {1'b1, 8'b11110111};
- 3'b100: calc_mac_mode_z_rectangle = {1'b1, 8'b11101111};
- 3'b101: calc_mac_mode_z_rectangle = {1'b1, 8'b11011111};
- 3'b110: calc_mac_mode_z_rectangle = {1'b1, 8'b10111111};
- 3'b111: calc_mac_mode_z_rectangle = {1'b1, 8'b01111111};
- endcase
- else calc_mac_mode_z_rectangle = {1'b1, 8'b11111111};
- end
+ if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) calc_mac_mode_z_rectangle = ~({{NUM_MULTS_AUX-1{1'b0}}, 1'b1} << narrow_xy_addr_value[MAC_INDEX_W-1:0]);
+ else calc_mac_mode_z_rectangle = {NUM_MULTS_AUX{1'b1}};
endfunction
always @(posedge clk)
diff --git a/rtl/modexpng_parameters_x8.vh b/rtl/modexpng_parameters_x8.vh
index 2822d0a..f1d6395 100644
--- a/rtl/modexpng_parameters_x8.vh
+++ b/rtl/modexpng_parameters_x8.vh
@@ -31,7 +31,7 @@
//
//======================================================================
-localparam NUM_MULTS = 8;
+localparam NUM_MULTS = 32;
localparam NUM_MULTS_AUX = NUM_MULTS + 1;
localparam NUM_MULTS_HALF = NUM_MULTS / 2;
localparam NUM_MULTS_HALF_AUX = NUM_MULTS_HALF + 1;
diff --git a/rtl/modexpng_recombinator_block.v b/rtl/modexpng_recombinator_block.v
index ba440b0..ccd04ac 100644
--- a/rtl/modexpng_recombinator_block.v
+++ b/rtl/modexpng_recombinator_block.v
@@ -260,28 +260,14 @@ module modexpng_recombinator_block
//
endfunction
- //
- // TODO: This will need some generic replacement defined in modexpng_parameters.vh
- // in case anything different from NUM_MULTS = 8 is used.
- //
function [ NUM_MULTS -1:0] calc_square_triangle_bitmap_lsb;
input [COL_INDEX_W -1:0] col_index_value;
input [COL_INDEX_W -1:0] col_index_last_value;
input [BANK_ADDR_W -1:0] narrow_xy_bank_value;
input [ OP_ADDR_W -1:0] narrow_xy_addr_value;
//
- if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value)
- case (narrow_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_square_triangle_bitmap_lsb = 8'b00000001;
- 3'b001: calc_square_triangle_bitmap_lsb = 8'b00000010;
- 3'b010: calc_square_triangle_bitmap_lsb = 8'b00000100;
- 3'b011: calc_square_triangle_bitmap_lsb = 8'b00001000;
- 3'b100: calc_square_triangle_bitmap_lsb = 8'b00010000;
- 3'b101: calc_square_triangle_bitmap_lsb = 8'b00100000;
- 3'b110: calc_square_triangle_bitmap_lsb = 8'b01000000;
- 3'b111: calc_square_triangle_bitmap_lsb = 8'b10000000;
- endcase
- else calc_square_triangle_bitmap_lsb = 8'b00000000;
+ if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) calc_square_triangle_bitmap_lsb = {{NUM_MULTS-1{1'b0}}, 1'b1} << narrow_xy_addr_value[MAC_INDEX_W-1:0];
+ else calc_square_triangle_bitmap_lsb = {NUM_MULTS{1'b0}};
//
endfunction
@@ -307,18 +293,8 @@ module modexpng_recombinator_block
input [BANK_ADDR_W -1:0] narrow_xy_bank_value;
input [ OP_ADDR_W -1:0] narrow_xy_addr_value;
//
- if ((narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) && (narrow_xy_bank_value != BANK_NARROW_EXT))
- case (narrow_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_rectangle_bitmap_lsb = 8'b00000001;
- 3'b001: calc_rectangle_bitmap_lsb = 8'b00000010;
- 3'b010: calc_rectangle_bitmap_lsb = 8'b00000100;
- 3'b011: calc_rectangle_bitmap_lsb = 8'b00001000;
- 3'b100: calc_rectangle_bitmap_lsb = 8'b00010000;
- 3'b101: calc_rectangle_bitmap_lsb = 8'b00100000;
- 3'b110: calc_rectangle_bitmap_lsb = 8'b01000000;
- 3'b111: calc_rectangle_bitmap_lsb = 8'b10000000;
- endcase
- else calc_rectangle_bitmap_lsb = 8'b00000000;
+ if ((narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) && (narrow_xy_bank_value != BANK_NARROW_EXT)) calc_rectangle_bitmap_lsb = {{NUM_MULTS-1{1'b0}}, 1'b1} << narrow_xy_addr_value[MAC_INDEX_W-1:0];
+ else calc_rectangle_bitmap_lsb = {NUM_MULTS{1'b0}};
//
endfunction
@@ -335,18 +311,8 @@ module modexpng_recombinator_block
input [BANK_ADDR_W -1:0] narrow_xy_bank_value;
input [ OP_ADDR_W -1:0] narrow_xy_addr_value;
//
- if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value)
- case (narrow_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_square_triangle_index_lsb = 3'd0;
- 3'b001: calc_square_triangle_index_lsb = 3'd1;
- 3'b010: calc_square_triangle_index_lsb = 3'd2;
- 3'b011: calc_square_triangle_index_lsb = 3'd3;
- 3'b100: calc_square_triangle_index_lsb = 3'd4;
- 3'b101: calc_square_triangle_index_lsb = 3'd5;
- 3'b110: calc_square_triangle_index_lsb = 3'd6;
- 3'b111: calc_square_triangle_index_lsb = 3'd7;
- endcase
- else calc_square_triangle_index_lsb = 3'dX;
+ if (narrow_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) calc_square_triangle_index_lsb = narrow_xy_addr_value[MAC_INDEX_W-1:0];
+ else calc_square_triangle_index_lsb = {MAC_INDEX_W{1'bX}};
//
endfunction
@@ -372,18 +338,8 @@ module modexpng_recombinator_block
input [BANK_ADDR_W -1:0] slim_bram_xy_bank_value;
input [ OP_ADDR_W -1:0] slim_bram_xy_addr_value;
//
- if ((slim_bram_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) && (slim_bram_xy_bank_value != BANK_NARROW_EXT))
- case (slim_bram_xy_addr_value[MAC_INDEX_W-1:0])
- 3'b000: calc_rectangle_index_lsb = 3'd0;
- 3'b001: calc_rectangle_index_lsb = 3'd1;
- 3'b010: calc_rectangle_index_lsb = 3'd2;
- 3'b011: calc_rectangle_index_lsb = 3'd3;
- 3'b100: calc_rectangle_index_lsb = 3'd4;
- 3'b101: calc_rectangle_index_lsb = 3'd5;
- 3'b110: calc_rectangle_index_lsb = 3'd6;
- 3'b111: calc_rectangle_index_lsb = 3'd7;
- endcase
- else calc_rectangle_index_lsb = 3'dX;
+ if ((slim_bram_xy_addr_value[OP_ADDR_W-1:MAC_INDEX_W] == col_index_value) && (slim_bram_xy_bank_value != BANK_NARROW_EXT)) calc_rectangle_index_lsb = slim_bram_xy_addr_value[MAC_INDEX_W-1:0];
+ else calc_rectangle_index_lsb = {MAC_INDEX_W{1'bX}};
//
endfunction
@@ -445,8 +401,8 @@ module modexpng_recombinator_block
input [ OP_ADDR_W -1:0] narrow_xy_addr_value;
input [ OP_ADDR_W -1:0] index_last_value;
//
- if (narrow_xy_addr_value == index_last_value) calc_square_bitmap_msb = {col_index_value != col_index_last_value, 7'b1111111};
- else calc_square_bitmap_msb = 8'b00000000;
+ if (narrow_xy_addr_value == index_last_value) calc_square_bitmap_msb = {col_index_value != col_index_last_value, {NUM_MULTS-1{1'b1}}};
+ else calc_square_bitmap_msb = {NUM_MULTS{1'b0}};
//
endfunction
@@ -457,8 +413,8 @@ module modexpng_recombinator_block
input [ OP_ADDR_W -1:0] narrow_xy_addr_value;
input [ OP_ADDR_W -1:0] index_last_value;
//
- if ((narrow_xy_addr_value == OP_ADDR_ONE) && (narrow_xy_bank_value == BANK_NARROW_EXT)) calc_rectangle_bitmap_msb = 8'b11111111;
- else calc_rectangle_bitmap_msb = 8'b00000000;
+ if ((narrow_xy_addr_value == OP_ADDR_ONE) && (narrow_xy_bank_value == BANK_NARROW_EXT)) calc_rectangle_bitmap_msb = {NUM_MULTS{1'b1}};
+ else calc_rectangle_bitmap_msb = {NUM_MULTS{1'b0}};
//
endfunction
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list