aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-10-23 10:50:22 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-10-23 10:50:22 +0200
commitaced6ee13af2d15ee0a9ccd8e681faf1519106ea (patch)
treef8a96f673f7f588e06b5d8483f90568b1cbad60f
parent4e1cb1dbf22b93bde1cf3d5214e47f22d3d21cdc (diff)
Hardened the keywrap API to not allow reads or writes when the core is busy.
-rw-r--r--src/rtl/keywrap.v55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/rtl/keywrap.v b/src/rtl/keywrap.v
index cc6f8ac..53deaaf 100644
--- a/src/rtl/keywrap.v
+++ b/src/rtl/keywrap.v
@@ -321,45 +321,48 @@ module keywrap #(parameter ADDR_BITS = 13)
api_rd_delay_new = 32'h0;
// api_mux
- if (address[(ADDR_BITS - 1)])
- tmp_read_data = core_api_rd_data;
- else
- tmp_read_data = api_rd_delay_reg;
+ if (core_ready)
+ if (address[(ADDR_BITS - 1)])
+ tmp_read_data = core_api_rd_data;
+ else
+ tmp_read_data = api_rd_delay_reg;
if (cs)
begin
if (we)
begin
- // Write access
- if (address == {{PAD{1'h0}}, ADDR_CTRL})
+ if (core_ready)
begin
- init_new = write_data[CTRL_INIT_BIT];
- next_new = write_data[CTRL_NEXT_BIT];
- read_new = write_data[CTRL_READ_BIT];
- write_new = write_data[CTRL_WRITE_BIT];
- end
+ if (address == {{PAD{1'h0}}, ADDR_CTRL})
+ begin
+ init_new = write_data[CTRL_INIT_BIT];
+ next_new = write_data[CTRL_NEXT_BIT];
+ read_new = write_data[CTRL_READ_BIT];
+ write_new = write_data[CTRL_WRITE_BIT];
+ end
- if (address == {{PAD{1'h0}}, ADDR_CONFIG})
- config_we = 1'h1;
+ if (address == {{PAD{1'h0}}, ADDR_CONFIG})
+ config_we = 1'h1;
- if (address == {{PAD{1'h0}}, ADDR_RLEN})
- rlen_we = 1'h1;
+ if (address == {{PAD{1'h0}}, ADDR_RLEN})
+ rlen_we = 1'h1;
- if (address == {{PAD{1'h0}}, ADDR_A0})
- a0_we = 1'h1;
+ if (address == {{PAD{1'h0}}, ADDR_A0})
+ a0_we = 1'h1;
- if (address == {{PAD{1'h0}}, ADDR_A1})
- a1_we = 1'h1;
+ if (address == {{PAD{1'h0}}, ADDR_A1})
+ a1_we = 1'h1;
- if (address == {{PAD{1'h0}}, ADDR_MSTATUS})
- mstatus_we = 1'h1;
+ if (address == {{PAD{1'h0}}, ADDR_MSTATUS})
+ mstatus_we = 1'h1;
- if ((address >= {{PAD{1'h0}}, ADDR_KEY0}) &&
- (address <= {{PAD{1'h0}}, ADDR_KEY7}))
- key_we = 1'h1;
+ if ((address >= {{PAD{1'h0}}, ADDR_KEY0}) &&
+ (address <= {{PAD{1'h0}}, ADDR_KEY7}))
+ key_we = 1'h1;
- if (address[(ADDR_BITS - 1)])
- core_api_we = 1'h1;
+ if (address[(ADDR_BITS - 1)])
+ core_api_we = 1'h1;
+ end
end // if (we)
else
begin