Skip to content

Conversation

stnolting
Copy link
Owner

Some time ago I read a blog article about the ARM embedded trace buffer (-> interrupt.memfault.com/blog/instruction-tracing-mtb-m33) and was quite excited about the concept. Hence, this PR adds a very similar module to the processor that allows for execution tracking via "instruction delta tracing".

The tracer module is configured by two new top generics:

IO_TRACER_EN     : boolean := false; -- implement instruction tracer
IO_TRACER_BUFFER : natural range 1 to 2**15 := 1 -- trace buffer depth, has to be a power of two, min 1

Once started, the trace buffer collects the instruction execution flow in an internal FIFO. Older elements are automatically discarded so that the buffer only contains the last IO_TRACER_BUFFER instruction deltas. Tracing can be stopped manually or automatically: when a certain address is reached, the tracer stops automatically and can optionally trigger an interrupt.

The trace data can be processed directly (stand-alone; no debugger required) by the processor:

<< NEORV32 Tracer Demo Program >>

Trace buffer: 64 entries
Starting trace...

Trace log:
[0] SRC: 0x000003b8 -> DST: 0x000002cc <TRACE_START>
[1] SRC: 0x000002d0 -> DST: 0x000004cc <TRAP_ENTRY>
[2] SRC: 0x00000568 -> DST: 0x0000056c
[3] SRC: 0x00000590 -> DST: 0x000001e4

Program completed

Alternatively, the data can also be output and displayed directly using a GDB script:

grafik

@stnolting stnolting self-assigned this Jul 12, 2025
@stnolting stnolting added enhancement New feature or request HW Hardware-related labels Jul 12, 2025
@stnolting stnolting marked this pull request as ready for review July 12, 2025 09:24
@stnolting
Copy link
Owner Author

Things planned for upcoming PRs:

As always, I would appreciate ideas, thoughts or help.

@stnolting stnolting merged commit 8013dd6 into main Jul 12, 2025
7 checks passed
@stnolting stnolting deleted the tracer branch July 12, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request HW Hardware-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant