From f5d8264609225435921a354a2672f0bd13670e66 Mon Sep 17 00:00:00 2001 From: Chris Lavin Date: Thu, 7 Sep 2023 13:32:55 -0600 Subject: [PATCH 1/3] Adds a tieoff method for module instances with unconnected inputs Signed-off-by: Chris Lavin --- .../xilinx/rapidwright/design/ModuleInst.java | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/src/com/xilinx/rapidwright/design/ModuleInst.java b/src/com/xilinx/rapidwright/design/ModuleInst.java index 7d947065c..75f038682 100644 --- a/src/com/xilinx/rapidwright/design/ModuleInst.java +++ b/src/com/xilinx/rapidwright/design/ModuleInst.java @@ -40,6 +40,9 @@ import com.xilinx.rapidwright.device.SiteTypeEnum; import com.xilinx.rapidwright.device.Tile; import com.xilinx.rapidwright.edif.EDIFCell; +import com.xilinx.rapidwright.edif.EDIFNet; +import com.xilinx.rapidwright.edif.EDIFPortInst; +import com.xilinx.rapidwright.edif.EDIFTools; import com.xilinx.rapidwright.util.MessageGenerator; import com.xilinx.rapidwright.util.Utils; @@ -469,7 +472,11 @@ private SitePinInst getCorrespondingPin(SitePinInst modulePin) { if (newSiteInst == null) { throw new RuntimeException("Did not find corresponding Site Inst for "+modulePin.getSiteInst().getName()+" in "+getName()); } - return newSiteInst.getSitePinInst(modulePin.getName()); + SitePinInst pin = newSiteInst.getSitePinInst(modulePin.getName()); + if (pin == null) { + pin = new SitePinInst(modulePin.getName(), newSiteInst); + } + return pin; } /** @@ -713,6 +720,78 @@ public void connect(String portName, int busIndex0, ModuleInst other, String oth } } + /** + * Connects unconnected SitePinInst inputs on the module instance to either GND + * or VCC (some reset input use VCC as an input and use the inverter to drive + * GND). + */ + public void tieOffUnconnectedInputs(boolean verbose) { + for (Port port : getModule().getPorts()) { + if (port.isOutPort()) + continue; + + for (SitePinInst pin : getCorrespondingPins(port)) { + if (pin == null) { + System.err.println("ERROR: Problem encountered with finding corresponding SitePinInst on port " + + getName() + "/" + port.getName() + " skipping..."); + } + if (pin != null && (pin.getNet() == null || pin.getNet().getSource() == null)) { + boolean useVccInverter = pin.getName().contains("RST"); + if (verbose) { + System.out.println(getName() + "/" + port.getName() + " SitePinInst=[" + pin + + "] has no source, connecting to " + (useVccInverter ? "VCC" : "GND")); + } + connectToStaticNet(port.getName(), useVccInverter); + } + break; + } + } + } + + /** + * Connects a port (all of its corresponding SitePinInsts) to either the GND or + * VCC net. + * + * @param portName Name of the port to connect to GND or VCC + * @param connectToVCC True to connect to VCC, False for GND + */ + public void connectToStaticNet(String portName, boolean connectToVCC) { + NetType type = connectToVCC ? NetType.VCC : NetType.GND; + Net staticNet = getDesign().getStaticNet(type); + + Port inPort = getPort(portName); + if (inPort.isOutPort()) { + throw new RuntimeException("ERROR: Attempting to connnect output port " + + getName() + "/" + portName + " to " + staticNet); + } + + // Connect logically + EDIFCell parent = getCellInst().getParentCell(); + EDIFNet logicalStaticNet = EDIFTools.getStaticNet(type, parent, getDesign().getNetlist()); + EDIFPortInst portInst = getCellInst().getPortInst(portName); + if (portInst == null) { + logicalStaticNet.createPortInst(portName, getCellInst()); + } else { + portInst.getNet().removePortInst(portInst); + logicalStaticNet.addPortInst(portInst); + } + + // Connect physically + for (SitePinInst inPin : getCorrespondingPins(inPort)) { + if (inPin == null) { + System.err.println("ERROR: Problem encountered with finding corresponding SitePinInst on port " + + getName() + "/" + inPort.getName() + " skipping..."); + continue; + } + + Net oldPhysicalNet = inPin.getNet(); + if (oldPhysicalNet != null) { + oldPhysicalNet.removePin(inPin, true); + } + staticNet.addPin(inPin); + } + } + @Override public RelocatableTileRectangle getBoundingBox() { return module.getBoundingBox().getCorresponding(getAnchor().getTile(), module.getAnchor().getTile()); From 59cabc1d3c568749106f9f065bc692cd310aca95 Mon Sep 17 00:00:00 2001 From: Chris Lavin Date: Mon, 15 Jan 2024 18:08:53 -0700 Subject: [PATCH 2/3] Clarify usage Signed-off-by: Chris Lavin --- src/com/xilinx/rapidwright/design/ModuleInst.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/ModuleInst.java b/src/com/xilinx/rapidwright/design/ModuleInst.java index c537bf8c5..e9a9b2970 100644 --- a/src/com/xilinx/rapidwright/design/ModuleInst.java +++ b/src/com/xilinx/rapidwright/design/ModuleInst.java @@ -780,12 +780,14 @@ public void tieOffUnconnectedInputs(boolean verbose) { + getName() + "/" + port.getName() + " skipping..."); } if (pin != null && (pin.getNet() == null || pin.getNet().getSource() == null)) { - boolean useVccInverter = pin.getName().contains("RST"); + // If a port has a RST inverter, drive it with VCC to get GND + boolean connectToVCC = pin.getName().contains("RST"); if (verbose) { System.out.println(getName() + "/" + port.getName() + " SitePinInst=[" + pin - + "] has no source, connecting to " + (useVccInverter ? "VCC" : "GND")); + + "] has no source, connecting to " + (connectToVCC ? "VCC" : "GND")); } - connectToStaticNet(port.getName(), useVccInverter); + + connectToStaticNet(port.getName(), connectToVCC); } break; } From f319fdef0c6df0e591872025f0026b74adc62275 Mon Sep 17 00:00:00 2001 From: Chris Lavin Date: Tue, 16 Jan 2024 11:02:10 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: eddieh-xlnx Signed-off-by: Chris Lavin --- src/com/xilinx/rapidwright/design/ModuleInst.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/ModuleInst.java b/src/com/xilinx/rapidwright/design/ModuleInst.java index e9a9b2970..0ae40fe65 100644 --- a/src/com/xilinx/rapidwright/design/ModuleInst.java +++ b/src/com/xilinx/rapidwright/design/ModuleInst.java @@ -766,8 +766,8 @@ public void connect(String portName, int busIndex0, ModuleInst other, String oth /** * Connects unconnected SitePinInst inputs on the module instance to either GND - * or VCC (some reset input use VCC as an input and use the inverter to drive - * GND). + * or VCC (some reset inputs can accept VCC as an input and use its built-in + * inverter to drive GND). */ public void tieOffUnconnectedInputs(boolean verbose) { for (Port port : getModule().getPorts()) {