Commit graph

373 commits

Author SHA1 Message Date
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
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
c26d89d15e Fix linting errors due to default in fully-specified case statements
This commit replaces fully-specified, binary case statements with default
case by a simple one-line assignment to avoid linting errors. Removing the
default would also work but is more error prone if at a later point more
case are added and the statement is no longer fully-specified.
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
1d1ace35f8 Cast enum to logic before bit range select to avoid linting errors 2019-05-10 11:11:19 +01:00
Pirmin Vogel
aa5c3d110b Move type cast out of case selector to avoid linting error 2019-05-10 11:11:19 +01:00
Pirmin Vogel
708f9287e4 Declare result of signed arithmetic as signed 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
580379df5a Replace non-unique case with if/else 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