diff options
Diffstat (limited to 'src/rtl')
-rw-r--r-- | src/rtl/keywrap.v | 25 | ||||
-rw-r--r-- | src/rtl/keywrap_core.v | 22 |
2 files changed, 30 insertions, 17 deletions
diff --git a/src/rtl/keywrap.v b/src/rtl/keywrap.v index 54bc547..edfd8c3 100644 --- a/src/rtl/keywrap.v +++ b/src/rtl/keywrap.v @@ -74,8 +74,8 @@ module keywrap( localparam CTRL_KEYLEN_BIT = 1; localparam ADDR_RLEN = 8'h0c; - localparam ADDR_A_LSB = 8'h0e; - localparam ADDR_A_MSB = 8'h0f; + localparam ADDR_A0 = 8'h0e; + localparam ADDR_A1 = 8'h0f; localparam ADDR_KEY0 = 8'h10; localparam ADDR_KEY7 = 8'h17; @@ -133,6 +133,7 @@ module keywrap( wire core_ready; wire core_valid; wire [255 : 0] core_key; + wire [63 : 0] core_a; wire [31 : 0] core_api_rd_data; wire [63 : 0] core_a_result; @@ -146,6 +147,8 @@ module keywrap( assign core_key = {key_reg[0], key_reg[1], key_reg[2], key_reg[3], key_reg[4], key_reg[5], key_reg[6], key_reg[7]}; + assign core_a = {a0_reg, a1_reg}; + //---------------------------------------------------------------- // core instantiation. @@ -166,7 +169,7 @@ module keywrap( .key(core_key), .keylen(keylen_reg), - .a_init({a1_reg, a0_reg}), + .a_init(core_a), .a_result(core_a_result), .api_cs(api_cs_reg), @@ -244,8 +247,8 @@ module keywrap( key_we = 1'h0; api_cs_new = 1'h0; api_we_new = 1'h0; - a0_we = 1'h1; - a1_we = 1'h1; + a0_we = 1'h0; + a1_we = 1'h0; tmp_read_data = 32'h0; tmp_error = 1'h0; @@ -265,10 +268,10 @@ module keywrap( if (address == ADDR_RLEN) config_we = 1'h1; - if (address == ADDR_A_LSB) + if (address == ADDR_A0) a0_we = 1'h1; - if (address == ADDR_A_MSB) + if (address == ADDR_A1) a1_we = 1'h1; if ((address >= ADDR_KEY0) && (address <= ADDR_KEY7)) @@ -295,12 +298,12 @@ module keywrap( end endcase // case (address) - if (address == ADDR_A_LSB) - tmp_read_data = core_a_result[31 : 0]; - - if (address == ADDR_A_MSB) + if (address == ADDR_A0) tmp_read_data = core_a_result[63 : 32]; + if (address == ADDR_A1) + tmp_read_data = core_a_result[31 : 0]; + if (address == ADDR_READ_DATA) begin api_cs_new = 1'h1; diff --git a/src/rtl/keywrap_core.v b/src/rtl/keywrap_core.v index aa6f0df..d476152 100644 --- a/src/rtl/keywrap_core.v +++ b/src/rtl/keywrap_core.v @@ -79,10 +79,11 @@ module keywrap_core ( localparam CTRL_NEXT_START = 4'h4; localparam CTRL_NEXT_LOOP = 4'h5; - localparam CTRL_NEXT_WAIT = 4'h6; - localparam CTRL_NEXT_UPDATE = 4'h7; - localparam CTRL_NEXT_CHECK = 4'h8; - localparam CTRL_NEXT_FINALIZE = 4'h9; + localparam CTRL_NEXT_WAIT0 = 4'h6; + localparam CTRL_NEXT_WAIT = 4'h7; + localparam CTRL_NEXT_UPDATE = 4'h9; + localparam CTRL_NEXT_CHECK = 4'h9; + localparam CTRL_NEXT_FINALIZE = 4'ha; //---------------------------------------------------------------- @@ -195,8 +196,8 @@ module keywrap_core ( if (!reset_n) begin a_reg <= 64'h0; - ready_reg <= 1'h0; - valid_reg <= 1'h0; + ready_reg <= 1'h1; + valid_reg <= 1'h1; api_addr_ctr_reg <= 14'h0; block_ctr_reg <= 13'h0; iteration_ctr_reg <= 3'h0; @@ -386,6 +387,8 @@ module keywrap_core ( begin ready_new = 1'h0; ready_we = 1'h1; + valid_new = 1'h0; + valid_we = 1'h1; keywrap_core_ctrl_new = CTRL_NEXT_START; keywrap_core_ctrl_we = 1'h1; end @@ -430,6 +433,13 @@ module keywrap_core ( end + CTRL_NEXT_WAIT0: + begin + keywrap_core_ctrl_new = CTRL_NEXT_WAIT; + keywrap_core_ctrl_we = 1'h1; + end + + CTRL_NEXT_WAIT: begin if (aes_ready) |