Xilinx / RapidWright

Build Customized FPGA Implementations for Vivado
http://www.rapidwright.io
Other
284 stars 109 forks source link

Modify Design.placeCell() to find compatible SiteTypeEnum if SiteInst does not exist #91

Closed clavin-xlnx closed 3 years ago

clavin-xlnx commented 3 years ago

Some sites can support multiple site types. In certain situations when placing a cell onto a BEL of a secondary site type when the SiteInst has not yet been created, placeCell() can fail with an error as limits the search to just the primary site. The issue can be reproduced from the code/design example below:

top.zip

from com.xilinx.rapidwright.design import Design
from com.xilinx.rapidwright.device import SiteTypeEnum

design = Design.readCheckpoint('top.dcp')
cellInst = design.getNetlist().getCellInstFromHierName("clk_IBUF_BUFG_inst")
cell = design.createCell(cellInst.getName(),cellInst)
site = design.getDevice().getSite("BUFGCTRL_X0Y16")
bel = site.getBEL("BUFG")
design.placeCell(cell,site,bel)

A work around is to create the SiteInst first:

...
site = design.getDevice().getSite("BUFGCTRL_X0Y16")
siteInst = design.createSiteInst(site.getName(), SiteTypeEnum.BUFG, site)
bel = siteInst.getBEL("BUFG")           
design.placeCell(cell,site,bel)

However, the top example should work if the SiteInst has not yet been created for the site which currently takes place in Design.placeCell().

clavin-xlnx commented 3 years ago

It turns out the code above is not quite correct in that the bel variable is null because the site is not of the right SiteTypeEnum. This went unchecked, but as of 2020.1.5, Design.placeCell() checks the parameters to ensure they are not null.