Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl/core] make FIRQs level-triggered #176

Merged
merged 20 commits into from
Oct 9, 2021
Merged

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Oct 8, 2021

This PR is a makeover of the processor's fast interrupts (FIRQ) interrupt system.

Old Version (Current State)

The current version of the CPU uses an internal interrupt queue to store fast interrupt request from the processor-internal peripherals. Currently, these request are single-shot (high for exactly one cycle) and are stored in the CPU queue until acknowledge by the hardware (before executing the trap handler).

New Version (This PR)

The reworked version uses level-triggered FIRQs that behave like the standard RISC-V interrupt (i.e. the MTIME machine timer interrupt):

  • as soon as the interrupt conditions of a peripheral is met, the peripheral sets it's FIRQ line high
  • the FIRQ appears in the CPU mip (machine interrupt pending) register
  • the interrupt request stays pending until explicitly acknowledged by the software (just like the MTIME interrupt)
  • acknowledging is done by reading/writing a peripheral-specific memory-mapped register

💡 Goals

  • uniform interrupt handling for all interrupts
  • more straightforward definition of interrupt condition: an IRQ is pending - and will be executed again and again - as long as the according device is fulfilling it's interrupt condition (like a FIFO that is not at least half-full yet)
  • comply with RISC-V specs.
  • reduce area footprint

Affected peripheral devices

  • WDT (FIRQ 0)
  • CFS (FIRQ 1)
  • UART0 (FIRQ 2, 3)
  • UART1 (FIRQ 4, 5)
  • SPI (FIRQ 6)
  • TWI (FIRQ 7)
  • XIRQ (FIRQ 8)
  • NEOLED (FIRQ 9)
  • SLINK (FIRQ 10, 11)

⚠️ Backwards Compatibility

  • peripheral devices will send an interrupt request right after being enabled; for example: the SPI module will send a FIRQ as long as it is in idle state (waiting for the CPU to trigger a new transmission)
  • pending interrupts have to be explicitly acknowledged; the according mip bit will remain set until the interrupt request is cleared (clearing and re-enabling mie bits will not clear any pending IRQs anymore)

the CPU fast interrupt requests are now level-triggered and need to stay asserted until explicitly acknowledged by the CPU (by reading/writing specific memory-mapped registers in the IRQ-causing peripheral module)

-> to comply with the RISC-V priv. spec; especially the behavior of MIE and MIP CSRs
@stnolting stnolting added enhancement New feature or request risc-v compliance Modification to comply with official RISC-V specs. labels Oct 8, 2021
@stnolting stnolting marked this pull request as ready for review October 8, 2021 17:36
- console output edits
- procesor_check: test if PMP test fails because of locked PMP entry
- fixed minor issue in number of PMP entries evaluation
a debugger halt request will also resume CPU operation after it was send to sleep mode via 'wfi' instruction
a pending WDT interrupt is cleared by resetting the watchdog (or by disabling it)
@stnolting stnolting self-assigned this Oct 9, 2021
enable FIRQs only when they are actually relevant for evaluation
@stnolting stnolting merged commit f2a261c into master Oct 9, 2021
@stnolting stnolting deleted the firq_level_triggered branch October 9, 2021 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request risc-v compliance Modification to comply with official RISC-V specs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant