Closed sylefeb closed 3 years ago
This sounds like it might be a dfflegalize interaction, although I haven't looked in any detail. I'll ping @mwkmwkmwk anyway.
This is a memory_dff
bug uncovered by an interaction with opt_dff
— opt_dff
basically optimizes away the address register on the write port into a const driver, and then memory_dff
is unable to recognize a synchronous write port. It goes downhill from there.
This should be fixed now that #2605 has landed — can you check it?
I confirm this is fixed in Yosys 0.9+4008 (git sha1 26e01a67, gcc 10.2.0 -fPIC -Os) - thanks!
Summary
I observe a change in behavior in Yosys that results in failed BRAM inference, between an older and the most recent version (version details below). I include at the end a repro code, which I tried to make small.
The issue seems to come from how constant values applied to a port enable are treated. What this example does is to either use a constant wire (assigned to 0) or a flip-flop that cannot be removed by synthesis (due to lack of initialization).
In older versions using a constant wire has the desirable effect of simplifying the BRAM. In the latest version the constant wire leads to either a port in async or a non-recognized BRAM as below. Note that if the flip-flop is given an initial value of 0, yosys will remove it which also leads to a failed inference.
Steps to reproduce the issue
Using the attached example, commenting out USE_FLIPFLOP_ON_WENABLE at the top triggers the issue in the latest version (0.9+3743 git sha1 13a27055).
Expected behavior
Ideally as with version Yosys 0.9+3537 (git sha1 c75d8c74), where both cases would lead to an inferred BRAM, and using a constant wire on a port would lead to the BRAM being simplified (dual => simple dual => single => rom).
Actual behavior
When assigning a constant wire to the wenable port, the BRAM inference fails.
Details
Command line
yosys -l yosys.log -p 'synth_ecp5 -abc9 -json build.json' 1_build.v
Using Yosys 0.9+3537 (git sha1 c75d8c74, gcc 10.1.0 -fPIC -Os)
Disabling
USE_FLIPFLOP_ON_WENABLE
the BRAM is accepted:Enabling
USE_FLIPFLOP_ON_WENABLE
the BRAM is accepted:Yosys 0.9+3743 (git sha1 13a27055, gcc 10.2.0 -fPIC -Os)
Disabling
USE_FLIPFLOP_ON_WENABLE
the BRAM is rejected:Enabling
USE_FLIPFLOP_ON_WENABLE
the BRAM is accepted:Code
(made minor edits for typos)