📄 sha512.v
字号:
round <= 'd0;
busy <= 'b0;
W0 <= 'b0;
W1 <= 'b0;
W2 <= 'b0;
W3 <= 'b0;
W4 <= 'b0;
W5 <= 'b0;
W6 <= 'b0;
W7 <= 'b0;
W8 <= 'b0;
W9 <= 'b0;
W10 <= 'b0;
W11 <= 'b0;
W12 <= 'b0;
W13 <= 'b0;
W14 <= 'b0;
Wt <= 'b0;
A <= 'b0;
B <= 'b0;
C <= 'b0;
D <= 'b0;
E <= 'b0;
F <= 'b0;
G <= 'b0;
H <= 'b0;
H0 <= 'b0;
H1 <= 'b0;
H2 <= 'b0;
H3 <= 'b0;
H4 <= 'b0;
H5 <= 'b0;
H6 <= 'b0;
H7 <= 'b0;
end
else
begin
case (round)
'd0:
begin
if (cmd[1])
begin
W0[31:0] <= text_i;
Wt[31:0] <= text_i;
busy <= 'b1;
round <= round_plus_1;
case (cmd[3:2])
2'b00: // sha-384 first message
begin
A <= `SHA384_H0;
B <= `SHA384_H1;
C <= `SHA384_H2;
D <= `SHA384_H3;
E <= `SHA384_H4;
F <= `SHA384_H5;
G <= `SHA384_H6;
H <= `SHA384_H7;
H0 <= `SHA384_H0;
H1 <= `SHA384_H1;
H2 <= `SHA384_H2;
H3 <= `SHA384_H3;
H4 <= `SHA384_H4;
H5 <= `SHA384_H5;
H6 <= `SHA384_H6;
H7 <= `SHA384_H7;
end
2'b01: // sha-384 internal message
begin
H0 <= A;
H1 <= B;
H2 <= C;
H3 <= D;
H4 <= E;
H5 <= F;
H6 <= G;
H7 <= H;
end
2'b10: // sha-512 first message
begin
A <= `SHA512_H0;
B <= `SHA512_H1;
C <= `SHA512_H2;
D <= `SHA512_H3;
E <= `SHA512_H4;
F <= `SHA512_H5;
G <= `SHA512_H6;
H <= `SHA512_H7;
H0 <= `SHA512_H0;
H1 <= `SHA512_H1;
H2 <= `SHA512_H2;
H3 <= `SHA512_H3;
H4 <= `SHA512_H4;
H5 <= `SHA512_H5;
H6 <= `SHA512_H6;
H7 <= `SHA512_H7;
end
2'b11: // sha-512 internal message
begin
H0 <= A;
H1 <= B;
H2 <= C;
H3 <= D;
H4 <= E;
H5 <= F;
H6 <= G;
H7 <= H;
end
endcase
end
else
begin // IDLE
round <= 'd0;
end
end
'd1:
begin
W0[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd2:
begin
W1[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd3:
begin
W1[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd4:
begin
W2[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd5:
begin
W2[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd6:
begin
W3[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd7:
begin
W3[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd8:
begin
W4[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd9:
begin
W4[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd10:
begin
W5[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd11:
begin
W5[63:32] <= text_i;
Wt[63:32] <= text_i;
round <= round_plus_1;
end
'd12:
begin
W6[31:0] <= text_i;
Wt[31:0] <= text_i;
H <= G;
G <= F;
F <= E;
E <= next_E;
D <= C;
C <= B;
B <= A;
A <= next_A;
round <= round_plus_1;
end
'd13:
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -