cve2/rtl
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
..
ibex_alu.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_compressed_decoder.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_controller.sv [RTL] Fix timing path around exceptions and pc_set 2019-10-02 15:46:26 +01:00
ibex_core.f Add local fast interrupts, remove legacy interrupts 2019-07-24 14:22:00 +01:00
ibex_core.sv ibex_core: Use correct width for param assignments 2019-10-01 10:38:45 +01:00
ibex_core_tracing.sv Implement Verilator-compatible tracer, and use it 2019-10-02 18:28:26 +01:00
ibex_cs_registers.sv Pull csr_we_int around case in CSR 2019-10-02 15:37:42 +01:00
ibex_decoder.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_ex_block.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_fetch_fifo.sv [Prefetch buffer] - various bug fixes 2019-10-01 08:23:08 +01:00
ibex_id_stage.sv [RTL] Keep instr in ID valid for FLUSH state 2019-10-02 15:46:26 +01:00
ibex_if_stage.sv [I-side] - Fix issues found in tracing example 2019-09-12 08:47:09 +01:00
ibex_load_store_unit.sv [RTL] - Remove timing loop in LSU 2019-09-05 08:35:54 +01:00
ibex_multdiv_fast.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_multdiv_slow.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_pkg.sv [RTL] - Add PMP module 2019-08-29 17:43:37 +01:00
ibex_pmp.sv [RTL] - Add PMP module 2019-08-29 17:43:37 +01:00
ibex_prefetch_buffer.sv [Prefetch buffer] - various bug fixes 2019-10-01 08:23:08 +01:00
ibex_register_file_ff.sv Mention CREDITS.md in license header 2019-08-27 18:10:02 +01:00
ibex_register_file_latch.sv Register file: update comments 2019-08-29 15:24:18 +01:00
ibex_tracer.sv Implement Verilator-compatible tracer, and use it 2019-10-02 18:28:26 +01:00
ibex_tracer_pkg.sv Implement Verilator-compatible tracer, and use it 2019-10-02 18:28:26 +01:00