What is the difference between EDIFCell and EDIFCellInst

43 views
Skip to first unread message

wenchen

unread,
Oct 30, 2020, 12:38:08 PM10/30/20
to RapidWright
Hi Chris,

I'm trying to understand the basic concept of RapidWright, but I cannot figure out the difference between EDIFCell and EDIFCellInst. As given in the RapidWright tutorial, EDIF package are related to logical netlist. As far as I can understand, EDIFCell is used to store a logical netlist component that can be LUT, FDRE, IBUF, OBUF and so on. EDIFCellInst is the instance in the design.

To better illustrate my problems, I provide a simple example.
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


5.PNG



































If my understanding is right, in the above schmetic,
1. LUT2, LUT4, IBUF, OBUF, FDRE... are EDIFCell, while result[0]_i_1, result[1]_i_1, result[2]_i_1, result_reg[0], result_reg[1]... are EDIFCellInsts. 
2. The EDIFLibrary contains LUT2, LUT4, IBUF, OBUF, FDRE rather than result[0]_i_1, result[1]_i_1, result[2]_i_1, result_reg[0], result_reg[1].
3. LUT4.getCellInsts() will be result[1]_i_1, result[2]_i_1
4. result[1]_i_1.getCell() will be LUT4

Then I synthesis (only synthesis, no P&R) the verilog code in Vivado and load the dcp into RapidWright.
        Design design = Design.readCheckpoint(args[0]);
       EDIFNetlist netlist = design.getNetlist();
       EDIFLibrary library = netlist.getLibrary("hdi_primitives");
       for(EDIFCell Cell : library.getCells()){
           for(EDIFCellInst CellInst : Cell.getCellInsts()){
               System.out.println(Cell.getName()+'/'+CellInst.getName());
           }
       }


My expected output is:
GND
VCC
BUFGCE/clk_IBUF_BUFG_inst
OBUF/out_OBUF[0]_inst
OBUF/out_OBUF[1]_inst
...
LUT2/result[1]_i_0
...
IBUF


However, the actual output is 
IBUF/IBUFCTRL_INST
IBUF/INBUF_INST


There must be something wrong with my understanding, but where is it?

Thank you

Wen Chen

RapidWright

unread,
Oct 30, 2020, 8:12:21 PM10/30/20
to RapidWright
Your points 1, 2 and 4 above are correct.  Point 3 is not.  There are primitive cells (defined in the hdi_primitives library) which do not have any nets or cell instances inside them.  They are atomic and appear as a black box.  However, there are other cells in a user's design that instantiate cells and have nets that connect them.  So a cell, if queried for the cell instances it owns, would be the cell instances inside of it.  A cell definition does not know anything about where it is used or instantiated, it is simply a definition in a library.  It does know about the instances inside of it and what those cell types are.  

Because each cell can be instantiated multiple times and multiple levels of hierarchy can exist, its not always straight forward to find cell instances of a particular type.  Luckily RapidWright has a number of helper methods and classes to deal with this complexity.  Take a look at the classes that begin with EDIFHier{Net,CellInst,PortInst}.  They are wrapped versions of their non-hierarchical equivalents with the full hierarchical name to the location of the object within the netlist.  If I were to modify your code above to match what I believe is your intent, I would do the following:

Design design = Design.readCheckpoint(args[0]);
EDIFNetlist netlist = design.getNetlist();
for(EDIFHierCellInst hierInst : netlist.getAllLeafDescendants("")){
  System.out.println(hierInst.getFullHierarchicalInstName() + " (CellType=" + hierInst.getCellName() + ")");
}

Hope that helps.

Chris

wenchen

unread,
Oct 30, 2020, 10:16:32 PM10/30/20
to RapidWright
Hi Chris, 

You do get my intent. I try your code and get my expected result. However, my further question is what is the difference between EDIFHierCellInst and EDIFCellInst?
The output of 
        for(EDIFHierCellInst hierInst : netlist.getAllLeafDescendants("")){
            System.out.println(hierInst.getFullHierarchicalInstName() + " (CellType=" + hierInst.getCellName() + ")");
        }
is
GND (CellType=GND)
VCC (CellType=VCC)
VCC_1 (CellType=VCC)
clk_IBUF_BUFG_inst (CellType=BUFGCE)
out_OBUF[0]_inst (CellType=OBUF)
out_OBUF[1]_inst (CellType=OBUF)
out_OBUF[2]_inst (CellType=OBUF)
out_OBUF[3]_inst (CellType=OBUF)
result[0]_i_1 (CellType=LUT2)
result[1]_i_1 (CellType=LUT4)
result[2]_i_1 (CellType=LUT4)
result_reg[0] (CellType=FDRE)
result_reg[1] (CellType=FDRE)
result_reg[2] (CellType=FDRE)
clk_IBUF_inst/IBUFCTRL_INST (CellType=IBUFCTRL)
clk_IBUF_inst/INBUF_INST (CellType=INBUF)
in0_IBUF[0]_inst/IBUFCTRL_INST (CellType=IBUFCTRL)
in0_IBUF[0]_inst/INBUF_INST (CellType=INBUF)
in0_IBUF[1]_inst/IBUFCTRL_INST (CellType=IBUFCTRL)
in0_IBUF[1]_inst/INBUF_INST (CellType=INBUF)
in1_IBUF[0]_inst/IBUFCTRL_INST (CellType=IBUFCTRL)
in1_IBUF[0]_inst/INBUF_INST (CellType=INBUF)
in1_IBUF[1]_inst/IBUFCTRL_INST (CellType=IBUFCTRL)
in1_IBUF[1]_inst/INBUF_INST (CellType=INBUF)

However, that of 
        for(EDIFCellInst CellInst : netlist.getAllLeafCellInstances()){
            System.out.println(CellInst.getName() + " (CellType=" + CellInst.getCellType().getName() + ")");
        }
is
GND (CellType=GND)
VCC (CellType=VCC)
VCC_1 (CellType=VCC)
clk_IBUF_BUFG_inst (CellType=BUFGCE)
out_OBUF[0]_inst (CellType=OBUF)
out_OBUF[1]_inst (CellType=OBUF)
out_OBUF[2]_inst (CellType=OBUF)
out_OBUF[3]_inst (CellType=OBUF)
result[0]_i_1 (CellType=LUT2)
result[1]_i_1 (CellType=LUT4)
result[2]_i_1 (CellType=LUT4)
result_reg[0] (CellType=FDRE)
result_reg[1] (CellType=FDRE)
result_reg[2] (CellType=FDRE)
IBUFCTRL_INST (CellType=IBUFCTRL)
INBUF_INST (CellType=INBUF)
IBUFCTRL_INST (CellType=IBUFCTRL)
INBUF_INST (CellType=INBUF)
IBUFCTRL_INST (CellType=IBUFCTRL)
INBUF_INST (CellType=INBUF)
IBUFCTRL_INST (CellType=IBUFCTRL)
INBUF_INST (CellType=INBUF)
IBUFCTRL_INST (CellType=IBUFCTRL)
INBUF_INST (CellType=INBUF)
It seems that 'getAllLeafCellInstances' goes deeper than 'getAllLeafDescendants', but what is the difference between EDIFHierCellInst and EDIFCellInst?

Thank you so much.

WenChen


在 2020年10月31日星期六 UTC+8上午8:12:21,RapidWright写道:

RapidWright

unread,
Oct 31, 2020, 12:17:01 AM10/31/20
to RapidWright
EDIFHierCellInst is a wrapper around EDIFCellInst.  It keeps track of where the instance is in the overall hierarchy of the design.  If you have a reference to an EDIFCellInst, you don't know what it's parent instance is.  With a reference to the EDIFHierCellInst, you can find out any of the parent instances.

getAllLeafCellInstances() returns just the shallow instance references.  getAllLeafDesecendants() explores all the same leaf cells, it just provides the hierarchical reference and context around where that instance is located in the netlist. 

wenchen

unread,
Nov 2, 2020, 8:47:37 AM11/2/20
to RapidWright
Hi Chris,

I get it.
Thank you for your reply!

WenChen

Reply all
Reply to author
Forward
0 new messages