[Cryptech-Commits] [core/math/modexp] 01/01: Fused the s_mem init loop into the adder loop.
git at cryptech.is
git at cryptech.is
Wed Jun 24 17:47:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
joachim at secworks.se pushed a commit to branch perfopt
in repository core/math/modexp.
commit d5115d8547df48e33af778eadc7cdaa07fddeb7e
Author: Joachim Strömbergson <joachim at secworks.se>
Date: Wed Jun 24 19:47:45 2015 +0200
Fused the s_mem init loop into the adder loop.
---
src/rtl/montprod.v | 49 ++++++++++++++-----------------------------------
src/tb/tb_montprod.v | 2 --
2 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/src/rtl/montprod.v b/src/rtl/montprod.v
index ccf8341..189bb18 100644
--- a/src/rtl/montprod.v
+++ b/src/rtl/montprod.v
@@ -68,16 +68,14 @@ module montprod #(parameter OPW = 32, parameter ADW = 8)
// Internal constant and parameter definitions.
//----------------------------------------------------------------
localparam CTRL_IDLE = 4'h0;
- localparam CTRL_INIT_S = 4'h1;
- localparam CTRL_WAIT = 4'h2;
- localparam CTRL_LOOP_ITER = 4'h3;
- localparam CTRL_LOOP_BQ = 4'h4;
- localparam CTRL_CALC_ADD = 4'h5;
- localparam CTRL_STALLPIPE_ADD = 4'h6;
- localparam CTRL_CALC_SDIV2 = 4'h7;
- localparam CTRL_STALLPIPE_SDIV2 = 4'h8;
- localparam CTRL_L_STALLPIPE_ES = 4'h9;
- localparam CTRL_EMIT_S = 4'ha;
+ localparam CTRL_LOOP_ITER = 4'h1;
+ localparam CTRL_LOOP_BQ = 4'h2;
+ localparam CTRL_CALC_ADD = 4'h3;
+ localparam CTRL_STALLPIPE_ADD = 4'h4;
+ localparam CTRL_CALC_SDIV2 = 4'h5;
+ localparam CTRL_STALLPIPE_SDIV2 = 4'h6;
+ localparam CTRL_L_STALLPIPE_ES = 4'h7;
+ localparam CTRL_EMIT_S = 4'h8;
localparam SMUX_ZERO = 2'h0;
localparam SMUX_ITER = 2'h1;
@@ -317,11 +315,6 @@ module montprod #(parameter OPW = 32, parameter ADW = 8)
s_mem_we = 1'b0;
case (montprod_ctrl_reg)
- CTRL_INIT_S:
- begin
- s_mem_we_new = 1'b1;
- end
-
CTRL_LOOP_ITER:
begin
s_mem_read_addr = length_m1;
@@ -409,7 +402,11 @@ module montprod #(parameter OPW = 32, parameter ADW = 8)
always @*
begin : bq
b_new = opb_data[b_bit_index_reg];
- q_new = s_mem_read_data[0] ^ (opa_data[0] & b_new);
+
+ if (first_iteration_reg)
+ q_new = 1'b0 ^ (opa_data[0] & b_new);
+ else
+ q_new = s_mem_read_data[0] ^ (opa_data[0] & b_new);
b_bit_index_new = (2**(13 - ADW) - 1) - loop_ctr_reg[(13 - ADW - 1) : 0];
b_word_index = loop_ctr_reg[12 : (13 - ADW)];
@@ -513,29 +510,11 @@ module montprod #(parameter OPW = 32, parameter ADW = 8)
ready_we = 1'b1;
reset_word_index_lsw = 1'b1;
loop_ctr_set = 1'b1;
- montprod_ctrl_new = CTRL_INIT_S;
+ montprod_ctrl_new = CTRL_LOOP_ITER;
montprod_ctrl_we = 1'b1;
end
end
- CTRL_INIT_S:
- begin
- s_mux_new = SMUX_ZERO;
- dec_word_index = 1'b1;
-
- if (word_index_reg == 0)
- begin
- montprod_ctrl_new = CTRL_WAIT;
- montprod_ctrl_we = 1'b1;
- end
- end
-
- CTRL_WAIT:
- begin
- montprod_ctrl_new = CTRL_LOOP_ITER;
- montprod_ctrl_we = 1'b1;
- end
-
//calculate q = (s - b * A) & 1;.
// Also abort loop if done.
CTRL_LOOP_ITER:
diff --git a/src/tb/tb_montprod.v b/src/tb/tb_montprod.v
index c98e8a2..cd27949 100644
--- a/src/tb/tb_montprod.v
+++ b/src/tb/tb_montprod.v
@@ -241,8 +241,6 @@ module tb_montprod();
case (dut.montprod_ctrl_new)
dut.CTRL_IDLE:
$display("FSM: IDLE");
- dut.CTRL_INIT_S:
- $display("FSM: INIT_S");
dut.CTRL_LOOP_ITER:
$display("FSM: LOOP_ITER");
dut.CTRL_LOOP_BQ:
More information about the Commits
mailing list