ibex icon indicating copy to clipboard operation
ibex copied to clipboard

Report traps and privilege level in trace

Open Timmmm opened this issue 2 months ago • 5 comments

There are a few signals in the tracer module that aren't printed to the output file:

  // These signals are part of RVFI, but not used in this module currently.
  // Keep them as part of the interface to change the tracer more easily in the future. Assigning
  // these signals to unused_* signals marks them explicitly as unused, an annotation picked up by
  // linters, including Verilator lint.
  logic [63:0] unused_rvfi_order = rvfi_order;
  logic        unused_rvfi_trap = rvfi_trap;
  logic        unused_rvfi_halt = rvfi_halt;
  logic        unused_rvfi_intr = rvfi_intr;
  logic [ 1:0] unused_rvfi_mode = rvfi_mode;
  logic [ 1:0] unused_rvfi_ixl = rvfi_ixl;

It would be really helpful if there was an extra column for the current privilege, and for traps to be printed.

If I make a PR for this would it be accepted?

Timmmm avatar Nov 27 '25 14:11 Timmmm

In general, I think this is a good idea.

One of the ways that we use the trace log is to gather ISA coverage. Specifically, this script needs to keep on working: https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/riscv_dv_extension/ibex_log_to_trace_csv.py

One thing you can consider is making a PR that specifies the format of the trace file with parameters.

marnovandermaas avatar Nov 27 '25 16:11 marnovandermaas

I think for parsing the logs you really want structured output. Parsing human-readable trace formats is generally a terrible idea, but it's difficult to get people to stop if there isn't a proper alternative...

We're starting to add structured logging outputs formats for the Sail model too (I was going to start with JSON), so it would probably be nice if Ibex and Sail could support the same JSON format.

I think for ISA coverage, @jordancarlin and the guys at Harvey Mudd have been working on something... Can you remind me what your plan was Jordan?

Timmmm avatar Nov 27 '25 16:11 Timmmm

I just noticed there's a new RVVI Text format in progress. It actually looks pretty well thought out, and more efficient than JSON. I'll try adding support for that.

Timmmm avatar Nov 28 '25 11:11 Timmmm

We're starting to add structured logging outputs formats for the Sail model too (I was going to start with JSON), so it would probably be nice if Ibex and Sail could support the same JSON format.

I think for ISA coverage, @jordancarlin and the guys at Harvey Mudd have been working on something... Can you remind me what your plan was Jordan?

I've been working with Synopsys to create and standardize the RVVI-Text format. That is the trace format that will be used for ISA coverage for ACT 4.0. It looks like Ibex uses RISCV-DV for coverage, which uses its own custom CSV format. I think RVVI-Text is a superset of that CSV format, so it should be possible to convert from an RVVI-Text log to the necessary CSV (though even better would be adding support for RVVI-Text to RISCV-DV).

I just noticed there's a new RVVI Text format in progress. It actually looks pretty well thought out, and more efficient than JSON. I'll try adding support for that.

The version released there is an evolution/standardization created in collaboration with Synopsys of the initial, ad-hoc format I had been using for ACT 4.0. Glad to hear that you like the overall format and thanks for opening a number of suggestions over on that repo.

jordancarlin avatar Nov 28 '25 21:11 jordancarlin

I also agree with using a standardized way that is easier to parse for machines and humans, and the format looks good to me so far. We could start with an implementation as @Timmmm is already doing and then slowly transition our DV scripts to use this format as well.

SamuelRiedel avatar Dec 01 '25 09:12 SamuelRiedel