From e8f4b057e9f43e381dccc377eeb3b8b5905d01be Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 23 Jul 2024 21:04:37 -0700 Subject: [PATCH 1/5] [DesignTools] makeBlackbox to examine Cells not EDIFNetlist Since EDIFNetlist may be partially encrypted Also speedup/cleanup. Signed-off-by: Eddie Hung --- .../rapidwright/design/DesignTools.java | 98 ++++++++----------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index 987ab92ab..3d8e6e10e 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -1740,67 +1740,48 @@ public static void makeBlackBox(Design d, EDIFHierCellInst hierarchicalCell) { } t.stop().start("Remove p&r"); + String prefix = hierarchicalCell.getFullHierarchicalInstName() + EDIFTools.EDIF_HIER_SEP; + for (SiteInst si : d.getSiteInsts()) { + for (Cell c : new ArrayList<>(si.getCells())) { + if (!c.getName().startsWith(prefix)) + continue; - List allLeafs = d.getNetlist().getAllLeafDescendants(hierarchicalCell); - Set cells = new HashSet<>(); - for (EDIFHierCellInst i : allLeafs) { - // Get the physical cell, make sure we can unplace/unroute it first - Cell c = d.getCell(i.getFullHierarchicalInstName()); - if (c == null) { - continue; - } - cells.add(c); - } - - // Remove all placement and routing information related to the cell to be - // blackboxed - for (Cell c : cells) { - BEL bel = c.getBEL(); - SiteInst si = c.getSiteInst(); - - // Check for VCC on A6 and remove if needed - if (c.getBEL().isLUT() && c.getBELName().endsWith("5LUT")) { - SitePinInst vcc = c.getSiteInst().getSitePinInst(c.getBELName().charAt(0) + "6"); - if (vcc != null && vcc.getNet().getName().equals(Net.VCC_NET)) { - boolean hasOtherSink = false; - for (BELPin otherSink : si.getSiteWirePins(vcc.getBELPin().getSiteWireIndex())) { - if (otherSink.isOutput()) - continue; - Cell otherCell = si.getCell(otherSink.getBEL()); - if (otherCell != null && otherCell.getLogicalPinMapping(otherSink.getName()) != null) { - hasOtherSink = true; - break; + // Remove all placement and routing information related to the cell to be + // blackboxed + BEL bel = c.getBEL(); + + // Check for VCC on A6 and remove if needed + if (c.getBEL().isLUT() && c.getBELName().endsWith("5LUT")) { + SitePinInst vcc = c.getSiteInst().getSitePinInst(c.getBELName().charAt(0) + "6"); + if (vcc != null && vcc.getNet().getName().equals(Net.VCC_NET)) { + boolean hasOtherSink = false; + for (BELPin otherSink : si.getSiteWirePins(vcc.getBELPin().getSiteWireIndex())) { + if (otherSink.isOutput()) + continue; + Cell otherCell = si.getCell(otherSink.getBEL()); + if (otherCell != null && otherCell.getLogicalPinMapping(otherSink.getName()) != null) { + hasOtherSink = true; + break; + } + } + if (!hasOtherSink) { + pinsToRemove.computeIfAbsent(vcc.getNet(), $ -> new HashSet<>()).add(vcc); } - } - if (!hasOtherSink) { - pinsToRemove.computeIfAbsent(vcc.getNet(), $ -> new HashSet<>()).add(vcc); } } - } - // Remove all physical nets first - for (String logPin : c.getPinMappingsP2L().values()) { - List removePins = unrouteCellPinSiteRouting(c, logPin); - for (SitePinInst pin : removePins) { - pinsToRemove.computeIfAbsent(pin.getNet(), $ -> new HashSet<>()).add(pin); + // Remove all physical nets first + for (String logPin : c.getPinMappingsP2L().values()) { + List removePins = unrouteCellPinSiteRouting(c, logPin); + for (SitePinInst pin : removePins) { + pinsToRemove.computeIfAbsent(pin.getNet(), $ -> new HashSet<>()).add(pin); + } } - } - touched.add(c.getSiteInst()); - - c.unplace(); - d.removeCell(c.getName()); - si.removeCell(bel); - } - - t.stop().start("cleanup t-prims"); + touched.add(c.getSiteInst()); - // Clean up any cells from Transformed Prims - String keepPrefix = hierarchicalCell.getFullHierarchicalInstName() + EDIFTools.EDIF_HIER_SEP; - for (SiteInst si : d.getSiteInsts()) { - for (Cell c : si.getCells()) { - if (c.getName().startsWith(keepPrefix)) { - touched.add(si); - } + c.unplace(); + d.removeCell(c.getName()); + si.removeCell(bel); } } @@ -1816,12 +1797,9 @@ public static void makeBlackBox(Design d, EDIFHierCellInst hierarchicalCell) { } } - batchRemoveSitePins(pinsToRemove, true); - // Rename nets if source was removed Set netsToKeep = new HashSet<>(); for (Entry e : netsToUpdate.entrySet()) { - EDIFHierNet newSource = d.getNetlist().getHierNetFromName(e.getValue()); Net net = e.getKey(); if (!net.rename(e.getValue())) { throw new RuntimeException("ERROR: Failed to rename net '" + net.getName() + "'"); @@ -1841,8 +1819,11 @@ public static void makeBlackBox(Design d, EDIFHierCellInst hierarchicalCell) { } for (SiteInst siteInst : siteInstsToRemove) { - d.removeSiteInst(siteInst); + d.removeSiteInst(siteInst, pinsToRemove); } + t.stop().start("cleanup nets"); + + batchRemoveSitePins(pinsToRemove, true); // Remove any stray stubs on any remaining nets for (Net net : pinsToRemove.keySet()) { @@ -1850,6 +1831,7 @@ public static void makeBlackBox(Design d, EDIFHierCellInst hierarchicalCell) { net.unroute(); } } + pinsToRemove.clear(); t.stop().start("create bbox"); From 238a9716d6c65dad12f32a2061d6d2b321487f36 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Wed, 24 Jul 2024 11:11:28 -0700 Subject: [PATCH 2/5] [DesignTools] unrouteCellPinSiteRouting() aware of output site pins Signed-off-by: Eddie Hung --- src/com/xilinx/rapidwright/design/DesignTools.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index 3d8e6e10e..9770a6f1f 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -1556,6 +1556,10 @@ public static List unrouteCellPinSiteRouting(Cell cell, String logi case PORT: { // We found a site pin, add it to solution set sitePinNames.add(pin.getName()); + if (belPin.isInput() && pin.isInput()) { + // This is an input BEL pin that feeds an output site pin, mark it as an internal sink + internalSinks.add(pin); + } break; } case BEL: { From b80984455e183b56e0bff9e4d8bc5020179d9e06 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Wed, 24 Jul 2024 11:14:24 -0700 Subject: [PATCH 3/5] [DesignTools] getLogicalBELPinDriver() to not NPE without netlist Signed-off-by: Eddie Hung --- .../xilinx/rapidwright/design/DesignTools.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index 9770a6f1f..f5464683c 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -2464,18 +2464,20 @@ public static BELPin getLogicalBELPinDriver(SitePinInst sitePinInst) { } return pin; } - // Looks like the approach above failed (site may not be routed), try logical path + // Looks like the approach above failed (site may not be routed), try logical path if netlist exists Net net = sitePinInst.getNet(); if (net == null) return null; Design design = siteInst.getDesign(); EDIFNetlist netlist = design.getNetlist(); - EDIFHierNet hierNet = netlist.getHierNetFromName(net.getName()); - if (hierNet == null) return null; - List portInsts = hierNet.getNet().getSourcePortInsts(false); - for (EDIFPortInst portInst : portInsts) { - Cell c = design.getCell(hierNet.getHierarchicalInstName(portInst)); - if (c != null) { - return c.getBELPin(portInst); + if (netlist != null) { + EDIFHierNet hierNet = netlist.getHierNetFromName(net.getName()); + if (hierNet == null) return null; + List portInsts = hierNet.getNet().getSourcePortInsts(false); + for (EDIFPortInst portInst : portInsts) { + Cell c = design.getCell(hierNet.getHierarchicalInstName(portInst)); + if (c != null) { + return c.getBELPin(portInst); + } } } return null; From 9cf5ba8ab890585e216790f72049bec769c170bd Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 29 Jul 2024 13:23:14 -0700 Subject: [PATCH 4/5] [DesignTools] unrouteCellPinSiteRouting() aware of used output site pins Signed-off-by: Eddie Hung --- src/com/xilinx/rapidwright/design/DesignTools.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index f5464683c..2f29a9294 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -1556,8 +1556,8 @@ public static List unrouteCellPinSiteRouting(Cell cell, String logi case PORT: { // We found a site pin, add it to solution set sitePinNames.add(pin.getName()); - if (belPin.isInput() && pin.isInput()) { - // This is an input BEL pin that feeds an output site pin, mark it as an internal sink + if (belPin.isInput() && pin.isInput() && siteInst.getSitePinInst(pin.getName()) != null) { + // This is an input BEL pin that feeds a used output site pin, mark it as an internal sink internalSinks.add(pin); } break; From 88d6854d3b9dbb16107a65c72bc9f0d94e3c807b Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 29 Jul 2024 13:23:42 -0700 Subject: [PATCH 5/5] [DesignTools] unrouteCellPinSiteRouting() to identify FF routethrus Signed-off-by: Eddie Hung --- src/com/xilinx/rapidwright/design/DesignTools.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index 2f29a9294..2af2743aa 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -1576,7 +1576,13 @@ public static List unrouteCellPinSiteRouting(Cell cell, String logi // Make sure we are coming in on the routed-thru pin String otherPinName = otherCell.getPinMappingsP2L().keySet().iterator().next(); if (pin.getName().equals(otherPinName)) { - otherPin = LUTTools.getLUTOutputPin(pin.getBEL()); + if (otherCell.isFFRoutethruCell()) { + otherPin = pin.getBEL().getPin("Q"); + } else if (LUTTools.isCellALUT(otherCell)) { + otherPin = LUTTools.getLUTOutputPin(pin.getBEL()); + } else { + throw new RuntimeException("ERROR: Unrecognized routethru cell: " + cell.getName()); + } } } if (otherPin != null) {