Skip to content

Commit

Permalink
[rtl] fix single-step halting (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting authored Apr 27, 2024
2 parents 57999a1 + de8b561 commit 49bc8be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mimpid = 0x01040312 -> Version 01.04.03.12 -> v1.4.3.12

| Date | Version | Comment | Ticket |
|:----:|:-------:|:--------|:------:|
| 27.04.2024 | 1.9.8.8 | fix delayed halt when single-stepping into an exception | [#887](https://github.com/stnolting/neorv32/pull/887) |
| 24.04.2024 | 1.9.8.7 | minor RTL fixes | [#883](https://github.com/stnolting/neorv32/pull/883) |
| 23.04.2024 | 1.9.8.6 | :bug: fix on-chip-debugger external-halt-request vs. exception concurrency | [#882](https://github.com/stnolting/neorv32/pull/882) |
| 21.04.2024 | 1.9.8.5 | rtl cleanups and (area) optimizations | [#880](https://github.com/stnolting/neorv32/pull/880) |
Expand Down
12 changes: 11 additions & 1 deletion rtl/core/neorv32_cpu_control.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ architecture neorv32_cpu_control_rtl of neorv32_cpu_control is
--
env_pending : std_ulogic; -- start of trap environment if pending
env_enter : std_ulogic; -- enter trap environment
env_entered : std_ulogic; -- trap environment has just been entered
env_exit : std_ulogic; -- leave trap environment
wakeup : std_ulogic; -- wakeup from sleep due to an enabled pending IRQ
--
Expand Down Expand Up @@ -1496,7 +1497,9 @@ begin
begin
if (rstn_i = '0') then
trap_ctrl.env_pending <= '0';
trap_ctrl.env_entered <= '0';
elsif rising_edge(clk_i) then
-- pending trap environment --
if (trap_ctrl.env_pending = '0') then -- no pending trap environment yet
if (trap_ctrl.exc_fire = '1') or (or_reduce_f(trap_ctrl.irq_fire) = '1') then
trap_ctrl.env_pending <= '1'; -- execute engine can start trap handling
Expand All @@ -1506,6 +1509,12 @@ begin
trap_ctrl.env_pending <= '0';
end if;
end if;
-- trap environment has just been entered --
if (execute_engine.state = EXECUTE) then -- first instruction of trap environment is executing
trap_ctrl.env_entered <= '0';
elsif (trap_ctrl.env_enter = '1') then
trap_ctrl.env_entered <= '1';
end if;
end if;
end process trap_controller;

Expand All @@ -1529,7 +1538,8 @@ begin

-- debug-entry single-step interrupt? --
trap_ctrl.irq_fire(2) <= '1' when
(execute_engine.state = EXECUTE) and -- trigger system IRQ only in EXECUTE state
((execute_engine.state = EXECUTE) or -- trigger single-step in EXECUTE state
((trap_ctrl.env_entered = '1') and (execute_engine.state = BRANCHED))) and -- also allow triggering when entering a system trap (#887)
(trap_ctrl.irq_buf(irq_db_step_c) = '1') -- pending single-step halt
else '0';

Expand Down
2 changes: 1 addition & 1 deletion rtl/core/neorv32_package.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package neorv32_package is

-- Architecture Constants -----------------------------------------------------------------
-- -------------------------------------------------------------------------------------------
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01090807"; -- hardware version
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01090808"; -- hardware version
constant archid_c : natural := 19; -- official RISC-V architecture ID
constant XLEN : natural := 32; -- native data path width

Expand Down

0 comments on commit 49bc8be

Please # to comment.