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

There's no explicit way to convert between signed <-> unsigned values #292

Closed
nmigen-issue-migration opened this issue Jan 3, 2020 · 1 comment
Labels
Milestone

Comments

@nmigen-issue-migration
Copy link

Issue by Maykeye
Friday Jan 03, 2020 at 07:19 GMT
Originally opened as m-labs/nmigen#292


I have an unsigned signal. I want to compare it as signed for a change and now there are no good explicit way to do it.

  • I can make new Signal(signed(old.width)) and equate it to the old one, but in order to do so, I must place all such signals in the beginning of elaborate: if I create a copy somewhere in the middle like with m.If(en): comb+= make_signed_copy(n)<10, generator will not be able to generate wire[31:0] signed_n = n, instead it will create register because if if-branch is not executed, signed_n is not being written

  • There's implicit conversion: I can use -(-n), and rely on optimizers down the road, but it feels hacky.

@nmigen-issue-migration
Copy link
Author

Comment by whitequark
Friday Jan 03, 2020 at 07:31 GMT


Proposed API: Value.to_signed / Value.to_unsigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant