Exceptions and interrupts
An exception is an unexpected event from within the processor and caused by some instruction written within a program. We have caused the following RISCV exceptions to trigger:
Illegal instruction exception
is triggered when an unknown opcode is detected in any instruction.Load address misaligned exception
is triggered when data to be loaded is divided into two memory regions.Load access fault exception
is triggered when the address of data to be loaded is out of core internal memory.Store address misaligned exception
is triggered when data to be written is divided into two memory regions.Store access fault exception
is triggered when the address of data to be written is out of core internal memory.Ecall from M-mode exception
is simply triggered byecall
instruction.
An interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. We have implemented [internal timer interrupt](###Internal timer interrupt) for SweRV EH1
.
RISCV uses two CSRs mtime
and mtimecmp
for a timer interrupt. When value in mtime
is greater than the value of mtimecmp
. SweRV EH1
uses four CSRs mitcnt0/1
and mitb0/1
, whenever the value of mitcnt0/1
is greater than mitb0/1
.
We made changes in following files for this task:
- Updated already written exception handlers to go to the next instruction.
- Exception handlers were added for misaligned exceptions.
- Added directed instructions to trigger these exceptions and interrupts.
- Introduced an argument to
gen_opts
to enable stream which triggers instructions.