Skip to content

Round up when calculating register size in bytes #419

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

Merged

Conversation

Tiwalun
Copy link
Contributor

@Tiwalun Tiwalun commented Jan 2, 2020

This fixes the issue in #418.

@Tiwalun Tiwalun requested a review from a team as a code owner January 2, 2020 15:17
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @adamgreig (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Jan 2, 2020
@burrbull
Copy link
Member

burrbull commented Jan 2, 2020

bors try

bors bot added a commit that referenced this pull request Jan 2, 2020
@therealprof
Copy link
Contributor

Seems a bit heavy and weird to do this with floating point operations.

Co-Authored-By: Daniel Egger <daniel@eggers-club.de>
@Tiwalun
Copy link
Contributor Author

Tiwalun commented Jan 2, 2020

You're right, it's neater this way. I applied your suggestion.

@bors
Copy link
Contributor

bors bot commented Jan 2, 2020

try

Build failed

@Tiwalun
Copy link
Contributor Author

Tiwalun commented Jan 2, 2020

I'm wondering if this still has an issue with larger fields, for example if I declare a 17 bit wide register,
this will use a 24 bit width to calculate the offset.

However, the register width is mapped to to the next power of two, and the register field will actually be 32 bit wide.

rsize.next_power_of_two()

It might make more sense to use the actual width of the register in this calculation, instead of calculating it again.

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

bors r+

bors bot added a commit that referenced this pull request Jan 3, 2020
419: Round up when calculating register size in bytes r=therealprof a=Tiwalun

This fixes the issue in #418.

Co-authored-by: Dominik Boehi <dominik.boehi@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jan 3, 2020

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants