Skip to content

logic analysis passes — balance, AIG/MIG conversion, cut enumeration . Co-authored with Claude Opus 4.8 and sonnet 4.6#7

Open
ranaumarnadeem wants to merge 3 commits into
Coloquinte:mainfrom
ranaumarnadeem:main
Open

logic analysis passes — balance, AIG/MIG conversion, cut enumeration . Co-authored with Claude Opus 4.8 and sonnet 4.6#7
ranaumarnadeem wants to merge 3 commits into
Coloquinte:mainfrom
ranaumarnadeem:main

Conversation

@ranaumarnadeem

Copy link
Copy Markdown

Did some Bug fixes, depth analysis, and four new non-ATPG features built on top of the existing network representation.

Bug fixes

  • io/blif.rs: .flop writer emitted the enable signal for R= and used raw Display instead of sig_to_string for both E=/R= fields
  • network/stats.rs: nb_gates() excluded LUTs from the count; Display showed nb_dff in place of nb_dffe/nb_dffr sub-counts

New: depth analysis (network/stats.rs)

levels(net) and depth(net) — combinational logic level per node (Buf does not add a level; Dff = 0). Surfaced in quaigh show.

New: balance pass (optim/balance.rs, --balance)

Flattens And/Xor associativity chains and rebuilds minimum-depth balanced 2-input trees using a min-heap on node level. A 16-input AND chain goes from depth 15 to 4. Verified equivalent post-balance.

New: AIG conversion (optim/aig.rs, --aig)

Lowers every gate to 2-input And + implicit inverters. Xor, Mux, Maj, and Lut are decomposed via SoP. Flip-flops preserved via pre-allocate-then-wire two-pass approach. Verified equivalent (combinational and bounded sequential).

New: MIG conversion (optim/mig.rs, --mig)

Lowers to 3-input Majority gates + implicit inverters (And = Maj(a,b,0), Or = Maj(a,b,1)). Intentionally skips make_canonical after construction (which would collapse Maj(a,b,0) back to And) — uses deduplicate() instead.

New: k-feasible cut enumeration (optim/cuts.rs)

Bottom-up priority-cut enumeration with dominance pruning and per-node cap (default 8). Flip-flops are combinational boundaries. Includes is_valid_cut verifier and count_cuts. Surfaced in quaigh show as "4-feasible cuts: N".

Tests

90 unit + 6 doc-tests, all green. cargo fmt and clippy clean.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 108 complexity · 39 duplication

Metric Results
Complexity 108
Duplication 39

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Coloquinte

Copy link
Copy Markdown
Owner

Thanks! Seems like legit bugs, I'll merge those

On the other hand, there's a very AI feeling to it. The code seems okay, but it's a large chunk so I'd appreciate more context please:

  • how did you develop this? If AI, which model/could you include it in the commit description?
  • are you using it in the wild/for a larger project, and what for?

@ranaumarnadeem

Copy link
Copy Markdown
Author

Yup did it with the help of AI i used claude opus 4.8 and sonnet 4.6. I will update PR .
I am working on a fault simulator with scan insertion etc. Wanted to see how equivalency checking logic is implented so took inspiration from Quaigh and saw some bugs and easy to do improvemens so did them along the way xD.

@ranaumarnadeem ranaumarnadeem changed the title logic analysis passes — balance, AIG/MIG conversion, cut enumeration logic analysis passes — balance, AIG/MIG conversion, cut enumeration . Co-authored with Claude Opus 4.8 and sonnet 4.6 Jun 24, 2026
@ranaumarnadeem

Copy link
Copy Markdown
Author

also if i have to do some contribution in future (which i will do ig cuz i kinda like rust) so i will make sure to make PRs with a little code changes only when possible.

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