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

Feature request: Right-padded fields #37

Open
mumblingdrunkard opened this issue Dec 30, 2023 · 0 comments
Open

Feature request: Right-padded fields #37

mumblingdrunkard opened this issue Dec 30, 2023 · 0 comments

Comments

@mumblingdrunkard
Copy link

Somewhat related to #36

I'm creating a RISC-V emulator and the instruction formats sometimes encode values in the instructions, called immediates.
Sometimes, the instruction only contains the upper few bits of the immediate value.
E.g.:
image
Here, only the upper 20 bits are included in the instruction, from bit 31 to 12. and the lower 12 bits of the immediate should be set to 0.
I imagine syntax similar to the one proposed in #36 but with literal values that should occupy some number of bits in the field; e.g.:

imm, _: [(31, 12), 12(0)];
// alternatively
imm, _: 31, 12, 12(0);

It does raise the question of how the setter works when the field has padding.
I imagine it should just mask away the padded section, or simply panic when there are non-zero bits in the padded section.

It shouldn't be too difficult to support internal padding, but I can't imagine a good use case for that.

I understand that this is probably reaching outside the scope of what this package is meant to do, but it would certainly make my code a lot cleaner :).

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

No branches or pull requests

1 participant