Commit graph

50 commits

Author SHA1 Message Date
Pirmin Vogel
e1a7dcf37f ID stage: rework CSR-related pipeline flushes
This commit clarifies why CSR-related pipeline flushes are needed
(e.g. when enabling interrupts), only introduces them when doing the
critical modifications (write/set bits in `mstatus` and `mie` CSRs
for enabling interrupts, reads and clears are uncritical for these
CSRs), and makes sure the controller is actually able to start
handling interrupts while doing a CSR-related pipeline flush.

This resolves lowrisc/ibex#6.
2019-08-16 13:28:52 +01:00
Tom Roberts
44b033cf8b [rtl] Add support for instruction fetch errors
- Add required signals to top-level
- Propagate error through fetch stages
- Add new exception type
- Update documentation for new exception type
- Resolves issue #109
2019-08-09 10:44:37 +01:00
Pirmin Vogel
cee2e9396f Remove csr_restore_dret_i signal
This signal was used to restore `mstatus` when executing DRET.
But this is not needed as `mstatus` is not modified when entering
debug mode.
2019-07-29 15:55:48 +01:00
Pirmin Vogel
327d836281 Add non-maskeable interrupt (NMI) 2019-07-24 14:22:00 +01:00
Pirmin Vogel
71a33e1ca1 Add local fast interrupts, remove legacy interrupts
This commit adds 15 local fast interrupt lines managed through
the `mie` and `mip` CSRs directly, and removes the old legacy
interrupts including the internal controller.
2019-07-24 14:22:00 +01:00
Pirmin Vogel
c2fffe0440 Add mip and mie CSRs + interrupts
This commit adds the `mip` and `mie` CSRs as well as the software,
timer and external interrupts.

Currently these interrupts are overlapped with some of the legacy
interrupts, i.e., the core will jump to the same address for different
interrupts. For example, the software interrupt has the same ID as
legacy interrupt #3. Thus, the handler must read the `mip` register
to find out whether the interrupt routine has been entered because of
the software interrupt or the legacy interrupt.

Eventually, the number of legacy interrupts will be reduced to avoid
this overlapping, and they will be connected to the `mie` and `mip`
CSRs directly.
2019-07-24 14:22:00 +01:00
Philipp Wagner
428d057c4a Rename ibex_[tracer_]define to ibex_[tracer_]pkg
This file doesn't contain defines any more, but a normal SV package.

The diff is best viewed without whitespace changes, as the reindents
cause a lof of diff noise.

Fixes lowrisc/ibex#173
2019-07-19 11:34:40 +01:00
Pirmin Vogel
010985a395 Controller: save next PC to dpc CSR upon a halt request
This commit changes the controller to save the PC of the next
instruction to the dpc CSR when entering debug mode upon a halt
request instead of the PC of the current instruction (only valid
for EBREAK instructions).

This bug was reported by @taoliug. This resolves #164.
2019-07-17 11:17:37 +01:00
Tobias Wölfel
d059979af6 RVFI based on core state (#151, fix #147)
The RVFI implementation make use of signals from the decoder and
controller to detect the state of the processor.
Especially the signal for a new and retired instruction.
2019-07-16 12:43:38 +02:00
Pirmin Vogel
a775abd967 Fix dpc CSR not updated (#157)
* Controller: remove impossible condition for `DBG_TAKEN_IF`

There is no way to jump into `DBG_TAKEN_IF` because of an EBREAK
instruction. Thus, this case also does not need to be checked.

* Controller: do not enter debug when `debug_req_i` goes low

With this commit, the core is prevented from entering debug mode when
the debug request signal is deasserted during that procedure.
Previously, the core would still enter debug mode but not updating the
debug CSR.

This resolves #153 reported by @taoliug.

* Update ibex_controller.sv
2019-07-15 10:37:33 -07:00
Pirmin Vogel
b1df836940 Controller FSM: simplify debug_mode_q-related control
The FSM now uses input signals for interrupt and debug request handling
that depend on whether the core is in debug mode. This avoids the need
for many `debug_mode_q` guards and somewhat simplifies the FSM.

If in debug mode, the core shall not handle interrupts according to the
spec anyway.
2019-07-15 15:33:29 +01:00
Pirmin Vogel
5b0e81ecd2 Move store/load_err_i into separate exc_req_lsu signal 2019-07-11 17:35:12 +01:00
Pirmin Vogel
795b5bd651 Cleanup performance monitor signals 2019-07-11 17:35:12 +01:00
Pirmin Vogel
6b5d26bae2 Cleanup interplay of IF and ID stage (controller)
Once the core is executing, the IF stage now only gets two signals
from the controller: One to clear the instruction valid output and one
to prevent the IF stage from pushing new instructions.

The former `if_valid_o` of the IF stage has been renamed to clarify
that this is not a valid bit but just the write enable for the
pipeline register.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
1456e8e0da Rework register file write enable mux
The register file shall not be written upon illegal CSR operations
and when the core is idle (waiting for new instructions). Otherwise
the write enable signal from the WB FSM/decoder is used.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
e47b500c50 Remove obsolete signals between controller and ID stage 2019-07-11 17:35:12 +01:00
Pirmin Vogel
45dadcd5bd Cleanup controller 2019-07-11 17:35:12 +01:00
Pirmin Vogel
35a5a737a7 Do not set PC when setting exceptions registers in single stepping
In the next state, the PC is set to jump into debug anyway.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
3e1c8df311 Correctly prioritize exceptions in controller 2019-07-11 17:35:12 +01:00
Pirmin Vogel
95c0dc0556 Fix handling of single stepping
Single stepping should execute exactly one more instruction, not abort
any running (multicycle) instructions, and only enter debug mode after
the current instruction is finished. In case the current instruction
leads to an exception, the exception registers must be set accordingly,
but the core must jump into debug mode instead of the exception
handler.

Previous to this commit, single stepping would immediately jump into
debug mode and ignore any exceptions.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
9ef3c13f87 Fix control for interrupts, debug request and multicycle instr
This commit makes sure that interrupts and debug requests do not
interrupt currently running multicycle instructions. Priority is
given 1) to the currently running instruction, possible exceptions
caused by this instruction, 2) debug requests, 3) interrupt
requests.

Previously, currently running instructions were aborted upon
incoming debug and interrupt requests, which could corrupt the
processor state and lead to exceptions being ignored.

This commit resolves #108 and #121.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
fd6426f52c Replace pipe_flush signal by wfi_insn
This signal is triggered iff a `wfi` instruction is decoded.
2019-07-11 17:35:12 +01:00
Pirmin Vogel
d477fbc46b Correct wrong spelling in signal name 2019-07-09 09:46:48 +01:00
Pirmin Vogel
a6c2846346 Move stall and IF-ID control from ID stage into controller 2019-07-09 09:46:48 +01:00
Pirmin Vogel
d973618ce8 Move logic to ignore decoder output out of decoder into ID stage
The decoder shall decode the instruction only. The handling of stalls
is not related to instruction decoding.
2019-07-09 09:46:48 +01:00
Pirmin Vogel
07214f626d Switch to RISC-V spec compliant trap handling
For exceptions, the Ibex always jumps to the trap vector base address
specified in `mtvec`. The exception cause is specified in `mcause` with
possibly additional information in `mtval`.

Interrupts are handled in vectored mode as before.
2019-06-28 18:55:26 +01:00
Pirmin Vogel
b22a6a10de Add mtval CSR
`mtval` can provide additional information to trap handlers.
In case of load/store errors, it holds the failing address.
For illegal instruction exceptions, it holds the illegal instruction.
2019-06-28 18:55:26 +01:00
Pirmin Vogel
5171ee79f0 Rework AGU mux for misaligned loads/stores
This operation only depends on the LSU detecting a misaligned address.
Previously, the mux control was scattered across ID stage, controller
and decoder. With this commit, all the relevant code for this operation
is moved into the ID stage and also streamlined.
2019-06-28 18:55:26 +01:00
Pirmin Vogel
ab4c8699fb Simplify default assignments to enum types
This commit simplifies the assignment of literals to enum types in
default cases by:
- defining or using existing enum values for all-zero values,
- feeding a single `1'bX` into the type cast instead of exact width
  (the tools are fine with that).
2019-05-24 15:52:58 +01:00
Pirmin Vogel
036f963990 Enforce line wrapping after 100 chars according to style guide 2019-05-24 15:52:58 +01:00
Pirmin Vogel
74abc47b71 Add missing default in unique case, propagate 'X in FSM states
This commit adds a `default` to all `unique case` statements. Also, in case
FSMs reach an undefined state, the `'X` is propagated to ease detection
in simulation. Both these changes are required by our coding guidelines.
2019-05-21 15:22:21 +01:00
Pirmin Vogel
76cd32e936 Add capability to detect and react on load/store errors 2019-05-21 15:22:21 +01:00
Pirmin Vogel
2e697121b2 Specify width of literals cast to enums to avoid linting errors 2019-05-15 16:07:25 +01:00
Pirmin Vogel
f84ed3ecd3 Use lower_snake_case for code block labels 2019-05-15 10:42:48 +01:00
Pirmin Vogel
c9efb99d97 Use 'or' instead of ',' inside '@( )' statements 2019-05-15 10:42:48 +01:00
Pirmin Vogel
fde6e505df Make sure all inputs/outputs use _i/_o suffices 2019-05-15 10:42:48 +01:00
Pirmin Vogel
967834db0c Use cast before assignment to enum type to avoid Vivado errors 2019-05-13 17:37:54 +01:00
Pirmin Vogel
49fa87ba44 Use exc_cause in IF stage directly, add missing casts to enum type
In case of interrupts, `exc_cause` carries the interrupt ID in the lower
bits and its MSB is 0 anyway. There is no need to forward only the lower
bits to the IF stage.
2019-05-10 11:11:19 +01:00
Pirmin Vogel
53f2fb9350 Remove unused signals 2019-05-10 11:11:19 +01:00
Pirmin Vogel
580379df5a Replace non-unique case with if/else 2019-05-10 11:11:19 +01:00
Pirmin Vogel
6ac7f844a1 Replace hard coded parameters and signal widths by enum types 2019-05-07 13:30:07 +01:00
Philipp Wagner
f9ad280d0c Cleanup includes and defines
- Move ibex_tracer_defines.sv and ibex_defines.sv out of the 'include'
  directory, since these files are not actually included.
- Remove ibex_config.sv, it's mostly unused code. The remaining defines,
  SYNTHESIS, ASIC_SYNTHESIS, TRACE_EXECUTION, and CHECK_MISALIGNED should
  be set through command-line flags to the simulation/synthesis tools.

Initial version by Nils Gräf.
2019-05-03 17:30:29 +01:00
Alex Bradbury
7e81f6f4eb Standardise "subheadings" in code comments
The code base made extensive use of ASCII art headings/subheadings in
comments to delineate code. Switch to a more space efficient and easier
to edit format:

/////////
// Foo //
/////////
2019-04-26 15:09:00 +01:00
Philipp Wagner
48c0b34b38 Various fixes to debug implementation
This commit updates the RISC-V debug spec-compliant debug implementation
by incorporating changes mostly done by Robert Balas on the RI5CY core.

Most notably, single stepping works after this patch is applied.

With this patch the RISC-V debug compliance test built into OpenOCD
passes fully.
2019-04-26 15:09:00 +01:00
Philipp Wagner
4d0d59db8e Include executed instruction in dbg message
If an illegal instruction is executed we display a message in
simulation. This message now also contains the instruction itself, not
only the program counter.
2019-04-26 15:09:00 +01:00
Philipp Wagner
401e7e1e3c Switch to execution-based debug
This commit switches the ibex core from a custom debug system to an
execution-based, standard RISC-V debug system. The port is based on a
port done for the RI5CY core.
2019-04-26 15:09:00 +01:00
Scott Johnson
6b0475744d Code cleanup
Fix errors and warnings reported by lint tools, and clean up the code
according to our coding style. Move all imports into the module.
2019-04-26 15:09:00 +01:00
Philipp Wagner
8813f57624 Add Doxygen-style module descriptions
We leave the existing longer headers in place for author information.
2019-04-26 15:08:30 +01:00
Alex Bradbury
27e68bd76e Convert from Solderpad to standard Apache 2.0 license
This change has been informed by advice from the lowRISC legal
committee.

The Solderpad 0.51 license states "the Licensor permits any Work
licensed under this License, at the option of the Licensee, to be
treated as licensed under the Apache License Version 2.0". We use this
freedom to convert license markings to Apache 2.0. This commit ensures
that we retain all authorship and copyright attribution information.
2019-04-26 15:05:17 +01:00
Philipp Wagner
e9e5a719bc Move RTL code into rtl/ directory
This gives us a bit of space in the source tree for documentation,
verification, utilities, and much more.
2019-04-26 15:05:17 +01:00
Renamed from ibex_controller.sv (Browse further)