-
Notifications
You must be signed in to change notification settings - Fork 597
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
Preserve literal value across .asSInt and .zext #4151
Conversation
e32aedc
to
37c416d
Compare
def do_zext(implicit sourceInfo: SourceInfo): SInt = this.litOption match { | ||
case Some(value) => SInt.Lit(value, this.width + 1) | ||
case None => pushOp(DefPrim(sourceInfo, SInt(width + 1), ConvertOp, ref)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is somewhat surprising that zero extending a UInt
returns an SInt
. I would've thought that this took a width to zero extend to and did not change the type. This seems like it wants to be asSIntPreserveValue
or something. This is what the API is, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the name of the API is questionable but that's what it has always been. We certain can alias it (and consider changing).
37c416d
to
bb9a996
Compare
(cherry picked from commit dbbf73a)
Note that
.asSInt
is only defined onBits
, if you want to cast toSInt
from Bundles or Vecs you already gotta go throughUInt
.Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.