Commit graph

1182 commits

Author SHA1 Message Date
Philipp Wagner
2acb497d22 Add missing enum cast
Vivado doesn't compile the design without this cast.
2019-10-03 16:56:26 +01:00
Tom Roberts
6aae5fe975 [Doc] Fix some rendering issues in cs_registers
- fixes #306
2019-10-03 10:41:29 +01:00
Tom Roberts
f35db04b7c [RTL PMP] Fix address matching bugs
- Partial matching not relevant for 32bit only accesses
- Apply region size masking correctly
2019-10-03 10:41:29 +01:00
Tom Roberts
2aacd2b98b [Priv modes] Add support for U-Mode
- General changes to suport U-mode (fixes #88)
- Update documentation
- Add priv mode flops to CSRs module
- Propagate correct priv mode to PMP module
- Implement CSR priv-mode permission checking
- Implement illegal U-mode instruction checking
- Add extra mstatus bits for U-mode (MPRV and TW)
2019-10-03 10:41:29 +01:00
Philipp Wagner
f54dfe5d4b RISC-V Compliance test: Enable tracing
Use the tracing-enabled core wrapper when executing the RISC-V
compliance test suite to help with debugging it.
2019-10-03 09:42:45 +01:00
udinator
48e604ab9e
[DV] Update ibex log regex (#366) 2019-10-02 13:16:47 -07:00
Philipp Wagner
0908817963 Tracer: Fix default file name
We document the default file name to be trace_core_00000000.log, but
actually used trace_core__00000000.log. Fix that.
2019-10-02 20:12:38 +01:00
Philipp Wagner
a121caab35 CI: Also check tracer in lint
By linting ibex_core_tracing, we lint all submodules as well: ibex_core
and ibex_tracer.
2019-10-02 18:28:26 +01:00
Philipp Wagner
1377e42a17 Lint: Enable lint for ibex_core_tracing
Add fusesoc description for core with tracing enabled, implicitly
linting the ibex_tracer as well.

Run with

$ fusesoc --cores-root=. run --target=lint lowrisc:ibex:ibex_core_tracing
2019-10-02 18:28:26 +01:00
Philipp Wagner
87c29694f0 Update gitignore to include trace log file 2019-10-02 18:28:26 +01:00
Philipp Wagner
c58e02a16b Document new tracer implementation 2019-10-02 18:28:26 +01:00
Philipp Wagner
74780e7e17 Implement Verilator-compatible tracer, and use it
The ibex_tracer module implements an execution tracer, observing the
execution flow and writing a human-readable execution trace. The trace
information is coming from the RVFI signals, as specified at
https://github.com/SymbioticEDA/riscv-formal/blob/master/docs/rvfi.md.

The existing implementation was tailored for use in ModelSim and other
commercial simulators, and used SystemVerilog features which are not
supported in Verilator or Icarus Verilog, such as classes, queues and
non-standard format specifiers (e.g. the `-` specifier for right-aligned
output). Being unable to see an execution trace when using Verilator
significantly reduced productivity and its usefulness.

This commit refactors the tracer to only use SystemVerilog constructs
which are supported in Verilator. While doing so, multiple improvements
were made for correctness and style.

Major changes:

- Improve compatibility with Verilator. Remove many non-synthesizable
  SystemVerilog constructs, such as classes and queues.
  Use casez instead of casex for better Verilator support (Verilator
  doesn't support X).
- Make the decoded output of the tracer match objdump from binutils
  exactly. Doing so is beneficial for two reasons: we can easily
  cross-check the decoded output from the tracer against the disassembly
  produced by objdump (and we did that), and users don't need to get
  used to another slighly different disassembly format.
- A plusarg "+ibex_tracer_file_base=ibex_my_trace" can be used to set a
  different basename for the trace log file.

Smaller cleanups:

- Remove decoding of reg-reg loads, which were leftover from a PULP
  extension.
- Make better use of the data available on the RVFI. Pass all of RVFI
  to the tracer, and use the provided data instead of manually
  recreating it, e.g. to get register data or the jump target.
- Rename all "instr" abbreviations to "insn". "insn" is what RVFI uses
  (and we cannot change that), so for consistency we now always use this
  abbreviation across the file.

All CSR names have been imported from binutils' riscv-opc.h file, available at
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=include/opcode/riscv-opc.h
using this small C program:

  #include <stdio.h>

  #define STR(s) #s

  int main(int argc, char **argv) {
    printf("unique case (csr_addr)\n");
  #define DECLARE_CSR(name, csraddr) \
    printf("  12'd%d: return \"%s\";\n", csraddr, STR(name));
  #include "riscv-opc.h"
    printf("  default: return $sformatf(\"0x%%x\", csr_addr);\n");
    printf("endcase\n");
    return 0;
  }

The RISC-V compliance test suite for the RV32 I, M, and C extensions has
been executed and traced. The disassembly of all traces have been
compared against traces produced by objdump to ensure identical output.

This PR is based on work by Rahul Behl <raulbehl@gmail.com> in #280.
Thank you Rahul for providing a great starting point for this work!
2019-10-02 18:28:26 +01:00
Philipp Wagner
e420688d1c Remove tracer testbench
This testbench was helpful in creating the initial tracer, but is not
fully working any more, and too limited to test the trace fully.
Extending it is inconvenient, as the creation of instruction sequences
through the bus interface is easy to get wrong.
2019-10-02 18:28:26 +01:00
Greg Chadwick
2a947c5e7f [RTL] Fix timing path around exceptions and pc_set
When an exception occurs controller goes into the flush state and then
does a pc_set to go the exception handler.  So there is no need for the
incoming signals that indicate an exception to factor directly into
pc_set_o.  This flops exc_req and illegal_insn to break long timing
paths that were occurring because of this.

Fixes #305
2019-10-02 15:46:26 +01:00
Greg Chadwick
b1155740c2 [RTL] Keep instr in ID valid for FLUSH state
When an instruction that caused an exception occurred the controller
would clear the instr_valid bit but rely on the instruction bits staying
in the ID register so it could still use them in the FLUSH state to
decide what to do. This reworks the control logic slightly so
instr_valid remains asserted when the controller goes into the FLUSH
state so relevant signals can be qualified with the instr_valid bit.

There were no known functional issues caused by the previous behaviour
however this gives a more robust approach.
2019-10-02 15:46:26 +01:00
Marek Pikuła
252874d32d Pull csr_we_int around case in CSR
`if (csr_we_int)` conditional is now outside address `unique case`.

Also add comment about `illegal_csr_*` origin.
2019-10-02 15:37:42 +01:00
Philipp Wagner
85e1d43a08 CI: Unbreak build after simplesat breakage
Tracked in https://github.com/enthought/sat-solver/issues/270
2019-10-02 14:16:26 +01:00
Philipp Wagner
47505c21f6 Docs: Fix Sphinx warnings and errors 2019-10-02 10:19:29 +01:00
udinator
f2048ea8e4
[DV] Debug single step test (#362) 2019-10-01 16:39:32 -07:00
Philipp Wagner
0a6bc4c4c8 Add more parameters to core file 2019-10-01 10:38:45 +01:00
Philipp Wagner
51dbfe1575 ibex_core_tracing: Pass through all parameters
The PMP parameters were not passed through on ibex_core_tracing, add
them back.
2019-10-01 10:38:45 +01:00
Philipp Wagner
e2848f2181 ibex_core: Use correct width for param assignments
These parameters are of type bit, we need to assign a value of the
correct width to avoid Verilator lint warnings.
2019-10-01 10:38:45 +01:00
Philipp Wagner
e6b42a1529 Tracer: Update copyright notice to match other files
In this file I missed updating the ETH/UniBo copyright notice to include
a reference to the CREDITS.md. Fixing that for consistency.
2019-10-01 09:18:48 +01:00
Tom Roberts
f2fccaadbc [Prefetch buffer] - various bug fixes
- Fix incorrect address output to mepc on interrupt (fixes #320)
- Fix instruction address changing before grant (fixes #296)
- Suppress requests and reg writes on fetch error (fixes #340)
- Remove excess address flops in fetch_fifo
- Remove restriction on outstanding requests
2019-10-01 08:23:08 +01:00
taoliug
b03ae4e2a7
[DV]Add Makefile target for functional coverage (#358) 2019-09-30 10:24:44 -07:00
NilsGraf
4c0ac554a6
[rtl/ibex_core] Added missing parameter assignment (#356)
Added missing parameter assignment for PMPEnable of ibex_cs_registers.
2019-09-30 09:52:07 -07:00
udinator
074e637b11
[DV] Fix ovpsim compare issue (#355)
* [DV] Fix ovpsim compare issue

* Update some test descriptions to avoid timeouts, update debug test
2019-09-27 17:45:58 -07:00
udinator
1615969bc1
[DV] Refactor debug stress stimulus to avoid race conditions (#354) 2019-09-25 19:08:05 -07:00
udinator
95a82f8be8
Update google_riscv-dv to google/riscv-dv@d341944 (#353)
Update code from upstream repository https://github.com/google/riscv-
dv to revision d3419444ca2fdb499a204587b2d36c6f5c1e0c44

* Update README (Udi)
* Add knob to enable full CSR randomization, fix mstatus.spp (Udi)
2019-09-25 18:40:36 -07:00
udinator
576d0ed76d
[DV] Basic performance test (#352) 2019-09-25 16:28:57 -07:00
udinator
6bae3f2d6f
Tighten debug stimulus assertion (#351) 2019-09-25 14:45:00 -07:00
udinator
83178c69f9
Update google_riscv-dv to google/riscv-dv@e3e1e30 (#349)
Update code from upstream repository https://github.com/google/riscv-
dv to revision e3e1e308cfc3d718aeb94bb3463371979d9a31ae

* Disable full trace in the run script (google/riscv-dv#180) (taoliug)
* Fix spike logging issue (google/riscv-dv#179) (taoliug)
* Add functional coverage for HINT instructions (google/riscv-dv#177)
  (taoliug)
* Add functional coverage for various hazard conditions (google/riscv-
  dv#176) (taoliug)
2019-09-24 13:55:03 -07:00
udinator
1e8381bfa1 Update google_riscv-dv to google/riscv-dv@4450592 (#347)
Update code from upstream repository https://github.com/google/riscv-
dv to revision 44505927a70a6234b996d15f2e51bd1e2632b68e

* Dump performance counters to testbench at EOT (Udi)
* Fix a constraint issue (google/riscv-dv#174) (taoliug)
* Allow split a long test to small batches (google/riscv-dv#173)
  (taoliug)
* Fix ius compile problem (google/riscv-dv#172) (taoliug)
* Add basic functional coverage for RV64IMC (google/riscv-dv#171)
  (taoliug)
* Initial prototype of functional coverage (google/riscv-dv#169)
  (taoliug)
2019-09-23 18:08:16 -07:00
udinator
ec02461b4a
[DV] Fix implemented_csr[] compile issue (#346) 2019-09-23 17:49:40 -07:00
udinator
9b967a5d97
[DV] Update implemented CSRs (#345) 2019-09-23 15:59:10 -07:00
udinator
717bf1ae02
Fix memory error test logic (#344) 2019-09-23 15:32:20 -07:00
Pirmin Vogel
83d2185c9b Tracing: Wrap fatal error message with $fatal()
The syntax of this statement is not correct without the `$fatal()` SV
construct. This causes errors in some tools even if the error condition
is not met.
2019-09-20 09:35:26 +01:00
udinator
8d799e526b
[DV] Illegal instruction monitoring (#338) 2019-09-19 10:45:28 -07:00
udinator
e9949f9808
[DV] Shorten length of interrupt tests to prevent timeouts (#337) 2019-09-19 10:19:56 -07:00
udinator
66410f6c90
[DV] Drive external stimulus to 0 after reset (#334) 2019-09-19 08:30:02 -07:00
udinator
2f120d4ade
Update google_riscv-dv to google/riscv-dv@80d4294 (#333)
Update code from upstream repository https://github.com/google/riscv-
dv to revision 80d429475138b4b94d863030246a06980c89889d

* Fix mstatus randomization issue (google/riscv-dv#168) (taoliug)
* Lower the percentage of JAL instruction (google/riscv-dv#167)
  (taoliug)
* Add an option to run a directed assembly test with ISS
  (google/riscv-dv#166) (taoliug)
* Add memory fault handlers (Udi)
2019-09-18 14:13:03 -07:00
udinator
e694fa05b9
Add memory error testing (#330) 2019-09-18 13:26:56 -07:00
Philipp Wagner
76f4db5155 Compliance test suite: Prefer D over I accesses
Give higher priority to data accesses from the CPU to improve
performance. This is the recommended setup for Ibex.
The test utility host needs still higher priority, otherwise the CPU
takes all bus capacity (the downside of strict priority arbitration).
2019-09-18 11:07:37 +01:00
taoliug
47acadc969 Consolidate the script logging (#329) 2019-09-17 16:41:43 -07:00
taoliug
e7123f1c2d
Add dsim support (#328) 2019-09-17 16:18:05 -07:00
Philipp Wagner
2ce4bfa150 Lint: Enable RVFI when doing lint checks
The RVFI define enables some code used by the tracer and should be
lint-checked as well.
2019-09-17 13:29:37 +01:00
Philipp Wagner
fa31484a6a Lint: Fix signal width in tracer
These width warnings are only visible if RVFI is enabled and reported by
Verilator lint.
2019-09-17 13:29:37 +01:00
Philipp Wagner
cc18a5e7d0 Ignore common editor files in Git
Also removes the include/riscv_config.sv.bak line, which was added
in 346d14c5. We have no code that generates this file any more.
2019-09-17 13:15:10 +01:00
udinator
80e231dd8b
Add interrupt testing, and update some debug test checks (#324) 2019-09-16 16:58:28 -07:00
taoliug
369f56bad0 Integrate with the new riscv-dv user extension flow (#323) 2019-09-16 15:06:36 -07:00