[debug] Add circt_debug_* intrinsics for Chisel type metadata#5276
Open
fkhaidari wants to merge 1 commit intochipsalliance:mainfrom
Open
[debug] Add circt_debug_* intrinsics for Chisel type metadata#5276fkhaidari wants to merge 1 commit intochipsalliance:mainfrom
fkhaidari wants to merge 1 commit intochipsalliance:mainfrom
Conversation
Introduce an opt-in pass that injects CIRCT debug intrinsics carrying Chisel-level type and constructor-parameter metadata through to FIRRTL, so downstream tooling (waveform viewers, debuggers) can recover Bundle field names, Vec shapes, ChiselEnum types and module parameters that are otherwise lost during conversion. The DebugIntrinsics emitter walks the elaborated circuit and appends four kinds of secret intrinsics: - circt_debug_moduleinfo per module (typeName + ctor params) - circt_debug_var per top-level signal, port or memory - circt_debug_subfield per Bundle/Vec element, linked by parent - circt_debug_enumdef per ChiselEnum type (emitted once) Constructor parameters are extracted via runtime reflection and serialised to JSON so the downstream sink can pick the right MLIR attribute type. Emission is disabled by default and activated by passing `withDebug = true` to any ChiselStage entry point, which schedules the new AddDebugIntrinsics phase between Elaborate and Convert. Includes unit tests for moduleinfo / var / subfield / enumdef emission across scalar, Bundle, Vec, ChiselEnum, memory and hierarchy cases, plus a docs section in docs/src/explanations/intrinsics.md. Based on work of @rameloni Signed-off-by: fkhaidari <khaidari.fg@gmail.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! This PR adds source-level debug info collection for Chisel
Based on @rameloni's Tywaves work (#4015, #4224), but using intrinsics
instead of annotations as @fabianschuiki suggested in that thread.
Emits four intrinsics during elaboration:
circt_debug_var-- type + ctor params per signalcirct_debug_subfield-- aggregate hierarchycirct_debug_moduleinfo-- module-level metadata (class, ctor params)circt_debug_enumdef-- ChiselEnum definitionsFully opt-in via
--emit-debug-type-info. Without the flag, FIRRTLoutput is bit-identical to main.
Companion CIRCT PR (intrinsic lowering + debug dialect extensions)
is in progress at [fkhaidari/circt#1] and will be submitted upstream
later
cc @fabianschuiki @rameloni @jackkoenig @seldridge
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
Add opt-in
ChiselStageflagwithDebug = truethat emitscirct_debug_*intrinsics preserving Chisel-level type and parameter metadata in FIRRTL.
Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash)and clean up the commit message.Create a merge commit.