From 8d0777b9f58efdc57fe9f2caa75b0ee6e2aae7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Mon, 21 May 2018 17:57:42 +0200 Subject: Moved the Sbox used for key expansion into the key_mem. --- src/rtl/aes_core.v | 7 +------ src/rtl/aes_key_mem.v | 18 ++++++++++-------- src/tb/tb_aes_key_mem.v | 11 +---------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/rtl/aes_core.v b/src/rtl/aes_core.v index 7c5720d..b74fdc4 100644 --- a/src/rtl/aes_core.v +++ b/src/rtl/aes_core.v @@ -154,15 +154,10 @@ module aes_core( .round(muxed_round_nr), .round_key(round_key), - .ready(key_ready), - - .sboxw(keymem_sboxw), - .new_sboxw(new_sboxw) + .ready(key_ready) ); - aes_sbox sbox_inst(.sboxw(keymem_sboxw), .new_sboxw(new_sboxw)); - //---------------------------------------------------------------- // Concurrent connectivity for ports etc. diff --git a/src/rtl/aes_key_mem.v b/src/rtl/aes_key_mem.v index 496fc08..e3aec4b 100644 --- a/src/rtl/aes_key_mem.v +++ b/src/rtl/aes_key_mem.v @@ -47,11 +47,7 @@ module aes_key_mem( input wire [3 : 0] round, output wire [127 : 0] round_key, - output wire ready, - - - output wire [31 : 0] sboxw, - input wire [31 : 0] new_sboxw + output wire ready ); @@ -109,7 +105,8 @@ module aes_key_mem( //---------------------------------------------------------------- // Wires. //---------------------------------------------------------------- - reg [31 : 0] tmp_sboxw; + reg [31 : 0] sboxw; + wire [31 : 0] new_sboxw; reg round_key_update; reg [3 : 0] num_rounds; @@ -122,7 +119,12 @@ module aes_key_mem( //---------------------------------------------------------------- assign round_key = tmp_round_key; assign ready = ready_reg; - assign sboxw = tmp_sboxw; + + + //---------------------------------------------------------------- + // S-box for key expansion. + //---------------------------------------------------------------- + aes_sbox sbox_inst(.sboxw(sboxw), .new_sboxw(new_sboxw)); //---------------------------------------------------------------- @@ -223,7 +225,7 @@ module aes_key_mem( w7 = prev_key1_reg[031 : 000]; rconw = {rcon_reg, 24'h0}; - tmp_sboxw = w7; + sboxw = w7; rotstw = {new_sboxw[23 : 00], new_sboxw[31 : 24]}; trw = rotstw ^ rconw; tw = new_sboxw; diff --git a/src/tb/tb_aes_key_mem.v b/src/tb/tb_aes_key_mem.v index cac216a..b76fb64 100644 --- a/src/tb/tb_aes_key_mem.v +++ b/src/tb/tb_aes_key_mem.v @@ -78,9 +78,6 @@ module tb_aes_key_mem(); wire [127 : 0] tb_round_key; wire tb_ready; - wire [31 : 0] tb_sboxw; - wire [31 : 0] tb_new_sboxw; - //---------------------------------------------------------------- // Device Under Test. @@ -95,15 +92,9 @@ module tb_aes_key_mem(); .round(tb_round), .round_key(tb_round_key), - .ready(tb_ready), - - .sboxw(tb_sboxw), - .new_sboxw(tb_new_sboxw) + .ready(tb_ready) ); - // The DUT requirees Sboxes. - aes_sbox sbox(.sboxw(tb_sboxw), .new_sboxw(tb_new_sboxw)); - //---------------------------------------------------------------- // clk_gen -- cgit v1.2.3