extract_fa: Fix xor3
/xnor3
inversion bug
#4691
Open
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.
What are the reasons/motivation for this change?
The
extract_fa
pass seems to have issues when an odd number of inputs are inverted, this is previously reported in #3879 and #4573.I think @eddiehung solved this is the
xor2
/xnor2
case in #1297, but I thexor3
/xnor3
case lacks the equivalent logic.Explain how this is achieved.
Similarly to how it is handled in the
xor2
/xnor2
case, we invert thexor3
/xnor3
output if themajority3
has an odd number of inverted inputs.If applicable, please suggest to reviewers how they can test the change.
I have tried to make this break using @jix's test case from #3882.
I don't have much confidence in my understanding of this code, and I hope that some discussion here will help clarify some things for me.
9421558 should perhaps be in a separate pull request (or probably just deleted). I left it in so I could ask if somebody could help clarify to me what the deleted code segment achieves.
84d0c8f I thought initially this was a bug fix, but I'm not sure
invert_xy
andf2i.inv_a ^ f2i.inv_b
can be true at the same time?Thanks for the amazing tool!