aboutsummaryrefslogtreecommitdiff
path: root/src/rtl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rtl')
-rw-r--r--src/rtl/keywrap_mkmif.v142
1 files changed, 92 insertions, 50 deletions
diff --git a/src/rtl/keywrap_mkmif.v b/src/rtl/keywrap_mkmif.v
index 88af6f8..2f7bebf 100644
--- a/src/rtl/keywrap_mkmif.v
+++ b/src/rtl/keywrap_mkmif.v
@@ -63,13 +63,16 @@ module keywrap_mkmif (
//----------------------------------------------------------------
// Paramenters and local defines.
//----------------------------------------------------------------
- localparam CTRL_IDLE = 3'h0;
- localparam CTRL_WAIT = 3'h1;
- localparam CTRL_READ_STATUS_WAIT = 3'h2;
- localparam CTRL_READ_KEY = 3'h3;
- localparam CTRL_READ_KEY_WAIT = 3'h4;
- localparam CTRL_WRITE_KEY = 3'h5;
- localparam CTRL_WRITE_KEY_WAIT = 3'h6;
+ localparam CTRL_IDLE = 4'h0;
+ localparam CTRL_WAIT = 4'h1;
+ localparam CTRL_INIT = 4'h2;
+ localparam CTRL_READ = 4'h3;
+ localparam CTRL_READ_STATUS_WAIT = 4'h4;
+ localparam CTRL_READ_KEY = 4'h5;
+ localparam CTRL_READ_KEY_WAIT = 4'h6;
+ localparam CTRL_WRITE = 4'h8;
+ localparam CTRL_WRITE_KEY = 4'h9;
+ localparam CTRL_WRITE_KEY_WAIT = 4'ha;
// Addresses for storage in the mkm
localparam MKM_STATUS_WORD = 16'h00;
@@ -106,10 +109,14 @@ module keywrap_mkmif (
reg ready_new;
reg ready_we;
- reg [2 : 0] keywrap_mkmif_ctrl_reg;
- reg [2 : 0] keywrap_mkmif_ctrl_new;
+ reg [3 : 0] keywrap_mkmif_ctrl_reg;
+ reg [3 : 0] keywrap_mkmif_ctrl_new;
reg keywrap_mkmif_ctrl_we;
+ reg init_op_reg;
+ reg read_op_reg;
+ reg write_op_reg;
+
//----------------------------------------------------------------
// Wires.
@@ -136,9 +143,9 @@ module keywrap_mkmif (
.spi_do(mkm_spi_do),
.spi_di(mkm_spi_di),
- .init_op(mkm_init_op),
- .read_op(mkm_read_op),
- .write_op(mkm_write_op),
+ .init_op(init_op_reg),
+ .read_op(read_op_reh),
+ .write_op(write_op_reg),
.ready(mkm_ready),
.valid(mkm_valid),
@@ -178,11 +185,18 @@ module keywrap_mkmif (
mkm_addr_reg <= 16'h0;
mkm_write_data_reg <= 32'h0;
key_word_ctr_reg <= 3'h0;
+ init_op_reg <= 1'h0;
+ read_op_reg <= 1'h0;
+ write_op_reg <= 1'h0;
keywrap_mkmif_ctrl_reg <= CTRL_IDLE;
end
else
begin
+ init_op_reg <= mkm_init_op;
+ read_op_reg <= mkm_read_op;
+ write_op_reg <= mkm_write_op;
+
if (ready_we)
ready_reg <= ready_new;
@@ -259,52 +273,50 @@ module keywrap_mkmif (
mkm_init_op = 1'h1;
ready_new = 1'h0;
ready_we = 1'h1;
- keywrap_mkmif_ctrl_new = CTRL_WAIT;
+ keywrap_mkmif_ctrl_new = CTRL_INIT;
keywrap_mkmif_ctrl_we = 1'h1;
end
if (read)
begin
- ready_new = 1'h0;
- ready_we = 1'h1;
-
- if (key_status)
- begin
- key_word_ctr_rst = 1'h1;
- keywrap_mkmif_ctrl_new = CTRL_READ_KEY;
- keywrap_mkmif_ctrl_we = 1'h1;
- end
- else
- begin
- mkm_read_op = 1'h1;
- mkm_addr_new = MKM_STATUS_WORD;
- mkm_addr_we = 1'h1;
- keywrap_mkmif_ctrl_new = CTRL_READ_STATUS_WAIT;
- keywrap_mkmif_ctrl_we = 1'h1;
- end
+ ready_new = 1'h0;
+ ready_we = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_READ;
+ keywrap_mkmif_ctrl_we = 1'h1;
end
if (write)
begin
- ready_new = 1'h0;
- ready_we = 1'h1;
-
- if (key_status)
- begin
- key_word_ctr_rst = 1'h1;
- keywrap_mkmif_ctrl_new = CTRL_WRITE_KEY;
- keywrap_mkmif_ctrl_we = 1'h1;
- end
- else
- begin
- mkm_write_op = 1'h1;
- mkm_addr_new = MKM_STATUS_WORD;
- mkm_addr_we = 1'h1;
- mkm_write_data_new = wr_status;
- mkm_write_data_we = 1'h1;
- keywrap_mkmif_ctrl_new = CTRL_WAIT;
- keywrap_mkmif_ctrl_we = 1'h1;
- end
+ ready_new = 1'h0;
+ ready_we = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_WRITE;
+ keywrap_mkmif_ctrl_we = 1'h1;
+ end
+ end
+
+
+ CTRL_INIT:
+ begin
+ keywrap_mkmif_ctrl_new = CTRL_WAIT;
+ keywrap_mkmif_ctrl_we = 1'h1;
+ end
+
+
+ CTRL_READ:
+ begin
+ if (key_status)
+ begin
+ key_word_ctr_rst = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_READ_KEY;
+ keywrap_mkmif_ctrl_we = 1'h1;
+ end
+ else
+ begin
+ mkm_read_op = 1'h1;
+ mkm_addr_new = MKM_STATUS_WORD;
+ mkm_addr_we = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_READ_STATUS_WAIT;
+ keywrap_mkmif_ctrl_we = 1'h1;
end
end
@@ -320,8 +332,13 @@ module keywrap_mkmif (
end
end
+
CTRL_READ_STATUS_WAIT:
begin
+ ready_new = 1'h1;
+ ready_we = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_IDLE;
+ keywrap_mkmif_ctrl_we = 1'h1;
if (mkm_ready)
begin
status_we = 1'h1;
@@ -332,6 +349,7 @@ module keywrap_mkmif (
end
end
+
CTRL_READ_KEY:
begin
if (key_word_ctr_reg < 8)
@@ -351,6 +369,7 @@ module keywrap_mkmif (
end
end
+
CTRL_READ_KEY_WAIT:
begin
if (mkm_ready)
@@ -362,6 +381,28 @@ module keywrap_mkmif (
end
end
+
+ CTRL_WRITE:
+ begin
+ if (key_status)
+ begin
+ key_word_ctr_rst = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_WRITE_KEY;
+ keywrap_mkmif_ctrl_we = 1'h1;
+ end
+ else
+ begin
+ mkm_write_op = 1'h1;
+ mkm_addr_new = MKM_STATUS_WORD;
+ mkm_addr_we = 1'h1;
+ mkm_write_data_new = wr_status;
+ mkm_write_data_we = 1'h1;
+ keywrap_mkmif_ctrl_new = CTRL_WAIT;
+ keywrap_mkmif_ctrl_we = 1'h1;
+ end
+ end
+
+
CTRL_WRITE_KEY:
begin
if (key_word_ctr_reg < 8)
@@ -383,6 +424,7 @@ module keywrap_mkmif (
end
end
+
CTRL_WRITE_KEY_WAIT:
begin
if (mkm_ready)
@@ -393,9 +435,9 @@ module keywrap_mkmif (
end
end
+
default:
begin
-
end
endcase // case (keywrap_mkmif_ctrl_reg)
end // keywrap_mkmif_ctrl