-
Notifications
You must be signed in to change notification settings - Fork 211
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
Negative initialization produces incorrect verilog #142
Comments
Your signal must be signed for a negative value to be legitimate. Migen should print an error here instead of emitting invalid verilog, maybe at the minimum add an assert in |
Though this isn't consistent with what happens when assigning a negative value to an unsigned signal; so maybe |
It's probably horrible practice, but I do it to set a signal to 0xFF regardless of its length. The rest of the code uses it unsigned. |
Signal(max=depth, ~0) produces the same incorrect code. What's the right way to initialize a signal to all 1s? |
2**depth-1 |
I think it would have to be 2**(ceil(log2(depth))-1 right? -1 or ~0 is much easier, and should be supported for this case in my opinion. |
OK. |
Triage: fixed in nMigen. In particular, |
Migen:
self.idx = Signal(max=depth, reset=-1)
Generated Verilog:
reg [3:0] sdram_bankmachine0_cmd_buffer_lookahead_idx = 4'd-1;
The assigned value should be -4'd1 instead to be valid Verilog. Not my favourite thing about the language.
The text was updated successfully, but these errors were encountered: