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

Boolean Operations on Fields and Signals #154

Closed
willy134 opened this issue Feb 24, 2023 · 1 comment
Closed

Boolean Operations on Fields and Signals #154

willy134 opened this issue Feb 24, 2023 · 1 comment

Comments

@willy134
Copy link

Looking through the compiler examples and test cases, I never could find an example of the boolean operations.

I was looking for something like this

reg {
    field {
       desc="Write 0x9A to unlock register"
       sw=rw;
       hw=na;
     } unlock[31:16];
    field {
      desc="locked field";
      sw=rw;
      hw=r;
    } locked[7:0];
    locked->swwe = unlock->next == 0x9A || unlock == 0x9A;
}

The hope is that the boolean == and || operations actually result in a boolean value for the swwe signal in this case. I also see use cases where a register is reset when a magic key is written to it (think watchdog timer).

Are there any known examples of these boolean operations? Does my interpretation of the spec make sense? I could create similar things with the external swwe signal, but it would lack the ability to use the next reference.

The error I am seeing when I try this is:
fatal: Left and right operands of expression are not compatible types

@amykyta3
Copy link
Member

Currently, this compiler only supports constant expressions that resolve to an integral value or a single reference (See https://systemrdl-compiler.readthedocs.io/en/stable/known_issues.html#property-assignments-using-references-shall-be-constant)

Eventually I may support this by preserving non-constant expressions as an AST so that developers can transcribe them to the output language. This would likely be part of #58 since the concepts are closely related.

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

2 participants