Closed leonardt closed 5 years ago
As far as I can tell, what is happening here is that the memory map process is failing to correctly identify the write port, thus producing a memory with an asynchronous write port that cannot be mapped in any sensible way.
Clearly the memory is being written in a synchronous way however. Running this script, which is the synthesis process until anything memory-related starts:
read_verilog -lib +/ice40/cells_sim.v
read_verilog stencil.v
hierarchy -top main
proc
flatten
opt_expr
opt_clean
opt
wreduce
alumacc
share
opt
fsm
opt -fast
write_ilang dump.ilang
Shows the following write port - at this point lacking a clock is OK because memory_dff hasn't been run yet:
cell $memwr $techmap\inst49.inst0.lbmem_1_0.mem.$memwr$\data$stencil.v:750$74
parameter \ABITS 4
parameter \CLK_ENABLE 0
parameter \CLK_POLARITY 0
parameter \MEMID "\\inst49.inst0.lbmem_1_0.mem.data"
parameter \PRIORITY 74
parameter \WIDTH 8
connect \ADDR $techmap\inst49.inst0.lbmem_1_0.mem.$memwr$\data$stencil.v:750$68_ADDR
connect \CLK 1'x
connect \DATA \inst49.inst0.lb1d_0.reg_1.outReg
connect \EN 8'11111111
end
Then running memory_dff, we get:
16. Executing MEMORY_DFF pass (merging $dff cells to $memrd and $memwr).
Checking cell `$techmap\inst49.inst0.lbmem_1_0.mem.$memwr$\data$stencil.v:750$74' in module `\main': no (compatible) $dff for data input found.
Checking cell `$techmap\inst49.inst0.lbmem_1_0.mem.$memrd$\data$stencil.v:752$73' in module `\main': merged data $dff to cell.
This shows there is a problem with the data input. Looking at the data port, in the ilang dump, we see that although the net connect to the data input is correctly driven by a $dff, it also fans directly out to a number of LUT inputs which means that it can't be folded into the memory write port. I suspect this is an overly eager optimisation pass doing this.
I think this could be solved in two ways:
Thanks for taking a look at this and the quick response! Tagging @adamdai, a fellow collaborator, so he will get notification of the resolution.
Steps to reproduce the issue
Attached a .zip that includes the input verilog file (stencil.v), the input
.pcf
for arachne-pnr, and the output.blif
from yosys. Also includes a Makefile with the relevantyosys
andarachne-pnr
command.stencil.zip
arachne-pnr version
Checkout and install yosys
4f31cb6d
NOTE: Because
abc
has moved to github and removed the makefile from the default clone of their repository, I had to make the following patch to the makefile, otherwise it fails when trying to call make cleanrun make with files in attached .zip (icepack command running not required, should just show
arachne-pnr
not failing. Here is the output.blif
file: blif.zipCheckout and install yosys master
run make with files in attached .zip
Here's the blif file that it generates: blif.zip
Expected behavior
An old version of yosys was able to correctly compile the
coreir_mem
module for the ice40 target to a.blif
file thatarachne-pnr
could place and route.Actual behavior
The latest version of yosys master produces a
$mem
cell whicharachne-pnr
cannot place.The verilog module of interest is copied below
It seems that when I make a smaller design using the memory, such as
yosys and arachne can compile it. Here is the input verilog and output blif for the above small example (also includes .pcf and makefile) small.zip