Open WeneneW opened 1 month ago
If this is the underlying cause for #4369 can you close that issue since this is more clear about the exact problem. This is still not the best minimal example, but it is better.
Narrowing it down even further by calling read_verilog -dump_vlog1 rtl.v
, I believe this may be related to the line case (|({(wire2[1'b 1:1'b 0])~^(0'b )}))
, where it is trying to xnor against a zero bit value, but the output of write_verilog is 1'b0
and that difference is being picked up down the line when the expression is evaluated. I will also note that when assigning to a wire first (and getting e.g. assign _15_ = (wire2[1:0])~^(0'b );
in the vlog1 dump) does not result in a difference in behaviour, so it is specific to the evaluation of the if and not the 0'b
itself.
If this is the underlying cause for #4369 can you close that issue since this is more clear about the exact problem. This is still not the best minimal example, but it is better.
Narrowing it down even further by calling
read_verilog -dump_vlog1 rtl.v
, I believe this may be related to the linecase (|({(wire2[1'b 1:1'b 0])~^(0'b )}))
, where it is trying to xnor against a zero bit value, but the output of write_verilog is1'b0
and that difference is being picked up down the line when the expression is evaluated. I will also note that when assigning to a wire first (and getting e.g.assign _15_ = (wire2[1:0])~^(0'b );
in the vlog1 dump) does not result in a difference in behaviour, so it is specific to the evaluation of the if and not the0'b
itself.
Thank you very much for your reply. This is indeed the reduced test case version of my previous question, and I have already closed the previous question. Best wishes to you
Yeah, that's an error in the frontend: according to 1364-2005 5.2.3.3,
The null string ("") shall be considered equivalent to the ASCII NUL ("\0"), which has a value zero (0), which is different from a string "0".
Which would make it equivalent to 8'b0
.
(cf #3103 fixing this in the backend, it seems the same misunderstanding is still present in the frontend)
'
Thank you for your reply
Version
Yosys 0.39+165
On which OS did this happen?
Linux
Reproduction Steps
My Verilog original design is as follows:
The content of the testbench file is as follows:
For this design, I used the same testbench file to simulate the code before and after yosys synthesis. However, there were inconsistencies between the original design simulation and the synthesized simulation.
![fe61ab69ac405782bd36382ca3bf33dc](https://github.com/YosysHQ/yosys/assets/168843330/ff8f30ac-ee50-4b66-858d-f51d0121e69b)
However, when I change the if statement in the code from
if ({(wire2[(1'h1):(1'h0)] ^~ "")})
toif ({(wire2[(1'h1):(1'h0)] ^~ "a")})
, replacing the empty string with another string or a different binary number, this inconsistency disappears.The directory structure of the compressed package is as follows: yosys_5_13.zip
rtl.v
is the original design. Files with thesyn_
prefix represent the synthesized versions. You can compare the vvp.log files located in the identity and yosys directories. Additionally, you can rerun simulations on the synthesized files by executingbash run_sim.sh.
Expected Behavior
The simulation before and after synthesis is consistent, just like Vivado
Actual Behavior
Inconsistent output before and after synthesis