Skip to content

Commit

Permalink
ROM only executable in firmware mode, except for address of
Browse files Browse the repository at this point in the history
syscall_addr_reg

Co-authored-by: Mikael Ågren <[email protected]>
  • Loading branch information
dehanj and agren committed Nov 15, 2024
1 parent 507313b commit 5c1ce76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hw/application_fpga/core/tk1/rtl/tk1.v
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module tk1 (
localparam FW_RAM_FIRST = 32'hd0000000;
localparam FW_RAM_LAST = 32'hd00007ff;

localparam FW_ROM_FIRST = 32'h00000000;
localparam FW_ROM_LAST = 32'h00001fff;

// ILLEGAL_ADDR is outside of the physical memory, and will trap in
Expand Down Expand Up @@ -398,6 +399,9 @@ module tk1 (
//
// Trying to execute instructions in FW-RAM.
//
// Executing instructions in ROM, while not being in firmware
// mode, or at the address set in syscall_addr_reg.
//
// Trying to execute code in mem area set to be data access only.
// This requires execution monitor to have been setup and
// enabled.
Expand All @@ -415,6 +419,14 @@ module tk1 (
force_trap_set = 1'h1;
end

if (system_mode_reg) begin
if (cpu_addr != syscall_addr_reg) begin
if ((cpu_addr >= FW_ROM_FIRST) && (cpu_addr <= FW_ROM_LAST)) begin
force_trap_set = 1'h1;
end
end
end

if (cpu_mon_en_reg) begin
if ((cpu_addr >= cpu_mon_first_reg) && (cpu_addr <= cpu_mon_last_reg)) begin
force_trap_set = 1'h1;
Expand Down

0 comments on commit 5c1ce76

Please sign in to comment.