mirror of
https://github.com/openhwgroup/cva6.git
synced 2025-04-20 04:07:36 -04:00
format fixes
This commit is contained in:
parent
148fc6f923
commit
a68a3e92fa
5 changed files with 170 additions and 102 deletions
|
@ -827,19 +827,51 @@ module decoder
|
|||
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::AES64KS2; // aes64ks2
|
||||
else illegal_instr_bm = 1'b1;
|
||||
end
|
||||
{7'b0010001, 3'b000}, {7'b0110001, 3'b000}, {7'b1010001, 3'b000}, {7'b1110001, 3'b000}: begin
|
||||
{
|
||||
7'b0010001, 3'b000
|
||||
}, {
|
||||
7'b0110001, 3'b000
|
||||
}, {
|
||||
7'b1010001, 3'b000
|
||||
}, {
|
||||
7'b1110001, 3'b000
|
||||
} : begin
|
||||
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::AES32ESI; // aes32esi
|
||||
else illegal_instr_bm = 1'b1;
|
||||
end
|
||||
{7'b0010011, 3'b000}, {7'b0110011, 3'b000}, {7'b1010011, 3'b000}, {7'b1110011, 3'b000}: begin
|
||||
{
|
||||
7'b0010011, 3'b000
|
||||
}, {
|
||||
7'b0110011, 3'b000
|
||||
}, {
|
||||
7'b1010011, 3'b000
|
||||
}, {
|
||||
7'b1110011, 3'b000
|
||||
} : begin
|
||||
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::AES32ESMI; // aes32esmi
|
||||
else illegal_instr_bm = 1'b1;
|
||||
end
|
||||
{7'b0010101, 3'b000}, {7'b0110101, 3'b000}, {7'b1010101, 3'b000}, {7'b1110101, 3'b000}: begin
|
||||
{
|
||||
7'b0010101, 3'b000
|
||||
}, {
|
||||
7'b0110101, 3'b000
|
||||
}, {
|
||||
7'b1010101, 3'b000
|
||||
}, {
|
||||
7'b1110101, 3'b000
|
||||
} : begin
|
||||
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::AES32DSI; // aes32dsi
|
||||
else illegal_instr_bm = 1'b1;
|
||||
end
|
||||
{7'b0010111, 3'b000}, {7'b0110111, 3'b000}, {7'b1010111, 3'b000}, {7'b1110111, 3'b000}: begin
|
||||
{
|
||||
7'b0010111, 3'b000
|
||||
}, {
|
||||
7'b0110111, 3'b000
|
||||
}, {
|
||||
7'b1010111, 3'b000
|
||||
}, {
|
||||
7'b1110111, 3'b000
|
||||
} : begin
|
||||
if (CVA6Cfg.ZKN) instruction_o.op = ariane_pkg::AES32DSMI; // aes32dsmi
|
||||
else illegal_instr_bm = 1'b1;
|
||||
end
|
||||
|
|
|
@ -311,7 +311,7 @@ module ex_stage
|
|||
.fu_data_i (one_cycle_data),
|
||||
.result_o (alu_result),
|
||||
.alu_branch_res_o(alu_branch_res),
|
||||
.orig_instr_aes(orig_instr_aes_i)
|
||||
.orig_instr_aes (orig_instr_aes_i)
|
||||
);
|
||||
|
||||
// 2. Branch Unit (combinatorial)
|
||||
|
@ -480,7 +480,7 @@ module ex_stage
|
|||
.fu_data_i (alu2_data),
|
||||
.result_o (alu2_result),
|
||||
.alu_branch_res_o( /* this ALU does not handle branching */),
|
||||
.orig_instr_aes()
|
||||
.orig_instr_aes ()
|
||||
);
|
||||
end else begin
|
||||
assign alu2_data = '0;
|
||||
|
|
|
@ -834,109 +834,127 @@ package ariane_pkg;
|
|||
|
||||
// AES functions
|
||||
// AES MixColumns Forward
|
||||
function [31:0] aes_mixcolumn_fwd(input [31:0] x);
|
||||
begin
|
||||
aes_mixcolumn_fwd = {(((x[7:0] << 1) ^ ((x[7]) ? 8'h1B : 8'h00)) ^ x[7:0]) ^ x[15:8] ^ x[23:16] ^ ((x[31:24] << 1) ^ ((x[31]) ? 8'h1B : 8'h00)),
|
||||
x[7:0] ^ x[15:8] ^ ((x[23:16] << 1) ^ ((x[23]) ? 8'h1B : 8'h00)) ^ (((x[31:24] << 1) ^ ((x[31]) ? 8'h1B : 8'h00)) ^ x[31:24]),
|
||||
x[7:0] ^ ((x[15:8] << 1) ^ ((x[15]) ? 8'h1B : 8'h00)) ^ (((x[23:16] << 1) ^ ((x[23]) ? 8'h1B : 8'h00)) ^ x[23:16]) ^ x[31:24],
|
||||
((x[7:0] << 1) ^ ((x[7]) ? 8'h1B : 8'h00)) ^ (((x[15:8] << 1) ^ ((x[15]) ? 8'h1B : 8'h00)) ^ x[15:8]) ^ x[23:16] ^ x[31:24]};
|
||||
end
|
||||
endfunction
|
||||
function [31:0] aes_mixcolumn_fwd(input [31:0] x);
|
||||
begin
|
||||
aes_mixcolumn_fwd = {
|
||||
(((x[7:0] << 1) ^ ((x[7]) ? 8'h1B : 8'h00)) ^ x[7:0]) ^ x[15:8] ^ x[23:16] ^ ((x[31:24] << 1) ^ ((x[31]) ? 8'h1B : 8'h00)),
|
||||
x[7:0] ^ x[15:8] ^ ((x[23:16] << 1) ^ ((x[23]) ? 8'h1B : 8'h00)) ^ (((x[31:24] << 1) ^ ((x[31]) ? 8'h1B : 8'h00)) ^ x[31:24]),
|
||||
x[7:0] ^ ((x[15:8] << 1) ^ ((x[15]) ? 8'h1B : 8'h00)) ^ (((x[23:16] << 1) ^ ((x[23]) ? 8'h1B : 8'h00)) ^ x[23:16]) ^ x[31:24],
|
||||
((x[7:0] << 1) ^ ((x[7]) ? 8'h1B : 8'h00)) ^ (((x[15:8] << 1) ^ ((x[15]) ? 8'h1B : 8'h00)) ^ x[15:8]) ^ x[23:16] ^ x[31:24]
|
||||
};
|
||||
end
|
||||
endfunction
|
||||
// AES subword Forward
|
||||
function [31:0] aes_subword_fwd(input [31:0] word);
|
||||
aes_subword_fwd = {aes_sbox_fwd(word[31:24]),
|
||||
aes_sbox_fwd(word[23:16]),
|
||||
aes_sbox_fwd(word[15:8]),
|
||||
aes_sbox_fwd(word[7:0])};
|
||||
endfunction
|
||||
function [31:0] aes_subword_fwd(input [31:0] word);
|
||||
aes_subword_fwd = {
|
||||
aes_sbox_fwd(word[31:24]),
|
||||
aes_sbox_fwd(word[23:16]),
|
||||
aes_sbox_fwd(word[15:8]),
|
||||
aes_sbox_fwd(word[7:0])
|
||||
};
|
||||
endfunction
|
||||
// AES Round Constant
|
||||
function [31:0] aes_decode_rcon(input [3:0] r);
|
||||
case (r)
|
||||
4'h0: aes_decode_rcon = 32'h00000001;
|
||||
4'h1: aes_decode_rcon = 32'h00000002;
|
||||
4'h2: aes_decode_rcon = 32'h00000004;
|
||||
4'h3: aes_decode_rcon = 32'h00000008;
|
||||
4'h4: aes_decode_rcon = 32'h00000010;
|
||||
4'h5: aes_decode_rcon = 32'h00000020;
|
||||
4'h6: aes_decode_rcon = 32'h00000040;
|
||||
4'h7: aes_decode_rcon = 32'h00000080;
|
||||
4'h8: aes_decode_rcon = 32'h0000001b;
|
||||
4'h9: aes_decode_rcon = 32'h00000036;
|
||||
4'hA: aes_decode_rcon = 32'h00000000;
|
||||
4'hB: aes_decode_rcon = 32'h00000000;
|
||||
4'hC: aes_decode_rcon = 32'h00000000;
|
||||
4'hD: aes_decode_rcon = 32'h00000000;
|
||||
4'hE: aes_decode_rcon = 32'h00000000;
|
||||
4'hF: aes_decode_rcon = 32'h00000000;
|
||||
default: aes_decode_rcon = 32'h00000000;
|
||||
endcase
|
||||
endfunction
|
||||
function [31:0] aes_decode_rcon(input [3:0] r);
|
||||
case (r)
|
||||
4'h0: aes_decode_rcon = 32'h00000001;
|
||||
4'h1: aes_decode_rcon = 32'h00000002;
|
||||
4'h2: aes_decode_rcon = 32'h00000004;
|
||||
4'h3: aes_decode_rcon = 32'h00000008;
|
||||
4'h4: aes_decode_rcon = 32'h00000010;
|
||||
4'h5: aes_decode_rcon = 32'h00000020;
|
||||
4'h6: aes_decode_rcon = 32'h00000040;
|
||||
4'h7: aes_decode_rcon = 32'h00000080;
|
||||
4'h8: aes_decode_rcon = 32'h0000001b;
|
||||
4'h9: aes_decode_rcon = 32'h00000036;
|
||||
4'hA: aes_decode_rcon = 32'h00000000;
|
||||
4'hB: aes_decode_rcon = 32'h00000000;
|
||||
4'hC: aes_decode_rcon = 32'h00000000;
|
||||
4'hD: aes_decode_rcon = 32'h00000000;
|
||||
4'hE: aes_decode_rcon = 32'h00000000;
|
||||
4'hF: aes_decode_rcon = 32'h00000000;
|
||||
default: aes_decode_rcon = 32'h00000000;
|
||||
endcase
|
||||
endfunction
|
||||
// AES MixColumns Inverse
|
||||
function logic [31:0] aes_mixcolumn_inv(input logic [31:0] x);
|
||||
aes_mixcolumn_inv = {(gfmul(x[7:0], 4'hB) ^ gfmul(x[15:8], 4'hD) ^ gfmul(x[23:16], 4'h9) ^ gfmul(x[31:24], 4'hE)),
|
||||
(gfmul(x[7:0], 4'hD) ^ gfmul(x[15:8], 4'h9) ^ gfmul(x[23:16], 4'hE) ^ gfmul(x[31:24], 4'hB)),
|
||||
(gfmul(x[7:0], 4'h9) ^ gfmul(x[15:8], 4'hE) ^ gfmul(x[23:16], 4'hB) ^ gfmul(x[31:24], 4'hD)),
|
||||
(gfmul(x[7:0], 4'hE) ^ gfmul(x[15:8], 4'hB) ^ gfmul(x[23:16], 4'hD) ^ gfmul(x[31:24], 4'h9))};
|
||||
endfunction
|
||||
function logic [31:0] aes_mixcolumn_inv(input logic [31:0] x);
|
||||
aes_mixcolumn_inv = {
|
||||
(gfmul(x[7:0], 4'hB) ^ gfmul(x[15:8], 4'hD) ^ gfmul(x[23:16], 4'h9) ^ gfmul(x[31:24], 4'hE)),
|
||||
(gfmul(x[7:0], 4'hD) ^ gfmul(x[15:8], 4'h9) ^ gfmul(x[23:16], 4'hE) ^ gfmul(x[31:24], 4'hB)),
|
||||
(gfmul(x[7:0], 4'h9) ^ gfmul(x[15:8], 4'hE) ^ gfmul(x[23:16], 4'hB) ^ gfmul(x[31:24], 4'hD)),
|
||||
(gfmul(x[7:0], 4'hE) ^ gfmul(x[15:8], 4'hB) ^ gfmul(x[23:16], 4'hD) ^ gfmul(x[31:24], 4'h9))
|
||||
};
|
||||
endfunction
|
||||
// GF multiplication
|
||||
function logic [7:0] gfmul(input logic [7:0] x, input logic [3:0] y);
|
||||
function logic [7:0] gfmul(input logic [7:0] x, input logic [3:0] y);
|
||||
logic [7:0] result, temp;
|
||||
result = 8'h00;
|
||||
if (y[0]) result ^= x;
|
||||
if (y[1]) begin
|
||||
result ^= ((x << 1) ^ ((x[7]) ? 8'h1B : 8'h00));
|
||||
result ^= ((x << 1) ^ ((x[7]) ? 8'h1B : 8'h00));
|
||||
end
|
||||
if (y[2]) begin
|
||||
temp = (x << 1) ^ ((x[7]) ? 8'h1B : 8'h00);
|
||||
result ^= (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
temp = (x << 1) ^ ((x[7]) ? 8'h1B : 8'h00);
|
||||
result ^= (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
end
|
||||
if (y[3]) begin
|
||||
temp = (x << 1) ^ ((x[7]) ? 8'h1B : 8'h00);
|
||||
temp = (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
result ^= (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
temp = (x << 1) ^ ((x[7]) ? 8'h1B : 8'h00);
|
||||
temp = (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
result ^= (temp << 1) ^ ((temp[7]) ? 8'h1B : 8'h00);
|
||||
end
|
||||
return result;
|
||||
endfunction
|
||||
endfunction
|
||||
// AES Sbox Forward
|
||||
function automatic logic [7:0] aes_sbox_fwd(input logic [7:0] in_byte);
|
||||
function automatic logic [7:0] aes_sbox_fwd(input logic [7:0] in_byte);
|
||||
logic [20:0] expanded;
|
||||
logic [17:0] non_linear;
|
||||
logic [7:0] compressed;
|
||||
expanded = linear_top_layer(in_byte);
|
||||
logic [ 7:0] compressed;
|
||||
expanded = linear_top_layer(in_byte);
|
||||
non_linear = non_linear_layer(expanded);
|
||||
compressed = linear_bottom_layer(non_linear);
|
||||
aes_sbox_fwd = compressed;
|
||||
endfunction
|
||||
endfunction
|
||||
// AES Sbox Inverse
|
||||
function automatic logic [7:0] aes_sbox_inv(input logic [7:0] in_byte);
|
||||
function automatic logic [7:0] aes_sbox_inv(input logic [7:0] in_byte);
|
||||
logic [20:0] expanded;
|
||||
logic [17:0] non_linear;
|
||||
logic [7:0] compressed;
|
||||
expanded = aes_sbox_inv_top(in_byte);
|
||||
logic [ 7:0] compressed;
|
||||
expanded = aes_sbox_inv_top(in_byte);
|
||||
non_linear = non_linear_layer(expanded);
|
||||
compressed = aes_sbox_inv_out(non_linear);
|
||||
aes_sbox_inv = compressed;
|
||||
endfunction
|
||||
endfunction
|
||||
// AES Sbox Forward Top Layer
|
||||
function automatic logic [20:0] linear_top_layer(input logic [7:0] x);
|
||||
return { ((x[7] ^ x[4]) ^ (x[5] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ ((x[6] ^ x[5]) ^ (x[4] ^ x[0]))) ^ ((x[0] ^ (x[6] ^ x[5])) ^ ((x[3] ^ x[1]) ^ (x[5] ^ x[2])))),
|
||||
((x[7] ^ x[2]) ^ (((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[5]))),
|
||||
((x[7] ^ x[2]) ^ ((x[6] ^ x[5]) ^ (x[1] ^ x[0]))), ((x[6] ^ x[5]) ^ (x[1] ^ x[0])),
|
||||
((x[7] ^ x[4]) ^ ((x[6] ^ x[5]) ^ (x[4] ^ x[0]))), ((x[6] ^ x[5]) ^ (x[4] ^ x[0])),
|
||||
((x[0] ^ (x[6] ^ x[5])) ^ ((x[3] ^ x[1]) ^ (x[5] ^ x[2]))), ((x[3] ^ x[1]) ^ (x[5] ^ x[2])), ((x[3] ^ x[1]) ^ (x[6] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[2])), ((x[7] ^ x[1]) ^ (x[4] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[5])),
|
||||
(x[0] ^ (x[6] ^ x[5])), (x[0] ^ ((x[7] ^ x[4]) ^ (x[3] ^ x[1]))),
|
||||
((x[7] ^ x[4]) ^ (x[3] ^ x[1])), (x[4] ^ x[2]), (x[7] ^ x[1]), (x[7] ^ x[2]), (x[7] ^ x[4]), (x[0])
|
||||
};
|
||||
endfunction
|
||||
// AES Sbox Middle Layer
|
||||
function automatic logic [17:0] non_linear_layer(input logic [20:0] x);
|
||||
function automatic logic [20:0] linear_top_layer(input logic [7:0] x);
|
||||
return {
|
||||
((x[7] ^ x[4]) ^ (x[5] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ ((x[6] ^ x[5]) ^ (x[4] ^ x[0]))) ^ ((x[0] ^ (x[6] ^ x[5])) ^ ((x[3] ^ x[1]) ^ (x[5] ^ x[2])))),
|
||||
((x[7] ^ x[2]) ^ (((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[5]))),
|
||||
((x[7] ^ x[2]) ^ ((x[6] ^ x[5]) ^ (x[1] ^ x[0]))),
|
||||
((x[6] ^ x[5]) ^ (x[1] ^ x[0])),
|
||||
((x[7] ^ x[4]) ^ ((x[6] ^ x[5]) ^ (x[4] ^ x[0]))),
|
||||
((x[6] ^ x[5]) ^ (x[4] ^ x[0])),
|
||||
((x[0] ^ (x[6] ^ x[5])) ^ ((x[3] ^ x[1]) ^ (x[5] ^ x[2]))),
|
||||
((x[3] ^ x[1]) ^ (x[5] ^ x[2])),
|
||||
((x[3] ^ x[1]) ^ (x[6] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[2])),
|
||||
((x[7] ^ x[1]) ^ (x[4] ^ x[2])),
|
||||
(((x[7] ^ x[4]) ^ (x[3] ^ x[1])) ^ (x[6] ^ x[5])),
|
||||
(x[0] ^ (x[6] ^ x[5])),
|
||||
(x[0] ^ ((x[7] ^ x[4]) ^ (x[3] ^ x[1]))),
|
||||
((x[7] ^ x[4]) ^ (x[3] ^ x[1])),
|
||||
(x[4] ^ x[2]),
|
||||
(x[7] ^ x[1]),
|
||||
(x[7] ^ x[2]),
|
||||
(x[7] ^ x[4]),
|
||||
(x[0])
|
||||
};
|
||||
endfunction
|
||||
// AES Sbox Middle Layer
|
||||
function automatic logic [17:0] non_linear_layer(input logic [20:0] x);
|
||||
logic t1, t2, t3, t4, t5;
|
||||
logic [17:0] y;
|
||||
t1 = (((x[10] ^ (x[9] & x[5])) ^ (x[17] & x[6])) ^ ((x[4] & x[20]) ^ (x[1] & x[11])));
|
||||
t2 = ((((x[14] & x[ 0]) ^ (x[9] & x[5])) ^ x[18]) ^ ((x[2] & x[8]) ^ (x[1] & x[11])));
|
||||
t2 = ((((x[14] & x[0]) ^ (x[9] & x[5])) ^ x[18]) ^ ((x[2] & x[8]) ^ (x[1] & x[11])));
|
||||
t3 = ((((x[3] ^ x[12]) ^ (x[3] & x[12])) ^ (x[16] & x[7])) ^ ((x[4] & x[20]) ^ (x[1] & x[11])));
|
||||
t4 = ((((x[15] & x[13]) ^ (x[3] & x[12])) ^ ((x[2] & x[8]) ^ (x[1] & x[11]))) ^ x[19]);
|
||||
t5 = ((((t1 ^ t2) & (t1 & t4)) ^ ((t1 ^ t2) ^ (t3 & t1))) ^ (((t3 ^ t4) & (t2 & t3)) ^ ((t3 ^ t4) ^ (t3 & t1))));
|
||||
|
@ -960,33 +978,48 @@ package ariane_pkg;
|
|||
y[16] = (t4 ^ ((t2 ^ (t3 & t1)) & (t3 ^ t4))) & x[0];
|
||||
y[17] = ((t2 ^ ((t4 ^ (t3 & t1)) & (t1 ^ t2))) ^ (((t1 ^ t2) & (t1 & t4)) ^ ((t1 ^ t2) ^ (t3 & t1)))) & x[12];
|
||||
return y;
|
||||
endfunction
|
||||
// AES Sbox Forward Bottom Layer
|
||||
function automatic logic [7:0] linear_bottom_layer(input logic [17:0] x);
|
||||
endfunction
|
||||
// AES Sbox Forward Bottom Layer
|
||||
function automatic logic [7:0] linear_bottom_layer(input logic [17:0] x);
|
||||
logic [7:0] y;
|
||||
y[0] = ((x[12] ^ (x[17] ^ x[11])) ^~ ((x[8] ^ (x[1] ^ x[9])) ^ (x[14] ^ x[16])));
|
||||
y[1] = ((x[0] ^ (x[11] ^ x[12])) ^~ ((x[1] ^ x[9]) ^ (x[3] ^ (x[4] ^ x[8]))));
|
||||
y[2] = (((x[12] ^ (x[17] ^ x[11])) ^ (x[3] ^ (x[4] ^ x[8]))) ^ ((x[10] ^ (x[14] ^ x[16])) ^ (x[7] ^ (x[0] ^ x[6]))));
|
||||
y[3] = (((x[11] ^ x[12]) ^ (x[0] ^ x[6])) ^ ((x[15] ^ x[5]) ^ (x[16] ^ x[1])));
|
||||
y[4] = ((x[12] ^ (x[17] ^ x[11])) ^ ((x[0] ^ x[6]) ^ (x[14] ^ (x[15] ^ x[5]))));
|
||||
y[3] = (((x[11] ^ x[12]) ^ (x[0] ^ x[6])) ^ ((x[15] ^ x[5]) ^ (x[16] ^ x[1])));
|
||||
y[4] = ((x[12] ^ (x[17] ^ x[11])) ^ ((x[0] ^ x[6]) ^ (x[14] ^ (x[15] ^ x[5]))));
|
||||
y[5] = ((x[13] ^ (x[4] ^ x[8])) ^~ ((x[10] ^ (x[14] ^ x[16])) ^ (x[2] ^ x[11])));
|
||||
y[6] = ((x[6] ^ (x[11] ^ x[12])) ^~ ((x[14] ^ (x[15] ^ x[5])) ^ (x[2] ^ x[3])));
|
||||
y[7] = ((x[12] ^ (x[17] ^ x[11])) ^ ((x[5] ^ (x[0] ^ x[6])) ^ (x[2] ^ x[3])));
|
||||
y[7] = ((x[12] ^ (x[17] ^ x[11])) ^ ((x[5] ^ (x[0] ^ x[6])) ^ (x[2] ^ x[3])));
|
||||
return y;
|
||||
endfunction
|
||||
// AES Sbox Inverse Top Layer
|
||||
function automatic logic [20:0] aes_sbox_inv_top(input logic [7:0] x);
|
||||
return { ((x[4] ^ x[3]) ^ (x[2] ^~ x[1])), (x[5] ^~ (x[4] ^ x[3])), (x[3] ^~ x[0]),
|
||||
(x[7] ^ x[4]), (x[6] ^~ x[4]), ((x[3] ^~ x[0]) ^ (x[6] ^ x[1])), ((x[6] ^~ x[4]) ^ (x[1] ^ x[0])),
|
||||
(x[5] ^~ ((x[6] ^~ x[4]) ^ (x[1] ^ x[0]))), ((x[6] ^ x[1]) ^ (x[5] ^~ x[3])),
|
||||
(((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])) ^ ((x[4] ^ x[3]) ^ (x[2] ^~ x[1]))),
|
||||
(((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])) ^ (x[2] ^~ x[1])),
|
||||
((x[7] ^~ x[6]) ^ (x[1] ^ x[0])), ((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])), (x[0] ^~ (x[4] ^ x[3])),
|
||||
(x[6] ^~ (x[7] ^ x[4])), ((x[6] ^~ x[4]) ^ (x[5] ^~ x[2])), (x[3] ^ (x[6] ^~ (x[7] ^ x[4]))),
|
||||
((x[4] ^ x[3]) ^ (x[1] ^ x[0])), (x[7] ^~ x[6]), (x[4] ^ x[3]), (x[7] ^ (x[5] ^~ x[2])) };
|
||||
endfunction
|
||||
// AES Sbox Inverse Bottom Layer
|
||||
function automatic logic [7:0] aes_sbox_inv_out(input logic [17:0] x);
|
||||
endfunction
|
||||
// AES Sbox Inverse Top Layer
|
||||
function automatic logic [20:0] aes_sbox_inv_top(input logic [7:0] x);
|
||||
return {
|
||||
((x[4] ^ x[3]) ^ (x[2] ^~ x[1])),
|
||||
(x[5] ^~ (x[4] ^ x[3])),
|
||||
(x[3] ^~ x[0]),
|
||||
(x[7] ^ x[4]),
|
||||
(x[6] ^~ x[4]),
|
||||
((x[3] ^~ x[0]) ^ (x[6] ^ x[1])),
|
||||
((x[6] ^~ x[4]) ^ (x[1] ^ x[0])),
|
||||
(x[5] ^~ ((x[6] ^~ x[4]) ^ (x[1] ^ x[0]))),
|
||||
((x[6] ^ x[1]) ^ (x[5] ^~ x[3])),
|
||||
(((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])) ^ ((x[4] ^ x[3]) ^ (x[2] ^~ x[1]))),
|
||||
(((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])) ^ (x[2] ^~ x[1])),
|
||||
((x[7] ^~ x[6]) ^ (x[1] ^ x[0])),
|
||||
((x[7] ^~ x[6]) ^ (x[3] ^~ x[0])),
|
||||
(x[0] ^~ (x[4] ^ x[3])),
|
||||
(x[6] ^~ (x[7] ^ x[4])),
|
||||
((x[6] ^~ x[4]) ^ (x[5] ^~ x[2])),
|
||||
(x[3] ^ (x[6] ^~ (x[7] ^ x[4]))),
|
||||
((x[4] ^ x[3]) ^ (x[1] ^ x[0])),
|
||||
(x[7] ^~ x[6]),
|
||||
(x[4] ^ x[3]),
|
||||
(x[7] ^ (x[5] ^~ x[2]))
|
||||
};
|
||||
endfunction
|
||||
// AES Sbox Inverse Bottom Layer
|
||||
function automatic logic [7:0] aes_sbox_inv_out(input logic [17:0] x);
|
||||
logic [7:0] y;
|
||||
y[0] = ((x[5] ^ x[13]) ^ (x[7] ^ x[11]));
|
||||
y[1] = ((x[17] ^ x[12]) ^ (((x[2] ^ x[11]) ^ (x[8] ^ x[9])) ^ (x[0] ^ x[3])));
|
||||
|
@ -997,5 +1030,5 @@ function automatic logic [7:0] aes_sbox_inv_out(input logic [17:0] x);
|
|||
y[6] = (((x[5] ^ x[13]) ^ ((x[2] ^ x[11]) ^ (x[15] ^ x[0]))) ^ ((x[4] ^ x[9]) ^ ((x[16] ^ x[6]) ^ (x[17] ^ x[10]))));
|
||||
y[7] = ((x[17] ^ x[1]) ^ ((x[4] ^ x[12]) ^ ((x[2] ^ x[11]) ^ (x[8] ^ x[9]))));
|
||||
return y;
|
||||
endfunction
|
||||
endfunction
|
||||
endpackage
|
||||
|
|
|
@ -1156,7 +1156,7 @@ module issue_read_operands
|
|||
end else begin
|
||||
fu_data_q <= fu_data_n;
|
||||
if (CVA6Cfg.ZKN) begin
|
||||
orig_instr_aes_bits <= {orig_instr_i[0][31:30], orig_instr_i[0][23:20]};
|
||||
orig_instr_aes_bits <= {orig_instr_i[0][31:30], orig_instr_i[0][23:20]};
|
||||
end
|
||||
if (CVA6Cfg.RVH) begin
|
||||
tinst_q <= tinst_n;
|
||||
|
|
|
@ -887,7 +887,10 @@ def load_config(args, cwd):
|
|||
elif base in ("cv64a6_imafdc_sv39_wb"):
|
||||
args.mabi = "lp64d"
|
||||
args.isa = "rv64gc_zba_zbb_zbs_zbc"
|
||||
elif base in ("cv64a6_imafdc_sv39", "cv64a6_imafdc_sv39_hpdcache", "cv64a6_imafdc_sv39_hpdcache_wb"):
|
||||
elif base in ("cv64a6_imafdc_sv39_hpdcache_wb"):
|
||||
args.mabi = "lp64d"
|
||||
args.isa = "rv64gc_zba_zbb_zbs_zbc"
|
||||
elif base in ("cv64a6_imafdc_sv39", "cv64a6_imafdc_sv39_hpdcache"):
|
||||
args.mabi = "lp64d"
|
||||
args.isa = "rv64gc_zba_zbb_zbs_zbc_zbkb_zbkx_zkne_zknd"
|
||||
elif base == "cv32a60x":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue