Skip to content

Commit 4c57e6c

Browse files
committed
Blake2b is working with a single compression round
1 parent 0b62ecb commit 4c57e6c

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

MixG.vhd

+9-17
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end MixG;
3232

3333
architecture rtl of MixG is
3434
signal A, B, C, D : unsigned(63 downto 0);
35-
signal cStep : natural range 0 to 7 := 0;
35+
signal cStep : natural range 0 to 3 := 0;
3636
begin
3737

3838
Mix: process(aReset, Clk)
@@ -49,40 +49,32 @@ begin
4949

5050
Valid <= '0';
5151

52-
if cStep < 7 then
52+
if cStep < 3 then
5353
cStep <= cStep + 1;
5454
else
5555
cStep <= 0;
5656
end if;
5757

5858
case(cStep) is
59-
6059
when 0 =>
6160
if not Start then
6261
-- Get stuck in here until start is asserted (overrides cStep)
6362
cStep <= cStep;
6463
else
6564
A <= A_in + B_in + X;
65+
D <= (D_in xor (A_in + B_in + X)) ror 32;
6666
end if;
6767
when 1 =>
68-
D <= (D_in xor A) ror 32;
69-
when 2 =>
7068
C <= C_in + D;
71-
when 3 =>
72-
B <= (B_in xor C) ror 24;
73-
when 4 =>
69+
B <= (B_in xor (C_in + D)) ror 24;
70+
when 2 =>
7471
A <= A + B + Y;
75-
when 5 =>
76-
D <= (D xor A) ror 16;
77-
when 6 =>
72+
D <= (D xor (A + B + Y)) ror 16;
73+
when 3 =>
7874
C <= C + D;
79-
when 7 =>
80-
B <= (B xor C) rol 1; -- Rotate right 63
81-
Valid <= '1';
82-
75+
B <= (B xor (C + D)) rol 1; -- Rotate right 63
76+
Valid <= '1';
8377
end case;
84-
85-
8678
end if;
8779
end process;
8880

PkgBlake2b.vhd

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ package PkgBlake2b is
4545
x"6a09e667f3bcc908"
4646
);
4747

48-
end PkgBlake2b;
48+
end PkgBlake2b;

Testbench/Blake2b_tb.vhd

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- Testbench for Blake2b.vhd
2+
-- Current compression performance: 122 clk cycles
23

34
library ieee;
45
use ieee.std_logic_1164.all;
@@ -63,6 +64,7 @@ begin
6364
assert not Done report "Done should be initially false" severity error;
6465
assert not Busy report "Busy should be initially false" severity error;
6566

67+
wait until aReset = '0';
6668
-- Push a single block test message to the core
6769
Msg <= kTestMsg;
6870
MsgLen <= to_unsigned(3, MsgLen'length); -- 0x636261

0 commit comments

Comments
 (0)