Closed alikates closed 3 months ago
I noticed this is independent of the sync reset, it seems to happen whenever there's an async reset. Let me check if theres any memory with async reset that is being correctly inferred...
Oops, I just noticed that 1) async reset detection is already implemented as Nvm I just saw bc6b5eec509007d2ce12f4ab7c13ef6fbc4fa4b9, so I guess we have to do it anywaysproc_arst
at RTLIL level, and 2) that pass was not being called by the frontend.
So, going back to what I thought about previously. Add the current UpdateTiming to SignalEvalContext and infer the reset by checking if the signal is in the sensitivity and also drives the memory write port. The only thing I found a bit annoying but probably has a reason is that we have to infer the async-reset signal from the $memwr
cell, but use it as input for $memrd
~Oops, I just noticed that 1) async reset detection is already implemented as
proc_arst
at RTLIL level, and 2) that pass was not being called by the frontend.~ Nvm I just saw bc6b5ee, so I guess we have to do it anyways
Yes, to give context on the choice not to rely on sync rules: YosysHQ/yosys#4231 amaranth-lang/amaranth#603
The only thing I found a bit annoying but probably has a reason is that we have to infer the async-reset signal from the $memwr cell, but use it as input for $memrd
I don't think this transformation is functionally correct. The ARST
input on $memrd_v2
does not reset the memory content, only the current output of the read port, if the read port is a synchronous one.
The way out here is to make sure variables are not inferred as memories if they are written to from the asynchronous branch of the async always_ff pattern.
Okay, sorry. I didn't know about the implications of memory cells. Then if its async reset, disqualify for inference and go for plain DFFs right?
Yes, exactly!
Fixed in 5aaa6e7
After a couple really small changes to the RTL I managed to have the Sargantana core totally parsed. But when trying to synthesize for FPGA (ECP5 in this case) I'm facing this error, which is related to the module
rtl/datapath/rtl/exe_stage/rtl/div_unit.sv
:I took a look at the RTL and this seems to be caused by a pattern equivalent to this:
As you can see, the
counter
memory is not totally reset, but only the part selected bysel_i
. I checked the RTLIL and found out that for the async reset, the clock of the memory cell is therstn_i
signal, and the regular write port usesclk_i
as expected. On the other hand, I'm seeing that for the read side, the synchronous and asynchronous reset inputs are always tied to 0. I assume for correctly setting the resets we would need to detect which signal is a reset (i guess the most simple heuristic would be if it is inside the sensitivity list and also enables writes to the memory).