Commit graph

548 commits

Author SHA1 Message Date
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
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
d5a89b571f Modify illegal clear and set CSR ops to be read-only
The specifications mandate that CSRRS/CSRRC instructions must not write to
CSRs from x0. Similarly, CSRRSI/CSRRCI instructions must not write a zero
immediate to CSRs. With this commit, these conditions are checked and
corresponding CSR operations are changed to read-only.
2019-06-03 15:49:21 +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
7a5c8ef5c6 Fix clear operation for performance counters in CSR.
This operation was not properly implemented. Resolves #16.
2019-06-03 15:49:21 +01:00
Pirmin Vogel
015f09881a add missing begin/end in multiline statements 2019-06-03 15:49:21 +01:00
Pirmin Vogel
5319734180 Fix decoding of C.LI, C.LUI, C.SRLI, C.SRAI, C.SSLI
Hints encoded in these compressed instructions must decode into hints
in the corresponding base instructions. This resolves #51.
2019-05-31 17:26:18 +01:00
Ioannis Karageorgos
382a6c096c Fix non-unique case bug .
The `nop` instruction ( `32'h00_00_00_13` ) cannot be distinguished from masked `addi` ( `17'b?, 3'b000, 5'b?, 7'h13` ) in `unique casex` statement. The other way around is not a problem, as `addi` cannot have both registers as 0x0. 
This can be also fixed by replacing `unique casex` with `priority casex`. However, in my opinion, it is not a good solution as it may hide future bugs like this.
2019-05-29 09:34:09 +01:00
Pirmin Vogel
4020a39e99 Make prefetch FSM state signals lowercase 2019-05-24 15:52:58 +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
Philipp Wagner
409892ec8c Fix handling of C.MV and C.JR
- Decoding must give precedence to rs2 (i.e. instr_i[6:2]) to
  switch between C.MV and C.JR.
  "C.MV is only valid when rs2̸=x0; the code points with rs2=x0
   correspond to the C.JR instruction. The code points with rs2̸=x0
   and rd=x0 are HINTs."

- C.JR is only valid with rs1==x0. Throw an illegal instruction
  exception if that's not the case.
  "C.JR is only valid when rs1̸=x0; the code point with rs1=x0
   is reserved." RV32 Spec, p103

All spec references based on RISC-V Unprivileged ISA
V20190305-Base-Ratification
2019-05-23 10:05:02 +01:00
Philipp Wagner
3de95df060 Fix decoding of C.ADD and C.EBREAK
The RV32C Specification, p106 (RISC-V Unprivileged ISA
V20190305-Base-Ratification) states:

C.ADD adds the values in registers rd and rs2 and writes the result to
register rd. C.ADD expands into add rd, rd, rs2. C.ADD is only valid
when rs2̸=x0; the code points with rs2=x0 correspond to the C.JALR and
C.EBREAK instructions. The code points with rs2̸=x0 and rd=x0 are HINTs.

This essentially says: rs2 == x0 takes precedence when decoding, that's
instr[6:2]. The current code was written with the assumption of
instr[11:7] taking precedence, thus incorrectly decoding a C.ADD HINT.

Fixes lowrisc/ibex#64
2019-05-23 10:05:02 +01:00
Pirmin Vogel
145269fdc8 Replace non-unique case with unique case + default 2019-05-22 17:02:18 +01:00
Pirmin Vogel
0305803e18 Fix alignment in tracer, add INSTR_LOAD/STORE parameter 2019-05-22 17:02:18 +01:00
Pirmin Vogel
709127ca4a Switch to logic [31:0] type for tracer instruction mask parameters
The instruction masks for the tracer are defined as parameters and contain
`?` literals, which can resolve to `1`, `0` or `X` in simulation. To cover
the `X`, the type of the masks must be changed from `int unsigned`
(standard for parameters according to guidelines) to `logic [31:0]`.
2019-05-22 17:02:18 +01:00
Pirmin Vogel
3cb868597f Remove unnecessary {} to avoid linting errors 2019-05-21 15:22:21 +01:00
Pirmin Vogel
e37fc203dc Adjust FSM state signal names to guidelines 2019-05-21 15:22:21 +01:00
Pirmin Vogel
db75d30547 Replace non-unique case constructs by unique case
Our coding guidelines require the usage of `unique case` constructs with
proper `default` cases. This commit implements this change and also makes sure
that potential `'X` are propagated.
2019-05-21 15:22:21 +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
Stefan Wallentowitz
7728b7b6f2 Typo fix in muldiv: Reminder->Remainder
I am pretty sure this is about the remainder of the operation.
2019-05-16 17:14:28 +01:00
Ioannis Karageorgos
9836ef883d Restore functionality of tracer
Tracer functionality is broken after transition to ibex. "operand_b_fw_id" is missing from instruction decoder.
2019-05-15 17:55:19 +01:00