mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-10-01 01:45:38 -04:00
FPGA: Add CPU instruction address SPI access control
Add logic that checks if the CPU is reading an instruction to execute from ROM or not. If instructions are read from ROM, access to the SPI from the API is granted, and signals between the SPI master and a slave are allowed. If instructions are not read from ROM, any API access is blocked. and between the SPI master and a slave are disabled. Signed-off-by: Joachim Strömbergson <joachim@assured.se>
This commit is contained in:
parent
7f93b7817b
commit
f6fa5ae2f9
@ -109,6 +109,8 @@ module tk1(
|
|||||||
localparam FW_RAM_FIRST = 32'hd0000000;
|
localparam FW_RAM_FIRST = 32'hd0000000;
|
||||||
localparam FW_RAM_LAST = 32'hd00007ff;
|
localparam FW_RAM_LAST = 32'hd00007ff;
|
||||||
|
|
||||||
|
localparam ROM_PREFIX = 2'h0;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// Registers including update variables and write enable.
|
// Registers including update variables and write enable.
|
||||||
@ -162,6 +164,8 @@ module tk1(
|
|||||||
reg force_trap_reg;
|
reg force_trap_reg;
|
||||||
reg force_trap_set;
|
reg force_trap_set;
|
||||||
|
|
||||||
|
reg spi_access_ok;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// Wires.
|
// Wires.
|
||||||
@ -231,13 +235,13 @@ module tk1(
|
|||||||
.clk(clk),
|
.clk(clk),
|
||||||
.reset_n(reset_n),
|
.reset_n(reset_n),
|
||||||
|
|
||||||
.spi_ss(spi_ss),
|
.spi_ss((spi_ss & ~spi_access_ok)),
|
||||||
.spi_sck(spi_sck),
|
.spi_sck((spi_sck & spi_access_ok)),
|
||||||
.spi_mosi(spi_mosi),
|
.spi_mosi((spi_mosi & spi_access_ok)),
|
||||||
.spi_miso(spi_miso),
|
.spi_miso((spi_miso & spi_access_ok)),
|
||||||
|
|
||||||
.spi_enable(spi_enable),
|
.spi_enable((spi_enable & spi_access_ok)),
|
||||||
.spi_enable_vld(spi_enable_vld),
|
.spi_enable_vld((spi_enable_vld & spi_access_ok)),
|
||||||
.spi_start(spi_start),
|
.spi_start(spi_start),
|
||||||
.spi_tx_data(spi_tx_data),
|
.spi_tx_data(spi_tx_data),
|
||||||
.spi_tx_data_vld(spi_tx_data_vld),
|
.spi_tx_data_vld(spi_tx_data_vld),
|
||||||
@ -384,6 +388,23 @@ module tk1(
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
// spi_access_control
|
||||||
|
//
|
||||||
|
// Logic thar controls if any access to the SPI master is done
|
||||||
|
// by FW-code.
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
always @*
|
||||||
|
begin : spi_access_control
|
||||||
|
if ((cpu_valid & cpu_instr) & (cpu_addr[31 : 30] == ROM_PREFIX)) begin
|
||||||
|
spi_access_ok = 1'h1;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
spi_access_ok = 1'h0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// security_monitor
|
// security_monitor
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user