From 00b61390d9c49565de7338cc25c4e1a9072a9b5b Mon Sep 17 00:00:00 2001 From: KelvinTr Date: Tue, 5 Mar 2024 14:56:24 -0600 Subject: [PATCH] Optimized Inverse Mixcolumn --- src/ieu/aes_common/aes_inv_mixcolumns.sv | 62 +++++-------------- src/ieu/aes_common/aes_mixcolumns.sv | 1 - src/ieu/aes_common/galoismult_forward.sv | 2 +- .../{gm2.sv => galoismult_inverse.sv} | 22 +++---- src/ieu/aes_common/gm11.sv | 44 ------------- src/ieu/aes_common/gm13.sv | 44 ------------- src/ieu/aes_common/gm14.sv | 47 -------------- src/ieu/aes_common/gm3.sv | 42 ------------- src/ieu/aes_common/gm4.sv | 44 ------------- src/ieu/aes_common/gm8.sv | 44 ------------- src/ieu/aes_common/gm9.sv | 42 ------------- src/ieu/aes_instructions/aes32dsi.sv | 2 +- src/ieu/aes_instructions/aes32dsmi.sv | 4 +- src/ieu/aes_instructions/aes32esi.sv | 2 +- src/ieu/aes_instructions/aes32esmi.sv | 4 +- src/ieu/aes_instructions/aes64ds.sv | 6 +- src/ieu/aes_instructions/aes64dsm.sv | 10 +-- src/ieu/aes_instructions/aes64es.sv | 6 +- src/ieu/aes_instructions/aes64esm.sv | 10 +-- src/ieu/aes_instructions/aes64im.sv | 4 +- src/ieu/aes_instructions/aes64ks1i.sv | 2 +- 21 files changed, 53 insertions(+), 391 deletions(-) rename src/ieu/aes_common/{gm2.sv => galoismult_inverse.sv} (74%) delete mode 100644 src/ieu/aes_common/gm11.sv delete mode 100644 src/ieu/aes_common/gm13.sv delete mode 100644 src/ieu/aes_common/gm14.sv delete mode 100644 src/ieu/aes_common/gm3.sv delete mode 100644 src/ieu/aes_common/gm4.sv delete mode 100644 src/ieu/aes_common/gm8.sv delete mode 100644 src/ieu/aes_common/gm9.sv diff --git a/src/ieu/aes_common/aes_inv_mixcolumns.sv b/src/ieu/aes_common/aes_inv_mixcolumns.sv index acb910637..4338e3c32 100644 --- a/src/ieu/aes_common/aes_inv_mixcolumns.sv +++ b/src/ieu/aes_common/aes_inv_mixcolumns.sv @@ -1,8 +1,8 @@ /////////////////////////////////////////// // aes_inv_mixcolumns.sv // -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu +// Created: 05 March 2024 // // Purpose: AES Inverted Mix Column Function for use with AES // @@ -25,52 +25,22 @@ // and limitations under the License. //////////////////////////////////////////////////////////////////////////////////////////////// -module aes_inv_mixcolumns(input logic [31:0] word, output logic [31:0] mixed_word); +module aes_inv_mixcolumns(input logic [31:0] in, output logic [31:0] out); - // Instantiate Internal Logic - logic [7:0] b0, b1, b2, b3; - logic [7:0] mb0, mb1, mb2, mb3; + logic [7:0] in0, in1, in2, in3, temp; + logic [10:0] xor0, xor1, xor2, xor3; - logic [7:0] gm9_mb0, gm11_mb0, gm13_mb0, gm14_mb0; - logic [7:0] gm9_mb1, gm11_mb1, gm13_mb1, gm14_mb1; - logic [7:0] gm9_mb2, gm11_mb2, gm13_mb2, gm14_mb2; - logic [7:0] gm9_mb3, gm11_mb3, gm13_mb3, gm14_mb3; + assign {in0, in1, in2, in3} = in; + assign temp = in0 ^ in1 ^ in2 ^ in3; - // Break up word into 1 byte slices - assign b0 = word[31:24]; - assign b1 = word[23:16]; - assign b2 = word[15:8]; - assign b3 = word[7:0]; - - // mb0 Galois components - gm9 gm9_0(.gm9_In(b1), .gm9_Out(gm9_mb0)); - gm11 gm11_0(.gm11_In(b3), .gm11_Out(gm11_mb0)); - gm13 gm13_0(.gm13_In(b2), .gm13_Out(gm13_mb0)); - gm14 gm14_0(.gm14_In(b0), .gm14_Out(gm14_mb0)); + assign xor0 = {temp, 3'b0} ^ {1'b0, in3^in1, 2'b0} ^ {2'b0, in3^in2, 1'b0} ^ {3'b0, temp} ^ {3'b0, in3}; + assign xor1 = {temp, 3'b0} ^ {1'b0, in2^in0, 2'b0} ^ {2'b0, in2^in1, 1'b0} ^ {3'b0, temp} ^ {3'b0, in2}; + assign xor2 = {temp, 3'b0} ^ {1'b0, in1^in3, 2'b0} ^ {2'b0, in1^in0, 1'b0} ^ {3'b0, temp} ^ {3'b0, in1}; + assign xor3 = {temp, 3'b0} ^ {1'b0, in0^in2, 2'b0} ^ {2'b0, in0^in3, 1'b0} ^ {3'b0, temp} ^ {3'b0, in0}; - // mb1 Galois components - gm9 gm9_1(.gm9_In(b2), .gm9_Out(gm9_mb1)); - gm11 gm11_1(.gm11_In(b0), .gm11_Out(gm11_mb1)); - gm13 gm13_1(.gm13_In(b3), .gm13_Out(gm13_mb1)); - gm14 gm14_1(.gm14_In(b1), .gm14_Out(gm14_mb1)); - - // mb2 Galois components - gm9 gm9_2(.gm9_In(b3), .gm9_Out(gm9_mb2)); - gm11 gm11_2(.gm11_In(b1), .gm11_Out(gm11_mb2)); - gm13 gm13_2(.gm13_In(b0), .gm13_Out(gm13_mb2)); - gm14 gm14_2(.gm14_In(b2), .gm14_Out(gm14_mb2)); - - // mb3 Galois components - gm9 gm9_3(.gm9_In(b0), .gm9_Out(gm9_mb3)); - gm11 gm11_3(.gm11_In(b2), .gm11_Out(gm11_mb3)); - gm13 gm13_3(.gm13_In(b1), .gm13_Out(gm13_mb3)); - gm14 gm14_3(.gm14_In(b3), .gm14_Out(gm14_mb3)); + galoismult_inverse gm0 (xor0, out[7:0]); + galoismult_inverse gm1 (xor1, out[15:8]); + galoismult_inverse gm2 (xor2, out[23:16]); + galoismult_inverse gm3 (xor3, out[31:24]); - // XOR Galois components and assign output - assign mb0 = gm9_mb0 ^ gm11_mb0 ^ gm13_mb0 ^ gm14_mb0; - assign mb1 = gm9_mb1 ^ gm11_mb1 ^ gm13_mb1 ^ gm14_mb1; - assign mb2 = gm9_mb2 ^ gm11_mb2 ^ gm13_mb2 ^ gm14_mb2; - assign mb3 = gm9_mb3 ^ gm11_mb3 ^ gm13_mb3 ^ gm14_mb3; - assign mixed_word = {mb0, mb1, mb2, mb3}; - -endmodule // inv_mixword +endmodule \ No newline at end of file diff --git a/src/ieu/aes_common/aes_mixcolumns.sv b/src/ieu/aes_common/aes_mixcolumns.sv index f33a16880..54f0c4d14 100644 --- a/src/ieu/aes_common/aes_mixcolumns.sv +++ b/src/ieu/aes_common/aes_mixcolumns.sv @@ -29,7 +29,6 @@ module aes_mixcolumns(input logic [31:0] in, output logic [31:0] out); logic [7:0] in0, in1, in2, in3, out0, out1, out2, out3, t0, t1, t2, t3, temp; - logic [15:0] rrot8_1, rrot8_2; assign {in0, in1, in2, in3} = in; assign temp = in0 ^ in1 ^ in2 ^ in3; diff --git a/src/ieu/aes_common/galoismult_forward.sv b/src/ieu/aes_common/galoismult_forward.sv index ea6d8d011..b7c855188 100644 --- a/src/ieu/aes_common/galoismult_forward.sv +++ b/src/ieu/aes_common/galoismult_forward.sv @@ -25,7 +25,7 @@ // and limitations under the License. //////////////////////////////////////////////////////////////////////////////////////////////// -module galoismult_forward(input logic [7:0] in, output logic [7:0] out); +module galoismult_forward(input logic [7:0] in, output logic [7:0] out); logic [7:0] leftshift; diff --git a/src/ieu/aes_common/gm2.sv b/src/ieu/aes_common/galoismult_inverse.sv similarity index 74% rename from src/ieu/aes_common/gm2.sv rename to src/ieu/aes_common/galoismult_inverse.sv index 527340337..fda3bbcb9 100644 --- a/src/ieu/aes_common/gm2.sv +++ b/src/ieu/aes_common/galoismult_inverse.sv @@ -1,7 +1,7 @@ /////////////////////////////////////////// -// gm2.sv +// galoismult_inverse.sv // -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu, David_Harris@hmc.edu +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu // Created: 20 February 2024 // // Purpose: Galois field operations for mix columns operation @@ -25,12 +25,12 @@ // and limitations under the License. //////////////////////////////////////////////////////////////////////////////////////////////// -module gm2 (gm2_In, gm2_Out); - - input logic [7:0] gm2_In; - output logic [7:0] gm2_Out; - - // Set output to Galois Mult 2 - assign gm2_Out = {gm2_In[6:0], 1'b0} ^ (8'h1b & {8{gm2_In[7]}}); - -endmodule +module galoismult_inverse(input logic [10:0] in, output logic [7:0] out); + + logic [7:0] temp0, temp1; + + assign temp0 = in[8] ? (in[7:0] ^ 8'b00011011) : in[7:0]; + assign temp1 = in[9] ? (temp0 ^ 8'b00110110) : temp0; + assign out = in[10] ? (temp1 ^ 8'b01101100) : temp1; + +endmodule diff --git a/src/ieu/aes_common/gm11.sv b/src/ieu/aes_common/gm11.sv deleted file mode 100644 index aa9f96754..000000000 --- a/src/ieu/aes_common/gm11.sv +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////// -// gm11.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm11(gm11_In, gm11_Out); - - input logic [7:0] gm11_In; - output logic [7:0] gm11_Out; - - // Internal Logic - logic [7:0] gm8_0_Out; - logic [7:0] gm2_0_Out; - - // Sub-Modules for sub-Galois operations - gm8 gm8_0 (.gm8_In(gm11_In), .gm8_Out(gm8_0_Out)); - gm2 gm2_0 (.gm2_In(gm11_In), .gm2_Out(gm2_0_Out)); - - // Set output to gm8(in) ^ gm2(in) ^ in - assign gm11_Out = gm8_0_Out ^ gm2_0_Out ^ gm11_In; - -endmodule diff --git a/src/ieu/aes_common/gm13.sv b/src/ieu/aes_common/gm13.sv deleted file mode 100644 index de4cf3911..000000000 --- a/src/ieu/aes_common/gm13.sv +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////// -// gm13.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm13(gm13_In, gm13_Out); - - input logic [7:0] gm13_In; - output logic [7:0] gm13_Out; - - // Internal Logic - logic [7:0] gm8_0_Out; - logic [7:0] gm4_0_Out; - - // Sub-Modules for sub-Galois operations - gm8 gm8_0 (.gm8_In(gm13_In), .gm8_Out(gm8_0_Out)); - gm4 gm4_0 (.gm4_In(gm13_In), .gm4_Out(gm4_0_Out)); - - // Set output to gm8(in) ^ gm4(in) ^ in - assign gm13_Out = gm8_0_Out ^ gm4_0_Out ^ gm13_In; - -endmodule diff --git a/src/ieu/aes_common/gm14.sv b/src/ieu/aes_common/gm14.sv deleted file mode 100644 index 1a8b77d93..000000000 --- a/src/ieu/aes_common/gm14.sv +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////// -// gm14.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm14(gm14_In, gm14_Out); - - input logic [7:0] gm14_In; - output logic [7:0] gm14_Out; - - // Internal Logic - logic [7:0] gm8_0_Out; - logic [7:0] gm4_0_Out; - logic [7:0] gm2_0_Out; - - // Sub-Modules for sub-Galois operations - gm8 gm8_0 (.gm8_In(gm14_In), .gm8_Out(gm8_0_Out)); - gm4 gm4_0 (.gm4_In(gm14_In), .gm4_Out(gm4_0_Out)); - gm2 gm2_0 (.gm2_In(gm14_In), .gm2_Out(gm2_0_Out)); - - //Assign output to gm8(in) ^ gm4(in) ^ gm2(in) - assign gm14_Out = gm8_0_Out ^ gm4_0_Out ^ gm2_0_Out; - -endmodule - diff --git a/src/ieu/aes_common/gm3.sv b/src/ieu/aes_common/gm3.sv deleted file mode 100644 index 009519f99..000000000 --- a/src/ieu/aes_common/gm3.sv +++ /dev/null @@ -1,42 +0,0 @@ -/////////////////////////////////////////// -// gm3.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm3(gm3_In, gm3_Out); - - input logic [7:0] gm3_In; - output logic [7:0] gm3_Out; - - // Internal Logic - logic [7:0] gm2_0_Out; - - // Sub-Modules for gm2 multiplication - gm2 gm2_0 (.gm2_In(gm3_In), .gm2_Out(gm2_0_Out)); - - // Assign Output - assign gm3_Out = gm2_0_Out ^ gm3_In; - -endmodule diff --git a/src/ieu/aes_common/gm4.sv b/src/ieu/aes_common/gm4.sv deleted file mode 100644 index f2e5a41e4..000000000 --- a/src/ieu/aes_common/gm4.sv +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////// -// gm4.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm4(gm4_In, gm4_Out); - - input logic [7:0] gm4_In; - output logic [7:0] gm4_Out; - - // Internal Logic - logic [7:0] gm2_0_Out; - logic [7:0] gm2_1_Out; - - // Sub-Modules for multiple gm2 multiplications - gm2 gm2_0 (.gm2_In(gm4_In), .gm2_Out(gm2_0_Out)); - gm2 gm2_1 (.gm2_In(gm2_0_Out), .gm2_Out(gm2_1_Out)); - - // Assign output to second gm2 output - assign gm4_Out = gm2_1_Out; - -endmodule diff --git a/src/ieu/aes_common/gm8.sv b/src/ieu/aes_common/gm8.sv deleted file mode 100644 index 159022854..000000000 --- a/src/ieu/aes_common/gm8.sv +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////// -// gm8.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm8(gm8_In, gm8_Out); - - input logic [7:0] gm8_In; - output logic [7:0] gm8_Out; - - // Internal Logic - logic [7:0] gm2_0_Out; - logic [7:0] gm4_0_Out; - - // Sub-Modules for sub-Galois operations - gm4 gm4_0 (.gm4_In(gm8_In), .gm4_Out(gm4_0_Out)); - gm2 gm2_0 (.gm2_In(gm4_0_Out), .gm2_Out(gm2_0_Out)); - - // Assign output to gm2 output - assign gm8_Out = gm2_0_Out; - -endmodule diff --git a/src/ieu/aes_common/gm9.sv b/src/ieu/aes_common/gm9.sv deleted file mode 100644 index c53f23e6f..000000000 --- a/src/ieu/aes_common/gm9.sv +++ /dev/null @@ -1,42 +0,0 @@ -/////////////////////////////////////////// -// gm9.sv -// -// Written: ryan.swann@okstate.edu, james.stine@okstate.edu -// Created: 20 February 2024 -// -// Purpose: Galois field operations for mix columns operation -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// https://github.com/openhwgroup/cvw -// -// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -module gm9(gm9_In, gm9_Out); - - input logic [7:0] gm9_In; - output logic [7:0] gm9_Out; - - // Internal Logic - logic [7:0] gm8_0_Out; - - // Sub-Modules for sub-Galois operations - gm8 gm8_0 (.gm8_In(gm9_In), .gm8_Out(gm8_0_Out)); - - // Set output to gm8(in) ^ in - assign gm9_Out = gm8_0_Out ^ gm9_In; - -endmodule diff --git a/src/ieu/aes_instructions/aes32dsi.sv b/src/ieu/aes_instructions/aes32dsi.sv index ab52d1d96..b54a68d27 100644 --- a/src/ieu/aes_instructions/aes32dsi.sv +++ b/src/ieu/aes_instructions/aes32dsi.sv @@ -46,7 +46,7 @@ module aes32dsi(input logic [1:0] bs, assign Sbox_In = Sbox_In_32[7:0]; // Apply inverse sbox to si - aes_Inv_Sbox inv_sbox(.in(Sbox_In), .out(Sbox_Out)); + aes_inv_sbox inv_sbox(.in(Sbox_In), .out(Sbox_Out)); // Pad output of inverse substitution box assign so = {24'h0, Sbox_Out}; diff --git a/src/ieu/aes_instructions/aes32dsmi.sv b/src/ieu/aes_instructions/aes32dsmi.sv index 6374cab8c..dcb8d327b 100644 --- a/src/ieu/aes_instructions/aes32dsmi.sv +++ b/src/ieu/aes_instructions/aes32dsmi.sv @@ -47,13 +47,13 @@ module aes32dsmi(input logic [1:0] bs, assign Sbox_In = Sbox_In_32[7:0]; // Apply inverse sbox to si - aes_Inv_Sbox inv_sbox(.in(Sbox_In), .out(Sbox_Out)); + aes_inv_sbox inv_sbox(.in(Sbox_In), .out(Sbox_Out)); // Pad output of inverse substitution box assign so = {24'h0, Sbox_Out}; // Run so through the mixword AES function - aes_Inv_Mixcolumns mix(.word(so), .mixed_word(mixed)); + aes_inv_mixcolumns mix(.in(so), .out(mixed)); // Rotate the substitution box output left by shamt (bs * 8) assign mixed_rotate = (mixed << shamt) | (mixed >> (32 - shamt)); diff --git a/src/ieu/aes_instructions/aes32esi.sv b/src/ieu/aes_instructions/aes32esi.sv index c1adb4e93..1d54de585 100644 --- a/src/ieu/aes_instructions/aes32esi.sv +++ b/src/ieu/aes_instructions/aes32esi.sv @@ -48,7 +48,7 @@ module aes32esi(input logic [1:0] bs, assign Sbox_In = Sbox_In_32[7:0]; // Substitute - aes_Sbox subbox(.in(Sbox_In), .out(Sbox_Out)); + aes_sbox subbox(.in(Sbox_In), .out(Sbox_Out)); // Pad sbox output assign so = {24'h0, Sbox_Out}; diff --git a/src/ieu/aes_instructions/aes32esmi.sv b/src/ieu/aes_instructions/aes32esmi.sv index 53550c921..88277a37d 100644 --- a/src/ieu/aes_instructions/aes32esmi.sv +++ b/src/ieu/aes_instructions/aes32esmi.sv @@ -49,13 +49,13 @@ module aes32esmi(input logic [1:0] bs, assign Sbox_In = Sbox_In_32[7:0]; // Substitute - aes_Sbox sbox(.in(Sbox_In), .out(Sbox_Out)); + aes_sbox sbox(.in(Sbox_In), .out(Sbox_Out)); // Pad sbox output assign so = {24'h0, Sbox_Out}; // Mix Word using aes_mixword component - aes_Mixcolumns mwd(.in(so), .out(mixed)); + aes_mixcolumns mwd(.in(so), .out(mixed)); // Rotate so left by shamt assign mixed_rotate = (mixed << shamt) | (mixed >> (32 - shamt)); diff --git a/src/ieu/aes_instructions/aes64ds.sv b/src/ieu/aes_instructions/aes64ds.sv index 44f6717b8..275d5b43c 100644 --- a/src/ieu/aes_instructions/aes64ds.sv +++ b/src/ieu/aes_instructions/aes64ds.sv @@ -35,11 +35,11 @@ module aes64ds(input logic [63:0] rs1, logic [31:0] Sbox_Out_1; // Apply inverse shiftrows to rs2 and rs1 - aes_Inv_Shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); + aes_inv_shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); // Apply full word inverse substitution to lower 2 words of shiftrow out - aes_Inv_Sbox_Word inv_sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out_0)); - aes_Inv_Sbox_Word inv_sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out_1)); + aes_inv_sbox_word inv_sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out_0)); + aes_inv_sbox_word inv_sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out_1)); // Concatenate the two substitution outputs to get result assign Data_Out = {Sbox_Out_1, Sbox_Out_0}; diff --git a/src/ieu/aes_instructions/aes64dsm.sv b/src/ieu/aes_instructions/aes64dsm.sv index c9f538358..4695d42cc 100644 --- a/src/ieu/aes_instructions/aes64dsm.sv +++ b/src/ieu/aes_instructions/aes64dsm.sv @@ -37,15 +37,15 @@ module aes64dsm(input logic [63:0] rs1, logic [31:0] Mixcol_Out_1; // Apply inverse shiftrows to rs2 and rs1 - aes_Inv_Shiftrow srow(.DataIn({rs2, rs1}), .DataOut(ShiftRow_Out)); + aes_inv_shiftrow srow(.DataIn({rs2, rs1}), .DataOut(ShiftRow_Out)); // Apply full word inverse substitution to lower 2 words of shiftrow out - aes_Inv_Sbox_Word inv_sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out_0)); - aes_Inv_Sbox_Word inv_sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out_1)); + aes_inv_sbox_word inv_sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out_0)); + aes_inv_sbox_word inv_sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out_1)); // Apply inverse mixword to sbox outputs - aes_Inv_Mixcolumns inv_mw_0(.word(Sbox_Out_0), .mixed_word(Mixcol_Out_0)); - aes_Inv_Mixcolumns inv_mw_1(.word(Sbox_Out_1), .mixed_word(Mixcol_Out_1)); + aes_inv_mixcolumns inv_mw_0(.in(Sbox_Out_0), .out(Mixcol_Out_0)); + aes_inv_mixcolumns inv_mw_1(.in(Sbox_Out_1), .out(Mixcol_Out_1)); // Concatenate mixed words for output assign Data_Out = {Mixcol_Out_1, Mixcol_Out_0}; diff --git a/src/ieu/aes_instructions/aes64es.sv b/src/ieu/aes_instructions/aes64es.sv index 363a1ab2c..58e6dfdc0 100644 --- a/src/ieu/aes_instructions/aes64es.sv +++ b/src/ieu/aes_instructions/aes64es.sv @@ -33,9 +33,9 @@ module aes64es(input logic [63:0] rs1, logic [127:0] ShiftRow_Out; // AES shiftrow unit - aes_Shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); + aes_shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); // Apply substitution box to 2 lower words - aes_Sbox_Word sbox_0(.in(ShiftRow_Out[31:0]), .out(Data_Out[31:0])); - aes_Sbox_Word sbox_1(.in(ShiftRow_Out[63:32]), .out(Data_Out[63:32])); + aes_sbox_word sbox_0(.in(ShiftRow_Out[31:0]), .out(Data_Out[31:0])); + aes_sbox_word sbox_1(.in(ShiftRow_Out[63:32]), .out(Data_Out[63:32])); endmodule diff --git a/src/ieu/aes_instructions/aes64esm.sv b/src/ieu/aes_instructions/aes64esm.sv index 3b10df582..0e3fd0d56 100644 --- a/src/ieu/aes_instructions/aes64esm.sv +++ b/src/ieu/aes_instructions/aes64esm.sv @@ -34,13 +34,13 @@ module aes64esm(input logic [63:0] rs1, logic [63:0] Sbox_Out; // AES shiftrow unit - aes_Shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); + aes_shiftrow srow(.DataIn({rs2,rs1}), .DataOut(ShiftRow_Out)); // Apply substitution box to 2 lower words - aes_Sbox_Word sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out[31:0])); - aes_Sbox_Word sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out[63:32])); + aes_sbox_word sbox_0(.in(ShiftRow_Out[31:0]), .out(Sbox_Out[31:0])); + aes_sbox_word sbox_1(.in(ShiftRow_Out[63:32]), .out(Sbox_Out[63:32])); // Apply mix columns operations - aes_Mixcolumns mw0(.in(Sbox_Out[31:0]), .out(Data_Out[31:0])); - aes_Mixcolumns mw1(.in(Sbox_Out[63:32]), .out(Data_Out[63:32])); + aes_mixcolumns mw0(.in(Sbox_Out[31:0]), .out(Data_Out[31:0])); + aes_mixcolumns mw1(.in(Sbox_Out[63:32]), .out(Data_Out[63:32])); endmodule diff --git a/src/ieu/aes_instructions/aes64im.sv b/src/ieu/aes_instructions/aes64im.sv index 06c8c8ebf..d4b7f12bb 100644 --- a/src/ieu/aes_instructions/aes64im.sv +++ b/src/ieu/aes_instructions/aes64im.sv @@ -28,6 +28,6 @@ module aes64im(input logic [63:0] rs1, output logic [63:0] Data_Out); - aes_Inv_Mixcolumns inv_mw_0(.word(rs1[31:0]), .mixed_word(Data_Out[31:0])); - aes_Inv_Mixcolumns inv_mw_1(.word(rs1[63:32]), .mixed_word(Data_Out[63:32])); + aes_inv_mixcolumns inv_mw_0(.in(rs1[31:0]), .out(Data_Out[31:0])); + aes_inv_mixcolumns inv_mw_1(.in(rs1[63:32]), .out(Data_Out[63:32])); endmodule diff --git a/src/ieu/aes_instructions/aes64ks1i.sv b/src/ieu/aes_instructions/aes64ks1i.sv index 7336fcd10..a8b44c3e5 100644 --- a/src/ieu/aes_instructions/aes64ks1i.sv +++ b/src/ieu/aes_instructions/aes64ks1i.sv @@ -53,7 +53,7 @@ module aes64ks1i(input logic [3:0] roundnum, assign tmp2 = lastRoundFlag ? rs1[63:32] : rs1_rotate; // Substitute bytes of value obtained for tmp2 using Rijndael sbox - aes_Sbox_Word sbox(.in(tmp2),.out(Sbox_Out)); + aes_sbox_word sbox(.in(tmp2),.out(Sbox_Out)); assign rd[31:0] = Sbox_Out ^ rcon; assign rd[63:32] = Sbox_Out ^ rcon;