Skip to content

opt_clean: handle undriven and x-bit driven bits consistently #5004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

widlarizer
Copy link
Collaborator

I believe driving the bit of a signal with a constant x-bit is exactly the same as not driving it at all. This PR removes this inconsistency by extending SigPool. As the SigPool is used to check the assign_mapped wire bits against unmapped bits, this creates an arbitrary distinction between driven and undriven. I have added a pass-specific mechanism by inheriting from SigPool that happens to work for this case. I don't know if SigPool is similarly misused elsewhere.

This PR shares its motivation with #5003

@widlarizer widlarizer marked this pull request as draft April 10, 2025 09:39
@widlarizer
Copy link
Collaborator Author

This doesn't create the ideal behavior and the implementation is hard to defend either. Looking into alternatives

@widlarizer widlarizer force-pushed the emil/fix-x-check_opt branch from 42c0f9f to 532f9ab Compare April 23, 2025 20:41
@widlarizer widlarizer marked this pull request as ready for review April 24, 2025 13:22
@KrystalDelusion
Copy link
Member

Might be good to add some tests, in particular for checking that opt_clean -x and setundef -undriven -undef; opt_clean are equivalent.
Am I also right in saying that opt -full wouldn't benefit from this, since opt_expr -full (or more specifically, opt_expr -undriven) already replaces undriven bits with x-bits?

@KrystalDelusion
Copy link
Member

KrystalDelusion commented Apr 24, 2025

Also given that setundef and opt_expr both use -undriven and refer to it as "replace undriven nets with undef (x) constants" in the help, it would be good to be consistent here (unless I'm misinterpreting, and this isn't the same).

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