Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Jul 20, 2025

This commit introduces NPNClass and BinaryTruthTable classes to the CIRCT Support library for Boolean function equivalence checking and canonicalization.

NPNClass computes Negation-Permutation-Negation canonical forms for Boolean functions, enabling efficient detection of functionally equivalent circuits under input/output transformations. BinaryTruthTable provides compact representation using APInt with support for multi-input, multi-output functions.

This infrastructure is essential for technology mapping and Boolean function optimization in synthesis flows.

  • This encodes multiple output functions as single APInt.
  • Currently exact NPN canonicalization is used but would need to implement semi-canonical form( https://people.eecs.berkeley.edu/~alanmi/publications/2013/icfpt13_npn.pdf)
  • Actual canonicalization is implemented in computeNPNCanonicalForm . Other changes are for helper functions for TruthTable/NPNClass.
  • Unit tests are heavily added as each transformation is very error-prune.

This commit introduces NPNClass and BinaryTruthTable classes to the CIRCT
Support library for Boolean function equivalence checking and canonicalization.

NPNClass computes Negation-Permutation-Negation canonical forms for Boolean
functions, enabling efficient detection of functionally equivalent circuits
under input/output transformations. BinaryTruthTable provides compact
representation using APInt with support for multi-input, multi-output functions.

This infrastructure is essential for technology mapping and Boolean function
optimization in synthesis flows.
Copy link
Contributor

@cowardsa cowardsa left a comment

Choose a reason for hiding this comment

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

LGTM - few minor comments but nothing substantial - would it be worth adding some tests to make sure we can't touch certain elements e.g. trigger the asserts that setOutput(largeNumber) doesn't proceed?

@uenoku uenoku force-pushed the dev/hidetou/npn-class-only branch from 22b9ecb to 42ca350 Compare July 23, 2025 08:37
@uenoku
Copy link
Member Author

uenoku commented Jul 23, 2025

trigger the asserts that setOutput(largeNumber) doesn't proceed?

Thank you for the suggestion! Assertion is conditionally enabled via compiler option so it's a bit difficult to test assertion firing in the unit tests (in CI assertions are enabled but we don't enable assertions for the binary release). For this specific conditions, users of NPN/TruthTable are expected to provide APInt with correct bit width so I think CI should have good coverage for this specific asssertions.

@cowardsa
Copy link
Contributor

LGTM - thanks for making the changes - the updated comments also help where you've written !0, !1 - makes it a little easier to follow!

@uenoku uenoku merged commit 754f72d into main Jul 23, 2025
7 checks passed
@uenoku uenoku deleted the dev/hidetou/npn-class-only branch July 23, 2025 17:27
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