YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.3k stars 860 forks source link

rtlil.cc: Fix #4427 #4437

Open KrystalDelusion opened 3 weeks ago

KrystalDelusion commented 3 weeks ago

What are the reasons/motivation for this change?

If a RTLIL::Const is composed of multiple strings, such as when using a ternary expression to select between two strings of different lengths, zero padding for the strings needs to be maintained.

Explain how this is achieved.

Only leading (and trailing) null characters should be dropped from the decoded string, rather than all null characters.

If applicable, please suggest to reviewers how they can test the change.

KrystalDelusion commented 3 weeks ago

Actually I think while this does prevent the assertion in #4427, it leads to an incorrect result. The problem was that the "t" would get width extended to match the length of "e...", and then concatenated to the end of "Q...", so that one side of the assertion is "Q...t\0" while the other is "Q...\0t". I changed the left to match the right, but I think the left side was actually the correct one and it is the right side that needs to be changed...