kernel: treat zero width constant as zero#5182
Conversation
|
Can confirm this fixes Sentinel CI failures when I test this patch locally. I'll just have to wait until a |
|
Maybe it would be useful to have a few amaranth designs in the test suite - verilog derived designs generally shouldn't end up with zero width cells. |
|
Treating a disconnected port (zero width or not) as a constant instead of undefined feels counter intuitive to me... Is there precedence for this elsewhere in Yosys, or is it just that it worked before so we shouldn't change it? |
|
Yeah I am equally kinda uncomfortable with it which is why I had put an assertion guarding against it in there in the first place - to me it seemed like something that wouldn't be super well defined and should be avoided. That being said, it does seem that amaranth codegen seems to rely on this behaviour so we should support some behaviour for it. The existing Also worth noting that this new I'm not sure any of this is 100% convincing, but after thinking about it for a bit it seems as reasonable approach as any to me and shouldnt change existing behaviour. |
Yeah actually that does seem reasonable |
I'm not sure I agree. A zero-width concatenation isn't the same as being disconnected, is it? |
|
|
Oh, that's... cursed. I think this is an issue with the RTLIL design, but now that you bring it up I also think that Amaranth may be misusing RTLIL here. |
|
@KrystalDelusion On discussion, I think this is wrong. There aren't any port bits that aren't being connected here. The port is also zero width: |
|
Also, wouldn't a disconnected port just be missing from the connection list of a cell? |
Nope |
I don't see how your snippet suppots your conclusion. All it shows is that internal cells don't allow ports to be disconnected. |
The cell that started this PR/discussion was a $shr cell, I said that a connection to yosys/backends/rtlil/rtlil_backend.cc Lines 107 to 119 in a0a77cd That's what gets called when dumping a cell. |
|
For what it's worth I was initially trying to show |
Yes, that is what I'm trying to tell you. |
|
Friendly ping, has this been forgotten about? |
|
Disappointingly this wasn't a part of the last release.. |
That's probably my fault. I was getting frustrated with the discussion and had to stop engaging. |
|
Yeah I've been away a lot in the past few weeks and not particularly actively keeping track of things, I probably could have prodded it as well. |
What are the reasons/motivation for this change?
Fixes #5175
Explain how this is achieved.
Zero width constants are special cased and treated as the constant value zero.
If applicable, please suggest to reviewers how they can test the change.
The testcase from #5175