aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-18 10:34:16 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-18 10:34:16 +0200
commit35c08fcc620a0b6118dc7ee2811475454cf5050b (patch)
tree4f4e7fcdaee52209ec8ea69f09a3e31c14462dc3 /src
parenta5076bb806fb6e6d2e4428fbb4156e7e1f23530b (diff)
Combined case statements to make it easier to follow the sequences.
Diffstat (limited to 'src')
-rw-r--r--src/rtl/montprod.v49
1 files changed, 16 insertions, 33 deletions
diff --git a/src/rtl/montprod.v b/src/rtl/montprod.v
index 8f2d012..f505d0c 100644
--- a/src/rtl/montprod.v
+++ b/src/rtl/montprod.v
@@ -331,44 +331,19 @@ module montprod(
//----------------------------------------------------------------
always @*
begin : s_select_write
- shr_carry_in_new = 1'b0;
- s_mux_new = SMUX_0;
- s_mem_we_new = 1'b0;
- sa_adder_data_in = 32'h0;
-
- case (montprod_ctrl_reg)
- CTRL_INIT_S:
- begin
- s_mux_new = SMUX_0; // write 0
- s_mem_we_new = 1'b1;
- end
-
- CTRL_L_CALC_SA:
- begin
- //s = (s + q*M + b*A) >>> 1;, if(b==1) S+= A. Takes (1..length) cycles.
- s_mux_new = SMUX_ADD_SA;
- s_mem_we_new = b_reg | q_reg;
- end
-
- CTRL_L_CALC_SDIV2:
- begin
- //s = (s + q*M + b*A) >>> 1; s>>=1. Takes (1..length) cycles.
- s_mux_new = SMUX_SHR;
- s_mem_we_new = 1'b1;
- end
-
- default:
- begin
- end
- endcase
-
- s_mem_new = 32'h0;
+ sa_adder_data_in = 32'h0;
+ shr_carry_in_new = 1'b0;
add_carry_in_sa_new = 1'b0;
add_carry_in_sm_new = 1'b0;
+ s_mem_new = 32'h0;
+ s_mem_we_new = 1'b0;
case (s_mux_reg)
SMUX_0:
- s_mem_new = 32'h0;
+ begin
+ s_mem_new = 32'h0;
+ s_mem_we_new = 1'b1;
+ end
SMUX_ADD_SA:
begin
@@ -384,6 +359,7 @@ module montprod(
add_carry_in_sa_new = add_carry_out_sa;
add_carry_in_sm_new = add_carry_out_sm;
+ s_mem_we_new = b_reg | q_reg;
end
SMUX_SHR:
@@ -391,6 +367,7 @@ module montprod(
shr_data_in = s_mem_read_data;
s_mem_new = shr_data_out;
shr_carry_in_new = shr_carry_out;
+ s_mem_we_new = 1'b1;
end
default:
@@ -483,6 +460,8 @@ module montprod(
CTRL_INIT_S:
begin
+ s_mux_new = SMUX_0;
+
if (word_index_reg == 8'h0)
begin
loop_ctr_set = 1'b1;
@@ -517,6 +496,8 @@ module montprod(
CTRL_L_CALC_SA:
begin
+ s_mux_new = SMUX_ADD_SA;
+
if (word_index_reg == 8'h0)
begin
reset_word_index_lsw = 1'b1;
@@ -534,6 +515,8 @@ module montprod(
CTRL_L_CALC_SDIV2:
begin
+ s_mux_new = SMUX_SHR;
+
if (word_index_reg == length_m1)
begin
montprod_ctrl_new = CTRL_L_STALLPIPE_D2;