Skip to content

Commit

Permalink
🔨 Fixed issues with KeyExpansion
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedSobhy01 committed Apr 20, 2024
1 parent 075e114 commit 3e05df1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions KeyExpansion.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module KeyExpansionRound(roundCount, keyIn, keyOut);
wire [31:0] words[3:0];

generate
for (i = 0; i < 4; i = i + 1) begin
for (i = 0; i < 4; i = i + 1) begin: KeySplitLoop
assign words[i] = keyIn[127 - i * 32 -: 32];
end
endgenerate
Expand All @@ -22,8 +22,9 @@ module KeyExpansionRound(roundCount, keyIn, keyOut);
wire [31:0] w3Sub;

generate
for (i = 0; i < 4; i = i + 1)
for (i = 0; i < 4; i = i + 1) begin: SBoxLoop
SBox sBox(w3Rot[i * 8 +: 8], w3Sub[i * 8 +: 8]);
end
endgenerate

// Perform the XOR operation with the round constant (roundConstant)
Expand Down Expand Up @@ -53,14 +54,14 @@ endmodule

module KeyExpansion(keyIn, keysOut);
input [127:0] keyIn;
output [(11 * 128) - 1:0] keysOut;
output [(12 * 128) - 1:0] keysOut;

assign keysOut[127:0] = keyIn;

// Perform the key expansion rounds (KeyExpansionRound)
genvar i;
generate
for (i = 0; i < 12; i = i + 1) begin : KeyExpansionLoop
for (i = 0; i < 11; i = i + 1) begin : KeyExpansionLoop
KeyExpansionRound keyExpansionRound(i + 1, keysOut[127 + i * 128 -: 128], keysOut[255 + i * 128 -: 128]);
end
endgenerate
Expand Down

0 comments on commit 3e05df1

Please sign in to comment.