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
Unusual code in Operator for << and >> #548
Comments
This is intentional. Basically, if we special-case
That's a leftover of some very early changes. We can get rid of that. |
I'm curious, do you have a case where constant folding would help you? In general shape determination in nMigen is very conservative, so I'm not sure if fixing this particular instance would help a lot. |
No, I just thought it was a bit odd to see that. Truncation "just works": x = Signal(32)
y = Signal(32)
m.d.comb += y.eq(x << 5)
m.d.comb += Assert(y == (x << 5)[:32]) so it never really matters. Clearly if I did something like: x = Signal(32)
y = Signal(len(x << 5)) It would make a difference, but honestly I never do that and I don't see why anyone else would. |
This didn't make sense to me:
The code causing this comes from
Operator
:Effectively, the constness of the shift amount is not used.
Two points:
__check_shamt
prevents shifting by a signedValue
, sob_signed
will never be true.Is it okay to put some extra code in there to handle the case where we are shifting by a
Const
and be a bit more surgical in the computing the new width?The text was updated successfully, but these errors were encountered: