Skip to content

[circt-bmc] Preserve signal names before lowering#10075

Open
ankit-cybertron wants to merge 1 commit intollvm:mainfrom
ankit-cybertron:bmc-fix
Open

[circt-bmc] Preserve signal names before lowering#10075
ankit-cybertron wants to merge 1 commit intollvm:mainfrom
ankit-cybertron:bmc-fix

Conversation

@ankit-cybertron
Copy link
Copy Markdown

This patch adds dbg.scope and dbg.variable ops in LowerToBMC to preserve hardware signal names before
hwModule->erase() discards them.

This is needed to support counter-example generation -- without preserving names here, there is no way to produce human-readable waveform output when the solver finds a violation.

@ankit-cybertron ankit-cybertron marked this pull request as draft March 29, 2026 06:35
@ankit-cybertron ankit-cybertron marked this pull request as ready for review March 29, 2026 06:35
Copy link
Copy Markdown
Contributor

@TaoBi22 TaoBi22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this! Could we add a test or two in test/Tools/circt-bmc/ to make sure this is working properly?

@ankit-cybertron
Copy link
Copy Markdown
Author

Thanks for looking at this! Could we add a test or two in test/Tools/circt-bmc/ to make sure this is working properly?

Thanks for the review! Added 2 tests in test/Tools/circt-bmc/lower-to-bmc-debug.mlir -- one for a simple passthrough module and one for a module with a computed output -- to verify that dbg.scope and dbg.variable ops are correctly emitted for all ports. But I'm not sure if these tests cover everything we have here

Copy link
Copy Markdown
Contributor

@TaoBi22 TaoBi22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is looking good modulo some comments below.

While I think landing this makes sense for now as a first step, I wonder if the best way to handle module hierarchy would actually be to add another pass to the circt-bmc pipeline that adds the dbg.variable ops to every module. Then these changes in LowerToBMC could just be to make sure those ops get carried across (not even sure that wouldn't just happen automatically). Not a blocker on this, just a thought!

@ankit-cybertron
Copy link
Copy Markdown
Author

Thanks! This is looking good modulo some comments below.

While I think landing this makes sense for now as a first step, I wonder if the best way to handle module hierarchy would actually be to add another pass to the circt-bmc pipeline that adds the dbg.variable ops to every module. Then these changes in LowerToBMC could just be to make sure those ops get carried across (not even sure that wouldn't just happen automatically). Not a blocker on this, just a thought!

That sounds like a really interesting direction -- I can definitely try exploring that as well. Not sure if something like this will work for circt-bmc at this stage, but happy to look into it

Copy link
Copy Markdown
Contributor

@TaoBi22 TaoBi22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM modulo a couple of nits - let me know if you need me to hit merge once these are addressed.

#include "circt/Dialect/Seq/SeqOps.h"
#include "circt/Dialect/Seq/SeqTypes.h"
#include "circt/Dialect/Verif/VerifOps.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unrelated change

// RUN: circt-opt --lower-to-bmc="top-module=Passthrough bound=2" %s | FileCheck %s --check-prefix=PASSTHROUGH

// SIMPLE: dbg.scope "Simple"
// SIMPLE-DAG: dbg.variable "in", %[[VAL:.*]] scope %{{.*}} : i8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check this is actually using the right value, as opposed to just matching anything for VAL? Also is there a reason for not matching the specific scope?

@TaoBi22
Copy link
Copy Markdown
Contributor

TaoBi22 commented Apr 1, 2026

Ah looks like the CI is failing on this - we probably need some kind of placeholder to discard dbg ops for now further down the pipeline.

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.

2 participants