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

Yosys Verilog Parsing Error: Unable to Synthesize After Reading File #4427

Open
LoSyTe opened this issue Jun 4, 2024 · 2 comments · May be fixed by #4437
Open

Yosys Verilog Parsing Error: Unable to Synthesize After Reading File #4427

LoSyTe opened this issue Jun 4, 2024 · 2 comments · May be fixed by #4437
Labels

Comments

@LoSyTe
Copy link

LoSyTe commented Jun 4, 2024

Version

yosys 0.41+126

On which OS did this happen?

Linux

Reproduction Steps

Hello,
I encountered an error while using Yosys to read a Verilog file. The steps and the error message are as follows:
截图 2024-06-04 21-27-09

After this error, the parsing process is interrupted. I have checked the Verilog file for syntax errors but couldn't find any obvious issues. I am using the latest version of Yosys.

Attached is the Verilog file (design.v) that triggers the error.
Thank you in advance for your attention to this matter.
I look forward to hearing from you regarding this issue.
design_file.zip

Expected Behavior

synthesis success

Actual Behavior

synthesis fail

@LoSyTe LoSyTe added the pending-verification This issue is pending verification and/or reproduction label Jun 4, 2024
@KrystalDelusion
Copy link
Member

KrystalDelusion commented Jun 10, 2024

Changing lines 31 and 32 to the following makes it compile fine:

                  reg289[(3'h6):(3'h5)] : {"Q",
                      ($unsigned((8'hb6)) ? "t" : "e")}));

Looking at the source where the assert is being raised it seems to be a problem with the parsing of string constants: // create an AST node for a constant (using a string in bit vector form as value). The git blame in that section also has the commit message "Fixed constant "cond ? string1 : string2" with strings of different size," which leads me to suspect that this is the same bug that was previously believed to be fixed. Extending the "t" string to the same length as "eLOYX7WZioxFD2iW" also fixes the problem, so that does seem to be what is happening, however swapping the order of strings such that the longer string is first also fixes the problem.

@KrystalDelusion KrystalDelusion added bug and removed pending-verification This issue is pending verification and/or reproduction labels Jun 10, 2024
KrystalDelusion added a commit that referenced this issue Jun 10, 2024
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.
Only leading (and trailing) null characters should be dropped from the decoded string, rather than all null characters.
@KrystalDelusion KrystalDelusion linked a pull request Jun 10, 2024 that will close this issue
@KrystalDelusion KrystalDelusion linked a pull request Jun 10, 2024 that will close this issue
@KrystalDelusion
Copy link
Member

KrystalDelusion commented Jun 10, 2024

Minimal example (for the error):

module top ();
wire [15:0] x = {"1", "\0"};
endmodule

wire [23:0] y = {"1", 1 ? "a" : "bc"}; is closer to the example given here, combining both the problem above and the zero extension used in the ternary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants