Skip to content
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

Support DontCare in Mux and cloneSupertype #995

Merged
merged 3 commits into from
Jan 22, 2019
Merged

Support DontCare in Mux and cloneSupertype #995

merged 3 commits into from
Jan 22, 2019

Conversation

ducky64
Copy link
Contributor

@ducky64 ducky64 commented Jan 22, 2019

Adds general support for DontCare to cloneSupertype, and add special case handling in Mux for the chisel style (DontCare object) to firrtl style (invalidate wire) conversion. Not sure how to actually test the DontCare case, but this tests the other case.

Note that it will still be difficult to use DontCare in a Mux, because Scala doesn't understand that DontCare should be a bottom type of Data, so it will infer the output type of Mux to be the common supertype of DontCare (which extends Element) and your Data, which usually means you'll get a Element or Data out, instead of something more specific eg UInt.

This also kind of feels like a game of whackamole, since DontCare support may be subtly broken in other contexts, though I guess it also makes no sense to do something like 1.U + DontCare


Related issue: resolves #848

Type of change: other enhancement

Impact: API addition (no impact on existing code)

Development Phase: implementation

Release Notes
Support DontCare in Muxes

@ducky64 ducky64 added the Bugfix Fixes a bug, will be included in release notes label Jan 22, 2019
@ducky64 ducky64 added this to the 3.2.0 milestone Jan 22, 2019
@ducky64 ducky64 requested a review from edwardcwang January 22, 2019 00:48
@ducky64 ducky64 requested a review from a team as a code owner January 22, 2019 00:48
@edwardcwang
Copy link
Contributor

From a user-facing perspective this looks fine to me. Is there a way to get Scala to understand that DontCare is a bottom type of Data, or is that not worth it / it introduces unwanted side effects / etc?

Copy link
Contributor

@edwardcwang edwardcwang left a comment

Choose a reason for hiding this comment

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

Generally LGTM with a question

@ducky64
Copy link
Contributor Author

ducky64 commented Jan 22, 2019

The implementation of Nothing as a bottom type may be compiler magic, see this StackOverflow thread. I'm going to merge this as-is and we can improve later if we figure out how.

@edwardcwang
Copy link
Contributor

Sounds good.

@ducky64 ducky64 merged commit 99bb15f into master Jan 22, 2019
@ducky64 ducky64 deleted the muxDontCAre branch January 22, 2019 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Fixes a bug, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use Mux with DontCare while equivalent when() statement is fine
2 participants