aboutsummaryrefslogtreecommitdiff
path: root/src/rtl/sha512_core.v
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-04-03 11:59:25 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-04-03 11:59:25 +0200
commit00f002c478e718d8bc6a71d148816820a8e65fc7 (patch)
treef3d12d970150ec8cfd69697a74c8d5016917432e /src/rtl/sha512_core.v
parent285a7830994783cd04307e4274749a84123a26b5 (diff)
Non functional cleanups: (1) Changed name of round counter to show what is used for. (2) Fixed timescale and empty parentheses of tasks in testbenches. (3) Fixed targets in Makefile to build if needed.
Diffstat (limited to 'src/rtl/sha512_core.v')
-rw-r--r--src/rtl/sha512_core.v64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/rtl/sha512_core.v b/src/rtl/sha512_core.v
index 9454f40..01f124d 100644
--- a/src/rtl/sha512_core.v
+++ b/src/rtl/sha512_core.v
@@ -126,11 +126,11 @@ module sha512_core(
reg [63 : 0] H7_new;
reg H_we;
- reg [6 : 0] t_ctr_reg;
- reg [6 : 0] t_ctr_new;
- reg t_ctr_we;
- reg t_ctr_inc;
- reg t_ctr_rst;
+ reg [6 : 0] round_ctr_reg;
+ reg [6 : 0] round_ctr_new;
+ reg round_ctr_we;
+ reg round_ctr_inc;
+ reg round_ctr_rst;
reg [31 : 0] work_factor_ctr_reg;
reg [31 : 0] work_factor_ctr_new;
@@ -147,6 +147,7 @@ module sha512_core(
reg [1 : 0] sha512_ctrl_new;
reg sha512_ctrl_we;
+ reg [63 : 0] t1_reg;
//----------------------------------------------------------------
// Wires.
@@ -184,7 +185,7 @@ module sha512_core(
// Module instantiantions.
//----------------------------------------------------------------
sha512_k_constants k_constants_inst(
- .addr(t_ctr_reg),
+ .addr(round_ctr_reg),
.K(k_data)
);
@@ -254,11 +255,14 @@ module sha512_core(
H7_reg <= 64'h0000000000000000;
work_factor_ctr_reg <= 32'h00000000;
digest_valid_reg <= 0;
- t_ctr_reg <= 7'h00;
+ round_ctr_reg <= 7'h0;
sha512_ctrl_reg <= CTRL_IDLE;
+ t1_reg <= 64'h0;
end
else
begin
+ t1_reg <= t1;
+
if (a_h_we)
begin
a_reg <= a_new;
@@ -331,9 +335,9 @@ module sha512_core(
if (state15_we)
H7_reg <= {H7_reg[63 : 32], state_wr_data};
- if (t_ctr_we)
+ if (round_ctr_we)
begin
- t_ctr_reg <= t_ctr_new;
+ round_ctr_reg <= round_ctr_new;
end
if (work_factor_ctr_we)
@@ -501,28 +505,28 @@ module sha512_core(
//----------------------------------------------------------------
- // t_ctr
+ // round_ctr
//
// Update logic for the round counter, a monotonically
// increasing counter with reset.
//----------------------------------------------------------------
always @*
- begin : t_ctr
- t_ctr_new = 7'h00;
- t_ctr_we = 0;
+ begin : round_ctr
+ round_ctr_new = 7'h0;
+ round_ctr_we = 0;
- if (t_ctr_rst)
+ if (round_ctr_rst)
begin
- t_ctr_new = 7'h00;
- t_ctr_we = 1;
+ round_ctr_new = 7'h00;
+ round_ctr_we = 1;
end
- if (t_ctr_inc)
+ if (round_ctr_inc)
begin
- t_ctr_new = t_ctr_reg + 1'b1;
- t_ctr_we = 1;
+ round_ctr_new = round_ctr_reg + 1'b1;
+ round_ctr_we = 1;
end
- end // t_ctr
+ end // round_ctr
//----------------------------------------------------------------
@@ -567,7 +571,6 @@ module sha512_core(
state_init = 0;
state_update = 0;
- t1_we = 0;
first_block = 0;
ready_flag = 0;
@@ -575,8 +578,8 @@ module sha512_core(
w_init = 0;
w_next = 0;
- t_ctr_inc = 0;
- t_ctr_rst = 0;
+ round_ctr_inc = 0;
+ round_ctr_rst = 0;
digest_valid_new = 0;
digest_valid_we = 0;
@@ -600,7 +603,7 @@ module sha512_core(
w_init = 1;
state_init = 1;
first_block = 1;
- t_ctr_rst = 1;
+ round_ctr_rst = 1;
digest_valid_new = 0;
digest_valid_we = 1;
sha512_ctrl_new = CTRL_ROUNDS1;
@@ -612,7 +615,7 @@ module sha512_core(
work_factor_ctr_rst = 1;
w_init = 1;
state_init = 1;
- t_ctr_rst = 1;
+ round_ctr_rst = 1;
digest_valid_new = 0;
digest_valid_we = 1;
sha512_ctrl_new = CTRL_ROUNDS1;
@@ -623,7 +626,6 @@ module sha512_core(
CTRL_ROUNDS1:
begin
- t1_we = 1;
sha512_ctrl_new = CTRL_ROUNDS2;
sha512_ctrl_we = 1;
end
@@ -631,11 +633,11 @@ module sha512_core(
CTRL_ROUNDS2:
begin
- w_next = 1;
- state_update = 1;
- t_ctr_inc = 1;
+ w_next = 1;
+ state_update = 1;
+ round_ctr_inc = 1;
- if (t_ctr_reg == SHA512_ROUNDS)
+ if (round_ctr_reg == SHA512_ROUNDS)
begin
work_factor_ctr_inc = 1;
sha512_ctrl_new = CTRL_DONE;
@@ -651,7 +653,7 @@ module sha512_core(
begin
w_init = 1;
state_init = 1;
- t_ctr_rst = 1;
+ round_ctr_rst = 1;
sha512_ctrl_new = CTRL_ROUNDS1;
sha512_ctrl_we = 1;
end