Commit graph

61 commits

Author SHA1 Message Date
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
Ivan Ribeiro
19ffe9ac1d Make BASE field of mtvec CSR writeable
This commit makes the BASE field of the `mtvec` CSR writable to
allow changing the trap-vector base address at runtime without
changing the boot address input. Similar to the boot address,
the trap-vector base address must always be aligned to 256 bytes.
At bootup, the trap-vector base address is initialized to the boot
address.

This commit resolves lowrisc/ibex#118.

Most of this work has been done by @ivanmgribeiro as part of
lowrisc/ibex#193.
2019-08-08 10:50:34 +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
1aa276dbc0 RVFI: re-add accidentally removed rvfi_intr signal
This signal is now set during the first instruction after the PC has
been set to enter a trap handler.
2019-07-26 09:30:45 +01:00
Pirmin Vogel
0dee0ff1ec Adapt interrupt IF for Arty example, tracer and TB 2019-07-24 18:58:26 +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
Tobias Wölfel
ff50ac8c59 Uncompressed instructions for tracer (#154)
The tracer does not support the decoding of compressed instructions.
Forward the internally used decoded instruction and use it for tracer.
2019-07-16 12:43:38 +02: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
a38389e3a2 Remove linting errors for RVFI-related signals 2019-07-16 10:12:01 +01:00
Pirmin Vogel
0dafd51b97 Generate instr_ret/compressed inside ID stage
This commit moves the generation of these signals into the ID stage
to generate it with more accurate timing. More precisely, an
instruction is now considered as retired once it has been completely
executed and not once the next instruction is pushed into the IF-ID
pipeline register.

Also, it no longer depends on whether the instruction was valid or
illegal. For RVFI and the tracer, also illegal instructions must be
considered.
2019-07-15 13:20:26 +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
Tobias Wölfel
014c753dde Tracer rewrite
Instantiate tracer module in a separate core file and use only RVFI
signals.
2019-07-11 13:25:18 +01:00
Pirmin Vogel
8613e880fc LSU cleanup, abort misaligned ops if first part fails
This commit cleans up the LSU and fixes two bugs:

1. If a misalgned transaction creates an error during the first
   part of the transaction, the second part is not pushed out and
   the transaction is aborted. Previously, the LSU tried to output
   also the second part but did not adhere to the defined
   protocol.

2. Misaligned operations are again working correctly. Previously,
   the generation of the byte enable and the alignment of read
   data was broken as these operations rely on the updated
   address from the AGU to have the same alignment as the
   original address.

This partially resolves #121.
2019-07-09 15:39:06 +01:00
Pirmin Vogel
c84ca25755 Cleanup CSR-related signals 2019-07-09 09:46:48 +01:00
Pirmin Vogel
1174603e76 Rework ID stage and decoder
This commit moves logic directly related to the decoder from the ID
stage into the decoder. This logic includes:
- Generation of immediates and decoder-based mux selectors
- Generation of register file addresses
- CSR operand check and manipulation depending on value in `rs1`
- Register file address check for RV32E (still disabled)

The muxes themselves stay in the ID stage as their control signals also
depend also on other, non-decoder-based signals (LSU, EX, WB FSM).
2019-07-09 09:46:48 +01:00
Pirmin Vogel
7924431144 Rework register file write data mux 2019-07-09 09:46:48 +01:00
Pirmin Vogel
24ab4ae65c Remove decoder MUX signals for jump and branch
These signals do not need to be generated by the WB FSM inside the ID
stage and be fed back into the decoder. They simply depend on whether
the instruction is new (we execute for the first cycle) or not.
2019-07-09 09:46:48 +01:00
Pirmin Vogel
1082b85ff0 Rework interaction between EX block and ID stage
The EX block actually signals when its output is valid, and not when it
is ready to accept new input. The LSU valid signal is not needed inside
the EX block and can thus be fed directly to the ID stage.
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
c86f71e724 Switch to new signal name in tracer instantiation
This got forgotten when renaming the signal inside ID stage in
commit b22a6a10de.
2019-07-01 17:56:59 +01:00
Tobias Wölfel
08f535ebb2 Fix updated signal name 2019-07-01 14:34:02 +01:00
Tobias Wölfel
b8be998978 Fix RVFI rd write enable 2019-07-01 14:09:34 +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
e9bdbaddd6 Make mtvec CSR compliant to spec
The LSBs indicate the vector mode. They are set to vectored for Ibex.
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
Philipp Wagner
d811c04cce Disable performance counters by default
Performance counters are an optional feature. Disable them by default to
avoid users having them enabled unknowingly and paying the (rather
large) area price for it.
2019-06-25 17:46:07 +01:00
Tobias Wölfel
8bada6a0b9 Fix RVFI signal name 2019-06-18 00:08:24 +01:00
Tobias Wölfel
632f3dcda6 RVFI memory access
Unaligned access is allowed.
2019-06-06 11:21:06 +01:00
Tobias Wölfel
951437a2c9 RVFI implementation
Generate signals for RISC-V Formal Verification.

Output of signals is partially delayed to get values before and after
the completion of an instruction.

The timing of the output is based on the detection of a retired
instruction. This change is detected on changes of the instruction
code itself, changes of the program counter and the valid signal.

The compressed instruction is forwarded because the decoder maps the
compressed instruction into the corresponding uncompressed instruction,
but the original instruction is needed to detect the correct format.

Register output based on the requirements from RVFI.
2019-06-06 11:21:06 +01:00
Pirmin Vogel
a3b6c28ebd Remove legacy performance counters 2019-06-03 15:49:21 +01:00
Pirmin Vogel
d4b349766e Cause illegal instruction exception for access violations on CSRs
This commit adds checks to CSR accesses. If a CSR is accessed that is not
implemented, or if a read-only CSR is written to, an illegal instruction
exception is caused.
2019-06-03 15:49:21 +01:00
Pirmin Vogel
3ea6744f81 Add standard compliant performance counters
This commit adds the CSRs `mcycle(h)`, `minstret(h)`, `mcountinhibit` and
mhpmcounter3(h) - mhpmcounter31(h) as well as `mphmevent3 - mhpmevent31`.
The registers `mphmevent3 - mhpmevent31` are hardwired and cannot be
reconfigured.
2019-06-03 15:49:21 +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
76cd32e936 Add capability to detect and react on load/store errors 2019-05-21 15:22:21 +01:00
Pirmin Vogel
c9efb99d97 Use 'or' instead of ',' inside '@( )' statements 2019-05-15 10:42:48 +01:00
Pirmin Vogel
0894cfb0db Use UpperCamelCase for config parameters, specify type 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
db6cb55656 Use enum type for csr_op* instead of logic, resolves #34 2019-05-13 17:37:54 +01:00
Pirmin Vogel
93b0b77f27 Make sure boot_addr_i is aligned to 256 bytes
The core ignores the lowest byte of the boot address and thus does not
support booting from addresses not aligned to 256 bytes. This commit
updates both the documentation accordingly and adds an assert to the
IF stage.
2019-05-10 11:11:19 +01:00
Pirmin Vogel
c5f32e4737 Specify bitlength of bit literal to avoid linting error 2019-05-10 11:11:19 +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
c459e99ff8 Align immediate encoding format names to specs 2019-05-08 15:45:22 +01:00
Pirmin Vogel
f40935aa7d Remove unused and unspecified immediate encoding types 2019-05-08 15:45:22 +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