Commit graph

373 commits

Author SHA1 Message Date
Tobias Wölfel
1df87f4400 Add fence instruction to tracer (#134) 2019-07-11 13:25:18 +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
Tobias Wölfel
1e2d5b7eda Rename opcode OP-IMM
Align name with RISC-V spec.
2019-07-11 10:04:56 +01:00
Tobias Wölfel
27d2addaa4 Rename fence opcode (#138) 2019-07-11 10:04:56 +01:00
Tobias Wölfel
08e9ba0165 Reorder opcode enum 2019-07-11 10:04:56 +01:00
Pirmin Vogel
8b4e337118 Decoder: fix drive conflict, set jump_set_o for JALR
This commit solves problems reported by @jeanlouismaquet in #130.
2019-07-10 15:24:21 +01:00
Pirmin Vogel
73e94fb6f8 Comment on RV32E register address check in compressed decoder
It is not necessary to do this check in the compressed decoder. If a
compressed instruction in RV32E tries to access any register x16 - x31,
the regular decoder triggers an illegal instruction exception and the
controller writes the actual faulting (compressed) instruction to
`mtval`.
2019-07-09 17:56:58 +01:00
Pirmin Vogel
5093e0a0d2 Explicitly set alu_op_x_mux_sel in decoder
To make the regfile address check in RV32E not triggering false alarms
when accessing reg x16 - x31, the decoder should only set the muxes
for the regfile output when the instruction actually requires the
regfile output.

It is cleaner to explicitly set the `alu_op_x_mux_sel` signals to
`OP_X_REG_X` instead of relying on the default assignment if they
are really needed.
2019-07-09 17:56:58 +01:00
Pirmin Vogel
9ed49b9a17 Do not select regfile in decoder if not required
Otherwise, the regfile address check in RV32E can trigger false alarms
for some instructions and arguments (e.g. immediates).
2019-07-09 17:56:58 +01:00
Pirmin Vogel
a3bfcd0f04 Decoder: enable checking of register file addresses for RV32E 2019-07-09 17:56:58 +01:00
Pirmin Vogel
2478b5f978 Check rs1 & rd for non-CSR system instructions
For `ecall`, `ebreak`, `mret`, `dret`, `wfi` these two fields must be 0.
If they are not zero, the decoder generates an illegal instruction
exception.
2019-07-09 17:08:21 +01:00
Pirmin Vogel
6a1ac272da Fix linting errors 2019-07-09 15:39:06 +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
d64eaad817 Rework WB FSM in ID stage, remove combinational loop 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
9e46bc50d5 Move jump_set generation from WB FSM into decoder 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
7e6452ac64 Multdiv: rename state signals 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
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
3eb147dbc2 Prevent illegal instructions from propagating out of decoder
This commit makes sure that if any instruction is detected as being
illegal inside the decoder, the decoder does not set the control
signals to let the illegal instruction affect the register file,
LSU, EX, WB, CSRs. Previously, this was only the case for some but
but not all instructions.

Note that this is not sufficient to prevent instructions detected
as illegal elsewhere from affecting the processor state. For example,
when using RV32E, an instruction can be detected to use unavailable
registers outside the decoder in the ID stage. But it is cleaner to
handle all illegal instructions detected in the decoder similarly.
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
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
9749120f05 Add mscratch CSR 2019-06-28 18:55:26 +01:00
Pirmin Vogel
2967113edd Mask LSB of mepc CSR to 0 for writes initiated by software 2019-06-28 18:55:26 +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
8ed9ff5bde Reduce width of mcause CSR 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
71a1ccc08d Order CSR assignments according to their address 2019-06-28 18:55:26 +01:00
Philipp Wagner
d00db65227 Avoid WIDTH lint warnings in Verilator
Verilator displays the following lint warnings:

%Warning-WIDTH: ../src/lowrisc_ibex_ibex_0.1/rtl/ibex_cs_registers.sv💯 Operator SHIFTL expects 32 bits on the LHS, but LHS's VARREF 'RV32E' generates 1 bits.
                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.
%Warning-WIDTH: ../src/lowrisc_ibex_ibex_0.1/rtl/ibex_cs_registers.sv:103: Operator SHIFTL expects 32 bits on the LHS, but LHS's VARREF 'RV32M' generates 1 bits.
%Warning-WIDTH: ../src/lowrisc_ibex_ibex_0.1/rtl/ibex_cs_registers.sv:108: Operator SHIFTL expects 32 bits on the LHS, but LHS's VARREF 'MXL' generates 2 bits.
%Warning-WIDTH: ../src/lowrisc_ibex_ibex_0.1/rtl/ibex_register_file_ff.sv:63: Operator EQ expects 32 bits on the LHS, but LHS's VARREF 'waddr_a_i' generates 5 bits.

It's not quite clear (to me) from reading the SV spec if this is a bug
in Verilator lint, or if this is actually a code bug.

Alternative proposal for #92
2019-06-27 17:54:11 +01:00
Pirmin Vogel
89b0d3a200 Clarify application scenarios of register file versions 2019-06-26 14:09:23 +01:00
Pirmin Vogel
d8cf729c21 Rename ibex_register_file.sv to ibex_register_file_latch.sv 2019-06-26 14:09:23 +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
Pirmin Vogel
37d9322785 Change format of assertions and add display output 2019-06-24 21:37:53 +02:00
Pirmin Vogel
b3c6c7ddbf Correct LSU assertion
Errors are signaled with `rvalid` and not with `gnt`.
2019-06-24 21:37:53 +02:00
Pirmin Vogel
6306436465 Add assertions for instruction and data address alignment 2019-06-24 21:37:53 +02:00
Pirmin Vogel
b7919a7bd3 Make sure instr address output is word aligned
The core handles unaligned instruction fetches by doing two separate
word-aligned instruction fetches. Without this commit, the core can
still output addresses which are not word aligned and relies on the
memory to ignore the LSBs of the address. This is not safe.
2019-06-24 21:37:53 +02:00
Pirmin Vogel
182e10048b Make sure data address output is word aligned
The core handles unaligned accesses by doing two separate word-aligned
accesses. Without this commit, the core can still output addresses
which are not word aligned and relies on the memory to ignore the LSBs
of the address. This is not safe.
2019-06-24 21:37:53 +02:00
Pirmin Vogel
0ecf71e8e1 Correct performance counter increment
Prior to this commit, the next counter value was not based on the
current value.
2019-06-24 21:34:56 +02:00
Pirmin Vogel
157eb5bc11 Fix performance counters
Without this commit, the performance counters mhpmcounter3(h)-
mhpmcounter31(h) are optimized away during synthesis due to
`X`-values in the address decoder masks. This commit replaces
these masks with offsets and instead masks the input address
before comparison.

To enable the synthesizer optimizing away unused counters,
the masks for these counters are set to zero.
2019-06-24 21:34:56 +02:00
Pirmin Vogel
92803bb8e5 Make sure CSR set/clear/write op only change the CSR during one cycle
Without this change, the core can continue to write CSRs during multiple
subsequent clock cycles when being stalled. This can corrupt CSR (e.g.
performance counters).
2019-06-24 17:02:40 +02:00
Pirmin Vogel
d363a3d3b6 Fix linting errors 2019-06-18 13:43:16 +01:00
Tobias Wölfel
8bada6a0b9 Fix RVFI signal name 2019-06-18 00:08:24 +01:00