Skip to content

Commit 55245d3

Browse files
committed
keccak: Add ifdef to keccak_iota for synth with yosys
1 parent 0a91a4e commit 55245d3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/keccak/keccak_iota.sv

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ module keccak_iota #(
1010
for (genvar i = 0; i < 5; i++) begin: sheet_select
1111
for (genvar j = 0; j < 5; j++) begin: lane_select
1212
if ((i == 4) & (j == 4)) begin: apply_rc
13-
// If yosys supported streaming operators, we'd flip the rc bytes like so:
14-
// assign y[i][j] = x[i][j] ^ {<<8{rc}};
15-
// Unfortunately yosys doesn't support the {<<{}} streaming operator :(
16-
// Instead we have to swap bytes manually, adding this gross for loop
17-
for (genvar b = 0; b < w/8; b++) begin: swap_bytes
18-
assign y[i][j][8*(b+1)-1:8*b] = x[i][j][8*(b+1)-1:8*b] ^ rc[w-8*b-1:w-8*(b+1)];
19-
end
13+
`ifdef YOSYS
14+
// Unfortunately yosys doesn't support the {<<{}} streaming operator :(
15+
// Instead we have to swap bytes manually, adding this gross for loop
16+
for (genvar b = 0; b < w/8; b++) begin: swap_bytes
17+
assign y[i][j][8*(b+1)-1:8*b] = x[i][j][8*(b+1)-1:8*b] ^ rc[w-8*b-1:w-8*(b+1)];
18+
end
19+
`else
20+
assign y[i][j] = x[i][j] ^ {<<8{rc}};
21+
`endif
2022
end else begin: passthrough
2123
assign y[i][j] = x[i][j];
2224
end

0 commit comments

Comments
 (0)