From aaadaee7f0b7eaa0bee70efcf2ec739c700219a1 Mon Sep 17 00:00:00 2001 From: Olof Kindgren Date: Wed, 4 Sep 2024 11:11:32 +0200 Subject: [PATCH] Make all functions automatic The automatic keyword makes a function reentrant and avoids warnings by some synthesis tools. --- src/rtl/aes_decipher_block.v | 24 ++++++++++++------------ src/rtl/aes_encipher_block.v | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rtl/aes_decipher_block.v b/src/rtl/aes_decipher_block.v index 3e016fb..1e6745c 100644 --- a/src/rtl/aes_decipher_block.v +++ b/src/rtl/aes_decipher_block.v @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/rtl/aes_encipher_block.v b/src/rtl/aes_encipher_block.v index a1b0954..da24c1c 100644 --- a/src/rtl/aes_encipher_block.v +++ b/src/rtl/aes_encipher_block.v @@ -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 @@ -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 @@ -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 @@ -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