Skip to content

Commit

Permalink
Merge pull request #11 from olofk/automatic
Browse files Browse the repository at this point in the history
Make all functions automatic
  • Loading branch information
secworks authored Oct 18, 2024
2 parents b9a3f19 + aaadaee commit 43050a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/rtl/aes_decipher_block.v
Original file line number Diff line number Diff line change
Expand Up @@ -80,55 +80,55 @@ module aes_decipher_block(
//----------------------------------------------------------------
// Gaolis multiplication functions for Inverse MixColumn.
//----------------------------------------------------------------
function [7 : 0] gm2(input [7 : 0] op);
function automatic [7 : 0] gm2(input [7 : 0] op);
begin
gm2 = {op[6 : 0], 1'b0} ^ (8'h1b & {8{op[7]}});
end
endfunction // gm2

function [7 : 0] gm3(input [7 : 0] op);
function automatic [7 : 0] gm3(input [7 : 0] op);
begin
gm3 = gm2(op) ^ op;
end
endfunction // gm3

function [7 : 0] gm4(input [7 : 0] op);
function automatic [7 : 0] gm4(input [7 : 0] op);
begin
gm4 = gm2(gm2(op));
end
endfunction // gm4

function [7 : 0] gm8(input [7 : 0] op);
function automatic [7 : 0] gm8(input [7 : 0] op);
begin
gm8 = gm2(gm4(op));
end
endfunction // gm8

function [7 : 0] gm09(input [7 : 0] op);
function automatic [7 : 0] gm09(input [7 : 0] op);
begin
gm09 = gm8(op) ^ op;
end
endfunction // gm09

function [7 : 0] gm11(input [7 : 0] op);
function automatic [7 : 0] gm11(input [7 : 0] op);
begin
gm11 = gm8(op) ^ gm2(op) ^ op;
end
endfunction // gm11

function [7 : 0] gm13(input [7 : 0] op);
function automatic [7 : 0] gm13(input [7 : 0] op);
begin
gm13 = gm8(op) ^ gm4(op) ^ op;
end
endfunction // gm13

function [7 : 0] gm14(input [7 : 0] op);
function automatic [7 : 0] gm14(input [7 : 0] op);
begin
gm14 = gm8(op) ^ gm4(op) ^ gm2(op);
end
endfunction // gm14

function [31 : 0] inv_mixw(input [31 : 0] w);
function automatic [31 : 0] inv_mixw(input [31 : 0] w);
reg [7 : 0] b0, b1, b2, b3;
reg [7 : 0] mb0, mb1, mb2, mb3;
begin
Expand All @@ -146,7 +146,7 @@ module aes_decipher_block(
end
endfunction // mixw

function [127 : 0] inv_mixcolumns(input [127 : 0] data);
function automatic [127 : 0] inv_mixcolumns(input [127 : 0] data);
reg [31 : 0] w0, w1, w2, w3;
reg [31 : 0] ws0, ws1, ws2, ws3;
begin
Expand All @@ -164,7 +164,7 @@ module aes_decipher_block(
end
endfunction // inv_mixcolumns

function [127 : 0] inv_shiftrows(input [127 : 0] data);
function automatic [127 : 0] inv_shiftrows(input [127 : 0] data);
reg [31 : 0] w0, w1, w2, w3;
reg [31 : 0] ws0, ws1, ws2, ws3;
begin
Expand All @@ -182,7 +182,7 @@ module aes_decipher_block(
end
endfunction // inv_shiftrows

function [127 : 0] addroundkey(input [127 : 0] data, input [127 : 0] rkey);
function automatic [127 : 0] addroundkey(input [127 : 0] data, input [127 : 0] rkey);
begin
addroundkey = data ^ rkey;
end
Expand Down
12 changes: 6 additions & 6 deletions src/rtl/aes_encipher_block.v
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ module aes_encipher_block(
//----------------------------------------------------------------
// Round functions with sub functions.
//----------------------------------------------------------------
function [7 : 0] gm2(input [7 : 0] op);
function automatic [7 : 0] gm2(input [7 : 0] op);
begin
gm2 = {op[6 : 0], 1'b0} ^ (8'h1b & {8{op[7]}});
end
endfunction // gm2

function [7 : 0] gm3(input [7 : 0] op);
function automatic [7 : 0] gm3(input [7 : 0] op);
begin
gm3 = gm2(op) ^ op;
end
endfunction // gm3

function [31 : 0] mixw(input [31 : 0] w);
function automatic [31 : 0] mixw(input [31 : 0] w);
reg [7 : 0] b0, b1, b2, b3;
reg [7 : 0] mb0, mb1, mb2, mb3;
begin
Expand All @@ -113,7 +113,7 @@ module aes_encipher_block(
end
endfunction // mixw

function [127 : 0] mixcolumns(input [127 : 0] data);
function automatic [127 : 0] mixcolumns(input [127 : 0] data);
reg [31 : 0] w0, w1, w2, w3;
reg [31 : 0] ws0, ws1, ws2, ws3;
begin
Expand All @@ -131,7 +131,7 @@ module aes_encipher_block(
end
endfunction // mixcolumns

function [127 : 0] shiftrows(input [127 : 0] data);
function automatic [127 : 0] shiftrows(input [127 : 0] data);
reg [31 : 0] w0, w1, w2, w3;
reg [31 : 0] ws0, ws1, ws2, ws3;
begin
Expand All @@ -149,7 +149,7 @@ module aes_encipher_block(
end
endfunction // shiftrows

function [127 : 0] addroundkey(input [127 : 0] data, input [127 : 0] rkey);
function automatic [127 : 0] addroundkey(input [127 : 0] data, input [127 : 0] rkey);
begin
addroundkey = data ^ rkey;
end
Expand Down

0 comments on commit 43050a1

Please sign in to comment.