-
Notifications
You must be signed in to change notification settings - Fork 19
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: Fields constructed of multiple ranges of bits #36
Comments
In theory, this syntax should work. I tried to implement it, but for some reason I don't understand |
I think the issue is that the part after the I don't know how to change that. |
(As a side note, I also implemented a RISC-V emulator in rust: https://gitlab.com/dzamlo/emuriscv) |
I think it should be possible to simply use :
as a syntax, but I find that a bit confusing and error-prone. |
I'm working on a RISC-V emulator and I use this crate to easily extract fields from RISC-V formatted instructions.
It's pretty nifty.
RISC-V instructions sometimes have values encoded inside of them that should be used in computations, called immediates.
For some instruction formats, these immediates are split into parts to fit around other fields.
E.g.:
Here, the immediate is split into two parts with the upper 7 bits in the range 31, 25 and the next 5 bits in the range 11, 7.
With the current implementation, I have these as separate fields
imm_11_5
andimm_4_0
and I construct the immediate by a shift and bitwise OR.It would be really nifty if I could specify fields that were composed of ranges of bits like:
Preferably with some syntax that doesn't break compatibility.
I'm not very proficient with writing macros, but I could probably look to implement this myself if it's not something you can be bothered with.
If so, what should the syntax look like?
I think the array of tuples looks pretty good, but I'm not sure if it would collide with some other syntax.
The text was updated successfully, but these errors were encountered: