How to place a BUFG in RapidWright

56 views
Skip to first unread message

wenchen

unread,
Nov 2, 2020, 9:24:22 AM11/2/20
to RapidWright
Hi Chris,

I'm trying to place a post-synthesis manually in RapidWright.

module top(
  input clk,
  input [1:0] in0,
  input [1:0] in1,
  output [3:0] out);
 
   reg [2:0] result;

    always @(posedge clk)
      result <= {(in1[1]&in0[1])|((in1[0]&in0[0])&(in1[1]^in0[1])),(in1[1]^in0[1])^(in1[0]&in0[0]),in1[0]^in0[0]};
     
   assign out[2:0] = result;
  assign out[3] = in1[1];

endmodule

To have a reference, I also implement the design in Vivado. The figure below is generated by Vivado and shows that clk_IBUF_BUFG_inst is placed to CLK_BUFG_TOP_R_X60Y53/BUFGCTRL_X0Y16/BUFG.

6.PNG



But I met some trouble when trying to reproduce the above figure in RapidWright. My code is given below:
design = Design.readCheckpoint('top.dcp')
netlist = design.getNetlist()
library = netlist.getLibrary("hdi_primitives")
topCell = netlist.getTopCell()

...

design.placeIOB(topCell.getCellInst("clk_IBUF_inst"), "E3", "LVCMOS33")

def placeCells(design):
   cell_names = design.getNetlist().getTopCell().getCellInsts().toArray().tolist()
   placement_list = []
   for cell_name in cell_names:
       print(str(cell_name.getCellType())+'/'+str(cell_name))
       if ("BUFG" in str(cell_name.getCellType())):
           cell = design.createCell(str(cell_name),cell_name)
           site = design.getDevice().getSite("BUFGCTRL_X0Y16")
           bel = site.getBEL("BUFG")
           design.placeCell(cell,site,bel)
           print(bel)

placeCells(design)


The output is given below:
GND/GND
VCC/VCC
BUFG/clk_IBUF_BUFG_inst
...
ERROR: Site type BUFGCTRL not supported for cell type BUFG

According to Vivado, it seems that cell type BUFG belongs to BUFGCTRL, however, RapidWright tells "Site type BUFGCTRL not supported for cell type BUFG". So how to place a BUFG in RapidWright?

wenchen

unread,
Nov 2, 2020, 9:56:02 AM11/2/20
to RapidWright
One possible reason is that "Vivado will show BUFG in the logical netlist. When the Vivado placer is run, the BUFG cell will be placed at a BUFGCTRL location, but the schematic will continue to show BUFG".
The following code works
        elif ("BUFG" in str(cn.getCellType())):
            cell = design.createCell("BUFGCTRL", Unisim.BUFGCTRL)
            site = design.getDevice().getSite("BUFGCTRL_X0Y16")
            bel = site.getBEL("BUFGCTRL")
            design.placeCell(cell,site,bel)



在 2020年11月2日星期一 UTC+8下午10:24:22,wenchen写道:

RapidWright

unread,
Nov 2, 2020, 6:59:18 PM11/2/20
to rapid...@googlegroups.com
The problem here is that some sites can implement multiple site types.  The site BUFGCTRL_X0Y16 can be a site of type 'BUFG' or 'BUFGCTRL', see this Vivado screenshot from the Site properties window:

sitetypes.png


The primary site type is BUFGCTRL which is what RapidWright is initializing the SiteInst to when it is created.  The SiteInst is being created in your code above when you call design.placeCell(), but RapidWright is not smart enough yet to identify that the underlying site type doesn't match the cell type (I'll file an issue on this to get it resolved).  

To work around this issue, you'll just need to create the SiteInst upfront and choose the site type at initialization:

def placeCells(design):
   cell_names = design.getNetlist().getTopCell().getCellInsts().toArray().tolist()
   placement_list = []
   for cell_name in cell_names:
       print(str(cell_name.getCellType())+'/'+str(cell_name))
       if ("BUFG" in str(cell_name.getCellType())):
           cell = design.createCell(str(cell_name),cell_name)
           site = design.getDevice().getSite("BUFGCTRL_X0Y16")
           siteInst = design.createSiteInst(site.getName(), SiteTypeEnum.BUFG, site)
           bel = siteInst.getBEL("BUFG")           
           design.placeCell(cell,site,bel)
           print(bel)

Thanks for pointing this out.

Chris

wenchen

unread,
Nov 2, 2020, 11:52:53 PM11/2/20
to RapidWright
Thank you Chris
在 2020年11月3日星期二 UTC+8上午7:59:18,RapidWright写道:
Reply all
Reply to author
Forward
0 new messages