diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2018-07-05 09:58:39 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2018-07-05 09:58:39 +0200 |
commit | 6b15816bff4c0c3ab22bf6d8185da48a263f7727 (patch) | |
tree | 0679fd463f258dde0a56cb19fcb6256b4d3a695e /src/rtl | |
parent | 84164cf6ae48923dfd0bd8a4d818642cd39a4e93 (diff) |
Fixed memory word order. Fixed a number of bugs. First block encrypted correctly. A state is wrong and memory is read too far.
Diffstat (limited to 'src/rtl')
-rw-r--r-- | src/rtl/keywrap.v | 4 | ||||
-rw-r--r-- | src/rtl/keywrap_core.v | 18 | ||||
-rw-r--r-- | src/rtl/keywrap_mem.v | 2 |
3 files changed, 9 insertions, 15 deletions
diff --git a/src/rtl/keywrap.v b/src/rtl/keywrap.v index 3117f61..69295ed 100644 --- a/src/rtl/keywrap.v +++ b/src/rtl/keywrap.v @@ -287,7 +287,7 @@ module keywrap( if ((address >= ADDR_KEY0) && (address <= ADDR_KEY7)) key_we = 1'h1; - if (address <= ADDR_R_DATA0 && address <= ADDR_R_DATA127) + if (address >= ADDR_R_DATA0 && address <= ADDR_R_DATA127) core_api_we = 1'h1; end // if (we) @@ -320,7 +320,7 @@ module keywrap( if (address == ADDR_A1) tmp_read_data = core_a_result[31 : 0]; - if (address <= ADDR_R_DATA0 && address <= ADDR_R_DATA127) + if (address >= ADDR_R_DATA0 && address <= ADDR_R_DATA127) tmp_read_data = core_api_rd_data; end end diff --git a/src/rtl/keywrap_core.v b/src/rtl/keywrap_core.v index e7b7749..07a079b 100644 --- a/src/rtl/keywrap_core.v +++ b/src/rtl/keywrap_core.v @@ -127,6 +127,7 @@ module keywrap_core ( reg aes_init; reg aes_next; wire aes_ready; + wire aes_valid; reg [127 : 0] aes_block; wire [127 : 0] aes_result; @@ -170,7 +171,7 @@ module keywrap_core ( .ready(aes_ready), .result(aes_result), - .result_valid() + .result_valid(aes_valid) ); @@ -351,7 +352,10 @@ module keywrap_core ( ready_we = 1'h1; valid_new = 1'h0; valid_we = 1'h1; - keywrap_core_ctrl_new = CTRL_NEXT_START; + init_a = 1'h1; + block_ctr_rst = 1'h1; + iteration_ctr_rst = 1'h1; + keywrap_core_ctrl_new = CTRL_NEXT_LOOP; keywrap_core_ctrl_we = 1'h1; end end @@ -376,16 +380,6 @@ module keywrap_core ( end - CTRL_NEXT_START: - begin - init_a = 1'h1; - block_ctr_rst = 1'h1; - iteration_ctr_rst = 1'h1; - keywrap_core_ctrl_new = CTRL_NEXT_LOOP; - keywrap_core_ctrl_we = 1'h1; - end - - CTRL_NEXT_LOOP: begin aes_next = 1'h1; diff --git a/src/rtl/keywrap_mem.v b/src/rtl/keywrap_mem.v index d31c76c..dc08bab 100644 --- a/src/rtl/keywrap_mem.v +++ b/src/rtl/keywrap_mem.v @@ -81,7 +81,7 @@ module keywrap_mem ( // Assignments for ports. //---------------------------------------------------------------- assign api_rd_data = muxed_api_rd_data; - assign core_rd_data = {core_rd_data1, core_rd_data0}; + assign core_rd_data = {core_rd_data0, core_rd_data1}; //---------------------------------------------------------------- |