diff --git a/src/com/xilinx/rapidwright/edif/EDIFCell.java b/src/com/xilinx/rapidwright/edif/EDIFCell.java index 7a901ccc2..9a53ba9d9 100644 --- a/src/com/xilinx/rapidwright/edif/EDIFCell.java +++ b/src/com/xilinx/rapidwright/edif/EDIFCell.java @@ -477,6 +477,10 @@ public boolean isLeafCellOrBlackBox() { return (instances == null || instances.size() == 0) && (nets == null || nets.size() == 0); } + public boolean isStaticSource() { + return getName().equals("VCC") || getName().equals("GND"); + } + /** * Checks if all the port on the provided cell match and are equal to the ports on this cell. * @param cell The other cell to check against. diff --git a/src/com/xilinx/rapidwright/edif/EDIFNetlist.java b/src/com/xilinx/rapidwright/edif/EDIFNetlist.java index 24a636d49..1cd9c6628 100644 --- a/src/com/xilinx/rapidwright/edif/EDIFNetlist.java +++ b/src/com/xilinx/rapidwright/edif/EDIFNetlist.java @@ -1043,6 +1043,7 @@ public List findCellInsts(String wildcardPattern) { public List getAllLeafDescendants(String instanceName) { return getAllLeafDescendants(getHierCellInstFromName(instanceName)); } + /** * Searches all lower levels of hierarchy to find all leaf descendants. It returns a * list of all leaf cells that fall under the hierarchy of the provided instance name. @@ -1050,15 +1051,30 @@ public List getAllLeafDescendants(String instanceName) { * @return A list of all leaf cell instances or null if the instanceName was not found. */ public List getAllLeafDescendants(EDIFHierCellInst instance) { - List leafCells = new ArrayList<>(); + return getAllLeafDescendants(instance, false); + } + /** + * Searches all lower levels of hierarchy to find all leaf descendants. It + * returns a list of all leaf cells that fall under the hierarchy of the + * provided instance name. + * + * @param instance The instance to start searching from. + * @param includeStaticSources If true, results returned will include all cell + * instances that instantiated the VCC and GND + * primitives + * @return A list of all leaf cell instances or null if the instanceName was not + * found. + */ + public List getAllLeafDescendants(EDIFHierCellInst instance, boolean includeStaticSources) { + List leafCells = new ArrayList<>(); Queue toProcess = new LinkedList(); toProcess.add(instance); while (!toProcess.isEmpty()) { EDIFHierCellInst curr = toProcess.poll(); - if (curr.getCellType().isPrimitive()) { + if (curr.getCellType().isPrimitive() && (includeStaticSources || !curr.getCellType().isStaticSource())) { leafCells.add(curr); } else { curr.addChildren(toProcess); @@ -1387,10 +1403,35 @@ public List getAllLeafCellInstances() { } /** - * Get the physical pins all parent nets (as returned by {@link #getParentNet(EDIFHierNet)}). + * Traverses the netlist and produces a list of all primitive leaf cell + * instances. + * + * @return A list of all primitive leaf cell instances. + */ + public List getAllLeafCellInstances(boolean includeStaticSources) { + List insts = new ArrayList<>(); + Queue q = new LinkedList<>(); + q.add(getTopCellInst()); + while (!q.isEmpty()) { + EDIFCellInst curr = q.poll(); + for (EDIFCellInst eci : curr.getCellType().getCellInsts()) { + if (eci.getCellType().isPrimitive() && (includeStaticSources || !eci.getCellType().isStaticSource())) + insts.add(eci); + else + q.add(eci); + } + } + return insts; + } + + /** + * Get the physical pins all parent nets (as returned by + * {@link #getParentNet(EDIFHierNet)}). * - * No special handling for static nets is performed. Therefore, only the local connectivity is visible. To see - * all globally connected static pins, use {@link #getPhysicalVccPins()} and {@link #getPhysicalGndPins()}. + * No special handling for static nets is performed. Therefore, only the local + * connectivity is visible. To see all globally connected static pins, use + * {@link #getPhysicalVccPins()} and {@link #getPhysicalGndPins()}. + * * @return the physicalNetPinMap */ public Map> getPhysicalNetPinMap() {