-
Notifications
You must be signed in to change notification settings - Fork 611
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
Fixes sendBits()
's handling of signed numbers in svsim
's simulation-driver
in #4593
#4599
Conversation
if (mutableBytes[byteCount - 1] != 0b10000000) { | ||
mutableBytes[byteCount - 1] &= signBitMask - 1; | ||
} |
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.
What happens if the width isn't a multiple of 8? Can we add tests for like 33 bits? And also can we add a test for 40 bits or something to make sure 32 isn't special as a power of 2?
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.
Sorry just saw your comment in #4593 (comment) explaining that this matters for multiples of 8. I still think it would be good to test a non-multiple of 8 width (e.g. 33) and a non-power-of-2 multiple of 2, (e.g. 40).
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.
Sure, I am still very new to the Chisel project, if we want to test other bitWidth
s, how should we prepare the SystemVerilog file since now we would like to have a parameterized SIntWire
module? I mean I can't figure out how svsim/src/main/scala/Workspace.elaborate()
works.
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 think it's way too much work to have parameterized modules here. Can we just settle for two different bitWidth
s here @jackkoenig ?
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 think it's way too much work to have parameterized modules here. Can we just settle for two different bitWidths here
Yes I think that makes sense!
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.
Actually both scanHexBits()
and sendBits()
are buggy, I think we might as well replace the home-made conversions with something provided by the C++'s standard library in the future.
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.
Actually both
scanHexBits()
andsendBits()
are buggy, I think we might as well replace the home-made conversions with something provided by the C++'s standard library in the future.
Do you want to do that in this PR or in a separate PR? Separate is fine if this fixes issues now.
The test you wrote is a good one because it's using the lower-level APIs, but as you noted it's a lot less flexible. We could more easily write parameterized tests using the higher-level Simulator API that's built on top of SVSim, some example tests are here:
class SimulatorSpec extends AnyFunSpec with Matchers { |
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.
Do you want to do that in this PR or in a separate PR? Separate is fine if this fixes issues now.
Unfortunately I don't think the current fix is nearly enough to fix sendBits()
.
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.
Both scanHexBits()
and sendBits()
should work now @jackkoenig .
The tl;dr is, both This PR should fix problems related to Beside the aforementioned stuff, |
…ve number `-1<<(bitWidth-1)` with `bitWidth % 8 == 1` is supplied.
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.
This looks great, thank you!
@Mergifyio backport 6.x |
✅ Backports have been created
|
(cherry picked from commit d4d3e97)
…4606) (cherry picked from commit d4d3e97) Co-authored-by: Jason Wang <[email protected]>
Although I don't understand the reasons for not using the conversions provided by
stringstream
, this PR fixes one of the edge cases as mentioned in #4593 :Fixes #4593
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
.