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

Register decoding does not work correctly when fields are represented in msb0 mode #48

Open
maltaisn opened this issue Mar 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@maltaisn
Copy link

maltaisn commented Mar 12, 2024

When entering a value in the "Encoded Register Value", the decoding doesn't work correctly. For this RDL source:

addrmap registers {
  default regwidth = 32;
  default memwidth = 32;
  default accesswidth = 32;

  reg {
    name = "Version";
    field {} VERSION_REVISION[0:7];
    field {} VERSION_BUILD[8:15];
    field {} VERSION_MINOR[16:23];
    field {} VERSION_MAJOR[24:31];
  } version;
};

Example result:
image

I'm also not sure what behavior is expected when entering a field value. The field text field always goes red it seems.

I'm using peakrdl-html v2.10.1 and Firefox. Also fails in Edge.

@maltaisn maltaisn changed the title Register decoding does not working correctly Register decoding does not work correctly Mar 12, 2024
@amykyta3
Copy link
Member

amykyta3 commented Mar 13, 2024

Thanks for reporting this!

This is definitely a bug, but there's actually a few things going on here.

SystemRDL defines this strange register packing mode called "msb0 mode" which means that the upper bit of a register is the least-significant bit instad of most-significant. You can switch to this mode explicitly by using the msb0 property, or infer it by using [low:high] bit ordering.
Assuming that using msb0 mode was not your intention, try flipping your fields to define bit-order using the lsb0 notation of [high:low]. That is more conventional for field definitions and I assume is what you intended.

  reg {
    name = "Version";
    field {} VERSION_REVISION[7:0];
    field {} VERSION_BUILD[15:8];
    field {} VERSION_MINOR[23:16];
    field {} VERSION_MAJOR[31:24];
  } version;

All that said, this is definitely a bug in the HTML generator - it ought to be able to support the alternate msb0 bit-mode correctly.

@amykyta3 amykyta3 changed the title Register decoding does not work correctly Register decoding does not work correctly when fields are represented in msb0 mode Mar 13, 2024
@amykyta3 amykyta3 added the bug Something isn't working label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants