Commit graph

585 commits

Author SHA1 Message Date
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
Ioannis Karageorgos
c221046c0c Remove unsynthesizable system task $stop
Synthesis tools throw warnings with system task $stop. Remove it.
2019-05-15 17:55:19 +01:00
Pirmin Vogel
e87d0cc3e9 Add comment to clarify that the MSB in the shifter can safely be ignored 2019-05-15 16:07:25 +01:00
Pirmin Vogel
553547e971 Harmonize comments, remove some weird formatting 2019-05-15 16:07:25 +01:00
Pirmin Vogel
5962df278e Add comment to clarify that ignoring the MSB in the MAC is safe.
It is not obvious that the MSB in the MAC of the multiplier can safely
be ignored, and it is tedious to derive this from solely studying the
architecture of the multiplier. This comment makes clear that it is
indeed safe and also gives some reasoning.
2019-05-15 16:07:25 +01:00
Pirmin Vogel
29107c5283 Use unsigned type for part select to avoid linting errors 2019-05-15 16:07:25 +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
ac7436f491 Align _Q/_q suffix to coding style guidelines 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
967834db0c Use cast before assignment to enum type to avoid Vivado errors 2019-05-13 17:37:54 +01:00