-
Notifications
You must be signed in to change notification settings - Fork 897
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
Optimization Sequence Induces Synthesis Errors Leading to Simulation Inconsistencies #4483
Comments
Hi, thanks for the report. #4445 (comment) applies here as well. Since this is randomly generated code, please report this as a part of the issue. Are you capable of reducing it further with your tools? By which I mean:
such that a difference between the two flows remains? |
Thank you for your response. I am currently working on minimizing the optimization sequence as much as possible. |
Please consider how this is very difficult for us to debug and given it is not coming from a real world use case there is limited motivation to put that effort in. Although you have minimised the design and script somewhat, the testbench still uses a large amount of randomly generated input. Ideally please try to extract the core essence of the failure into a handwritten (and thus sensibly structured) testcase that clearly demonstrates an error. This makes it much easier for then debugging where synthesis has gone wrong in Yosys as time can be spent debugging Yosys rather than trying to understand your confusing testcase. If you can say something like "I think Assuming you are doing this work in preparation for an academic publication or similar, you will be able to get better statistics about bugs actually being fixed as the result of your work if you help us by providing testcases that can actually be debugged. Also as a side note, you can wrap code in two sets of 3 backticks and a language name (e.g. verilog) to make it display better on github |
I haven't been able to understand your testbench much but this case does look like it may be that both optimized versions are valid, they just exploit the fact that wire4 is undriven differently, with one propagating an x forwards and one treating it as a don't care and refining to a concrete value. |
Hello, thank you very much for your reply. I tried to modify the custom optimization sequence again. I found that the final simulation results of custom hierarchy; proc; opt; abc; and direct use of synth were also inconsistent. Even when Replace opt with any pass in opt, such as opt_clean, and the final simulation result will be different from the default synth. |
That is not what i am getting at, I mean to suggest that "the final simulation result will be different from the default synth" is far too vague to be useful for debugging, you should try to dive into exactly what constructs are causing what issues. I had a quick further look at this issue and I believe my earlier comment that these are both correct synthesis results is true, one has just been refined more than the other. Running Running just These are both valid results, they have just had different amounts of lowering. Synthesis passes do not preserve an equivalence relation, but instead a notion of refinement. This blog post talks about the same concept but instead in the context of the llvm compiler. |
Thank you very much for your reply. I understand somewhat, but I have questions. In fact, the two processes are equivalent. However, when using Iverilog for functional simulation verification, as I described in the previous picture, there are indeed inconsistencies in the binary code. situation, then the waveform diagram of the functional simulation is different. Is this possibly an error of the Iverilog simulator? Or is it possible that comprehensive files with the same function may have inconsistent simulation results? |
Yes this is possible when the files are synthesized, as seen here. Consider the following verilog module top(output logic y);
assign y = 'x;
endmodule It is perfectly valid for this to be optimized by the synthesis tool to assign y = '1; or to assign y = '0; as If you want to check correctness of synthesis in this way, you could either avoid ever generating anything with nondeterminism like Even this may not actually be enough in all cases, but I can't think of any this wouldn't work for off the top of my head. |
The supposed inconsistency was found by George to be a valid refinement, I'm closing this issue as invalid |
Version
yosys 0.41+126
On which OS did this happen?
Linux
Reproduction Steps
Hello,
I have encountered an inconsistency issue during synthesis with Yosys.
My Icarus Verilog version is: Icarus Verilog version 13.0 (devel) (s20221226-221-g272771d18), and my Yosys version is 0.41+126.
During synthesis, we did not use the default Yosys synthesis process but employed a custom pass optimization sequence. The synthesis commands for both processes are as follows:
1、Using Yosys' default synthesis process:
read_verilog rtl.v
synth
write_verilog syn_yosys.v
2、Custom optimization sequence:
read_verilog rtl.v
prep -ifx; hierarchy; flatten; proc -ifx; opt_dff -nodffe; opt_lut; opt_expr -noclkinv; memory_libmap; opt_lut; opt_dff -sat; opt_expr -undriven; memory_dff; opt_merge -share_all; memory_collect; opt_muxtree; fsm_map; opt_expr -mux_bool; opt_mem_priority; opt_dff -keepdc; memory_bmux2rom; opt_expr -noclkinv; opt_lut_ins; opt_expr -undriven; check; check; opt_muxtree; opt_expr -mux_undef; opt_merge; opt_mem; memory_bram; fsm_recode; opt_clean; opt_clean -purge;
write_verilog new_syn_yosys.v
The changes in the optimization sequence should not affect the consistency of the code. However, we have observed inconsistencies in the simulation outputs when using the synthesized files generated by these two different synthesis processes with Icarus Verilog (as highlighted in the red box in the attached image).
Default synthesis process,the first line of output is:
Custom optimization sequence,the first line of output is:
This inconsistency suggests that the optimization sequence may be causing synthesis errors, leading to inconsistent simulation results.
I would appreciate your assistance in identifying the root cause of this issue.
Attached is my design file (rtl.v) and the executable script file (yosys.sh).
Thank you.
yosys_project.zip
Expected Behavior
The simulation results are consistent
Actual Behavior
Simulation results are inconsistent
The text was updated successfully, but these errors were encountered: