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
Maykeye opened this issue Jan 3, 2020 · 1 comment
Closed
Labels
Milestone

Comments

@Maykeye
Copy link

Maykeye commented Jan 3, 2020

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.

@whitequark
Copy link
Contributor

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
Projects
None yet
Development

No branches or pull requests

2 participants