-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZIR-306: Add SHA-2 accelerator, fix division overconstraint bug, add …
…rv32im compliance tests to C++ (#144) * Sha2 passes smoke test: todo, add some wrapper code and more test vectors * Improve sha tests to cover all the relevant cases * Fixed div * Remove unused code * Fixes for CI --------- Co-authored-by: Frank Laub <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,152 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// This file contains utilities that work with bits and twits. | ||
// RUN: zirgen --test %s | ||
|
||
// Vector / List functions | ||
|
||
// Shifts + Rotates | ||
component RotateLeft<SIZE: Val>(in: Array<Val, SIZE>, n: Val) { | ||
for i : 0..SIZE { | ||
if (InRange(0, i - n, SIZE)) { in[i - n] } else { in[SIZE + i - n] } | ||
} | ||
} | ||
|
||
component RotateRight<SIZE: Val>(in: Array<Val, SIZE>, n: Val) { | ||
for i : 0..SIZE { | ||
if (InRange(0, i + n, SIZE)) { in[i + n] } else { in[i + n - SIZE] } | ||
} | ||
} | ||
|
||
component ShiftLeft<SIZE: Val>(in: Array<Val, SIZE>, n: Val) { | ||
for i : 0..SIZE { | ||
if (InRange(0, i - n, SIZE)) { in[i - n] } else { 0 } | ||
} | ||
} | ||
|
||
component ShiftRight<SIZE: Val>(in: Array<Val, SIZE>, n: Val) { | ||
for i : 0..SIZE { | ||
if (InRange(0, i + n, SIZE)) { in[i + n] } else { 0 } | ||
} | ||
} | ||
|
||
component EqArr<SIZE: Val>(a: Array<Val, SIZE>, b: Array<Val, SIZE>) { | ||
for i : 0..SIZE { | ||
a[i] = b[i]; | ||
} | ||
} | ||
|
||
// Tests.... | ||
|
||
test ShiftAndRotate { | ||
// TODO: Now that these support non-bit values, maybe make new tests | ||
// Remember: array entry 0 is the low bit, so there seem backwards | ||
EqArr<8>(ShiftRight<8>([1, 1, 1, 0, 1, 0, 0, 0], 2), [1, 0, 1, 0, 0, 0, 0, 0]); | ||
EqArr<8>(ShiftLeft<8>([1, 1, 1, 0, 1, 0, 0, 0], 2), [0, 0, 1, 1, 1, 0, 1, 0]); | ||
EqArr<8>(RotateRight<8>([1, 1, 1, 0, 1, 0, 0, 0], 2), [1, 0, 1, 0, 0, 0, 1, 1]); | ||
EqArr<8>(RotateLeft<8>([1, 1, 1, 0, 1, 0, 0, 1], 2), [0, 1, 1, 1, 1, 0, 1, 0]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.