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

tgt-vvp: Use signedness of expression instead of signal for index load #1166

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

larsclausen
Copy link
Collaborator

@larsclausen larsclausen commented Sep 2, 2024

When loading a signal into into an index register currently the signedness of the signal is used when deciding whether sign-extension should be performed or not. But this can lead to incorrect results, instead the signedness of the expression must be used as that might be different from the signal. E.g.

reg signed [1:0] = 2'b10;
$display(1 << x[1:0]);

gives the wrong result without this.

Resolves #1165

When loading a signal into into an index register currently the signedness
of the signal is used when deciding whether sign-extension should be
performed or not. But this can lead to incorrect results, instead the
signedness of the expression must be used as that might be different from
the signal. E.g.

```
reg signed [1:0] = 2'b10;
$display(1 << x[1:0]);
```

gives the wrong result without this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Add a regression test to check that the right-hand side of a shift
operation is always treated as unsigned, even if it is a signed registers
or a variation thereof.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
@martinwhitaker martinwhitaker merged commit 74ba42e into steveicarus:master Sep 7, 2024
5 checks passed
@larsclausen larsclausen deleted the fix-ix-load-sign branch September 9, 2024 02:54
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

Successfully merging this pull request may close these issues.

Incorrect result from shift operation
2 participants