Skip to content

Conversation

fzi-hielscher
Copy link
Contributor

Sorry for the code dump. I will split this up into more manageable PRs when I have the time. I just want to get this out of the door in case it is already useful for somebody and to get some feedback.

This PR allows arcilator to "natively" produce signal traces. When doing a JIT run, just add --trace-taps --jit-vcd to the command line and it should produce a VCD file in your working directory containing the observed signals.

It breaks down to four major components:

  • The CombineTaps pass, which resolves signal aliases, so we don't trace the clock for each module individually.
  • Adding TraceTap attributes during AllocState when the --trace-taps option is provided, to maintain the association between the StateWrite ops and the traced signals.
  • The (unfortunately very verbose) LLVM IR creation in LowerArcToLLVM. In short, it inserts constant structs containing the model information, callbacks to the external trace handler library, and functions that append tracing information to a provided buffer whenever a traced StateWriteOp writes a value that is different from the one currently stored.
  • A trace backend library converting the raw trace buffers into VCD files, with some chunks taken out of @fabianschuiki's implementation in arcilator-runtime.h.

It involves a lot of ugly pointer wrangling. I've only run some basic tests so far, so I'm sure there are still plenty of bugs to find. It will also most likely (and to some extent inevitably) tank the performance. Unfortunately, I haven't been able to run the arc tests on it so far. For some reason, when enabling the TRACE option on my machine, it crashes with this funky LLVM Error, even when using a main branch build, and I've now run out of time to investigate:

/opt/homebrew/Cellar/llvm/21.1.1/bin/opt -O3 -S build/small-master/rocket-arc.ll | /opt/homebrew/Cellar/llvm/21.1.1/bin/llc -O3 --filetype=obj -o build/small-master/rocket-arc.o
LLVM ERROR: Do not know how to promote this operator's operand!
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/homebrew/Cellar/llvm/21.1.1/bin/llc -O3 --filetype=obj -o build/small-master/rocket-arc.o
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'AArch64 Instruction Selection' on function '@RocketSystem_eval'

@fzi-hielscher fzi-hielscher added the Arc Involving the `arc` dialect label Sep 18, 2025
@fabianschuiki
Copy link
Contributor

Really really cool 🥳 🚀 Can't wait to give this a spin 😁 Thanks for all this fantastic work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arc Involving the `arc` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants