Skip to content

rtl: Add gzip-compressed and disabled traces support - #152

Draft
Smephite wants to merge 1 commit into
mainfrom
feat/gz-trace
Draft

rtl: Add gzip-compressed and disabled traces support#152
Smephite wants to merge 1 commit into
mainfrom
feat/gz-trace

Conversation

@Smephite

@Smephite Smephite commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds RTL_TRACE to select the instruction-trace backend in simulation:

  • plain (default, unchanged $fwrite to .dasm)
  • gz (DPI writer producing .dasm.gz)
  • off (no tracer)

A compression ratio of 34x is reached on the traces without regressing simulation time.

Motivation

The uncompressed per-hart tracers in spatz_cc and spatz_mempool_cc can accumulate many Gigabytes of data which are potentially not needed anyhow.
The generated traces are highly compressible: A 1.4 GB dasm trace compresses to 40 MB with gzip-6 (34x).

What changed

  • hw/ip/snitch_test/src/trace_dpi.c: new DPI writer.
    Backends are thr:gz<N> (default thr:gz6), thr:plain, gz<N>, plain and null.
  • hw/ip/snitch/include/snitch/trace_writer.svh: SNITCH_TRACE_GZ selects the DPI writer, SNITCH_TRACE_DISABLE removes the tracer. - spatz_cc.sv / spatz_mempool_cc.sv: Updated to use new tracer
  • hw/system/spatz_cluster/Makefile, util/Makefrag: RTL_TRACE wires the defines, added required DPI compiles

Verification

Verified on QuestaSim 2021.3_2, Verilator 5.020 (GCC 11.2.0) and VCS 2022.06, default cluster config:
Traces decompress byte-identical to the same run under plain, 23.5 MiB → 1015 KiB (23.7x).

Compression does not affect simulation time:
In this implementation, the compression task is offloaded to a worker thread, so it never stalls the main simulation.
Due to the optimized DPI, the per-write latency even drops from 155ns to 61ns compared to $fwire.

Behavior on crashes was investigated:
On SIGKILL, the .gz still decompresses; every complete line is intact and in order; only the final line is cut, and ~920 KB is lost against ~690 KB for plain $fwrite, which buffers too.

Notes

This work was supported by Claudio (claude.ai).

* hw: add a DPI trace writer with a threaded gzip backend
* hw: gate both core tracers on RTL_TRACE=gz/off
* hw: select the backend per run with +trace_mode or TW_MODE
* mk: wire trace_dpi.c and -lz into verilator, vsim and vcs builds
* mk: forward extra arguments through the vsim run wrappers
* mk: rebuild when an included .svh header changes
* mk: handle .dasm.gz in make traces and make annotate
* chore: exempt the tracer sources from the trace_* ignore rule
* README: document RTL_TRACE and the tuning knobs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant