mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-03-12 18:16:55 -04:00
PoC: Automatically control system_mode in hardware
Instead of manually switching to app mode using the system mode register, app mode will be enabled when executing outside of firmware ROM. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
d36e9c9e3d
commit
2d762faba7
@ -107,6 +107,7 @@ 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 FW_ROM_LAST = 32'h000017ff;
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// Registers including update variables and write enable.
|
// Registers including update variables and write enable.
|
||||||
@ -115,6 +116,7 @@ module tk1 #(
|
|||||||
reg cdi_mem_we;
|
reg cdi_mem_we;
|
||||||
|
|
||||||
reg system_mode_reg;
|
reg system_mode_reg;
|
||||||
|
reg system_mode_new;
|
||||||
reg system_mode_we;
|
reg system_mode_we;
|
||||||
|
|
||||||
reg [ 2 : 0] led_reg;
|
reg [ 2 : 0] led_reg;
|
||||||
@ -291,7 +293,7 @@ module tk1 #(
|
|||||||
gpio2_reg[1] <= gpio2_reg[0];
|
gpio2_reg[1] <= gpio2_reg[0];
|
||||||
|
|
||||||
if (system_mode_we) begin
|
if (system_mode_we) begin
|
||||||
system_mode_reg <= 1'h1;
|
system_mode_reg <= system_mode_new;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (led_we) begin
|
if (led_we) begin
|
||||||
@ -412,12 +414,27 @@ module tk1 #(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
// system_mode_ctrl
|
||||||
|
//
|
||||||
|
// Automatically lower privilege when executing above ROM.
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
always @* begin : system_mode_ctrl
|
||||||
|
system_mode_new = 1'h0;
|
||||||
|
system_mode_we = 1'h0;
|
||||||
|
|
||||||
|
if (cpu_valid & cpu_instr) begin
|
||||||
|
if (cpu_addr > FW_ROM_LAST) begin
|
||||||
|
system_mode_new = 1'h1;
|
||||||
|
system_mode_we = 1'h1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// api
|
// api
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
always @* begin : api
|
always @* begin : api
|
||||||
system_mode_we = 1'h0;
|
|
||||||
led_we = 1'h0;
|
led_we = 1'h0;
|
||||||
gpio3_we = 1'h0;
|
gpio3_we = 1'h0;
|
||||||
gpio4_we = 1'h0;
|
gpio4_we = 1'h0;
|
||||||
@ -444,10 +461,6 @@ module tk1 #(
|
|||||||
if (cs) begin
|
if (cs) begin
|
||||||
tmp_ready = 1'h1;
|
tmp_ready = 1'h1;
|
||||||
if (we) begin
|
if (we) begin
|
||||||
if (address == ADDR_SYSTEM_MODE_CTRL) begin
|
|
||||||
system_mode_we = 1'h1;
|
|
||||||
end
|
|
||||||
|
|
||||||
if (address == ADDR_LED) begin
|
if (address == ADDR_LED) begin
|
||||||
led_we = 1'h1;
|
led_we = 1'h1;
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user