From bb3dc2bc4aab414df8a5b4c09ce976c5b56e5e59 Mon Sep 17 00:00:00 2001 From: eddieh-xlnx Date: Fri, 16 Sep 2022 09:12:08 -0700 Subject: [PATCH] DesignTools.unroutePins() to handle source pins too (#493) * DesignTools.unroutePins() to handle source pins * Fixes for a31fe3 * Add comment * Adapt test * Apply suggestions from code review * Update src/com/xilinx/rapidwright/design/DesignTools.java Co-authored-by: Chris Lavin Signed-off-by: eddieh-xlnx Signed-off-by: eddieh-xlnx Co-authored-by: eddieh-xlnx Co-authored-by: Chris Lavin --- .../rapidwright/design/DesignTools.java | 19 +++- .../design/tools/RelocationTools.java | 6 +- .../rapidwright/design/TestDesignTools.java | 106 +++++++++--------- 3 files changed, 74 insertions(+), 57 deletions(-) diff --git a/src/com/xilinx/rapidwright/design/DesignTools.java b/src/com/xilinx/rapidwright/design/DesignTools.java index 33f777b30..e9dd04470 100644 --- a/src/com/xilinx/rapidwright/design/DesignTools.java +++ b/src/com/xilinx/rapidwright/design/DesignTools.java @@ -1033,13 +1033,22 @@ public static boolean removeConnectedRouting(Net net, Node node){ * pins individually. * @param net The current net to modify routing and to which all pins will have their routing * removed. If any pin passed in is not of this net, it is skipped and no effect is taken. - * @param pins Sink pins that belong to the provided net that should have their selective routing - * removed. This method only works for sink pins. - * See {@link #unrouteSourcePin(SitePinInst)} for handling source pin unroutes. + * @param pins Pins that belong to the provided net that should have their selective routing + * removed. + * Source pins are handled by {@link #unrouteSourcePin(SitePinInst)}. */ public static void unroutePins(Net net, Collection pins) { - removePIPsFromNet(net,getTrimmablePIPsFromPins(net, pins)); - for(SitePinInst pin : pins) { + List sinkPins = new ArrayList<>(pins.size()); + pins.forEach((spi) -> { + if (spi.isOutPin()) { + // TODO - This can lead to a slow down in VCC and GND nets as it is not batched + DesignTools.unrouteSourcePin(spi); + } else { + sinkPins.add(spi); + } + }); + removePIPsFromNet(net,getTrimmablePIPsFromPins(net, sinkPins)); + for(SitePinInst pin : sinkPins) { pin.setRouted(false); } } diff --git a/src/com/xilinx/rapidwright/design/tools/RelocationTools.java b/src/com/xilinx/rapidwright/design/tools/RelocationTools.java index 5bb162ee2..9b9adf464 100644 --- a/src/com/xilinx/rapidwright/design/tools/RelocationTools.java +++ b/src/com/xilinx/rapidwright/design/tools/RelocationTools.java @@ -255,8 +255,10 @@ public static boolean relocate(Design design, } Collection pins = n.getPins(); - Collection nonMatchingPins = pins.stream().filter( - (spi) -> !oldSite.containsKey(spi.getSiteInst())) + Collection nonMatchingPins = pins.stream() + .filter((spi) -> !oldSite.containsKey(spi.getSiteInst())) + // Filter out SPIs on a "STATIC_SOURCE" SiteInst that would have been unplaced above + .filter((spi) -> spi.getSiteInst().isPlaced()) .collect(Collectors.toList()); if (nonMatchingPins.size() == pins.size()) { continue; diff --git a/test/src/com/xilinx/rapidwright/design/TestDesignTools.java b/test/src/com/xilinx/rapidwright/design/TestDesignTools.java index 73916a276..684d2b4f4 100644 --- a/test/src/com/xilinx/rapidwright/design/TestDesignTools.java +++ b/test/src/com/xilinx/rapidwright/design/TestDesignTools.java @@ -298,9 +298,18 @@ private Net createTestNet(Design design, String netName, String[] pips) { } return net; } - - @Test - public void testRemoveSourcePin() { + + private void removeSourcePinHelper(boolean useUnroutePins, SitePinInst spi, int expectedPIPs) { + if (useUnroutePins) { + DesignTools.unroutePins(spi.getNet(), Arrays.asList(spi)); + } else { + Assertions.assertEquals(expectedPIPs, DesignTools.unrouteSourcePin(spi).size()); + } + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void testRemoveSourcePin(boolean useUnroutePins) { Design design = new Design("test", Device.KCU105); // Net with one source (AQ2) and two sinks (A_I & FX) and a stub (INT_NODE_IMUX_71_INT_OUT) @@ -325,9 +334,8 @@ public void testRemoveSourcePin() { net1.createPin("AQ2", si).setRouted(true); net1.createPin("A_I", si).setRouted(true); net1.createPin("FX", si).setRouted(true); - - Assertions.assertEquals(12, DesignTools.unrouteSourcePin(net1.getSource()).size()); - + + removeSourcePinHelper(useUnroutePins, net1.getSource(), 12); Assertions.assertEquals(0, net1.getPIPs().size()); for(SitePinInst pin : net1.getPins()) { Assertions.assertFalse(pin.isRouted()); @@ -346,9 +354,8 @@ public void testRemoveSourcePin() { net2.createPin("HMUX", si).setRouted(true); si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158")); net2.createPin("SRST_B2", si).setRouted(true); - - Assertions.assertEquals(4, DesignTools.unrouteSourcePin(net2.getSource()).size()); - + + removeSourcePinHelper(useUnroutePins, net2.getSource(), 4); Assertions.assertEquals(0, net2.getPIPs().size()); for(SitePinInst pin : net2.getPins()) { Assertions.assertFalse(pin.isRouted()); @@ -362,46 +369,45 @@ public void testRemoveSourcePin() { // Net with two outputs (HMUX primary and H_O alternate) and two sinks (SRST_B2 & B2) Net net3 = createTestNet(design, "net3", new String[]{ - // SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2 - "INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT", - "INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT", - "INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1", - "INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7", - // Adding dual output net - // SLICE_X65Y158/H_O-> SLICE_X64Y158/B2 - "INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT", - "INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3", - "INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT", - "INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14", - "INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT", - "INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3", - "INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT", - "INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12", - "INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1", - "INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT", - "INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0", - }); - - si = design.createSiteInst(design.getDevice().getSite("SLICE_X65Y158")); - SitePinInst src = net3.createPin("HMUX", si); - src.setRouted(true); - SitePinInst altSrc = net3.createPin("H_O", si); - altSrc.setRouted(true); - Assertions.assertNotNull(net3.getAlternateSource()); - Assertions.assertTrue(net3.getAlternateSource().getName().equals("H_O")); - si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158")); - SitePinInst snk = net3.createPin("SRST_B2", si); - snk.setRouted(true); - SitePinInst altSnk = net3.createPin("B2", si); - altSnk.setRouted(true); - - // Unroute just the H_O alternate source - Set unroutedPIPs = DesignTools.unrouteSourcePin(net3.getAlternateSource()); - Assertions.assertEquals(11, unroutedPIPs.size()); - Assertions.assertEquals(4, net3.getPIPs().size()); - Assertions.assertTrue(src.isRouted()); - Assertions.assertFalse(altSrc.isRouted()); - Assertions.assertTrue(snk.isRouted()); - Assertions.assertFalse(altSnk.isRouted()); + // SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2 + "INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT", + "INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT", + "INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1", + "INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7", + // Adding dual output net + // SLICE_X65Y158/H_O-> SLICE_X64Y158/B2 + "INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT", + "INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3", + "INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT", + "INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14", + "INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT", + "INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3", + "INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT", + "INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12", + "INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1", + "INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT", + "INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0", + }); + + si = design.createSiteInst(design.getDevice().getSite("SLICE_X65Y158")); + SitePinInst src = net3.createPin("HMUX", si); + src.setRouted(true); + SitePinInst altSrc = net3.createPin("H_O", si); + altSrc.setRouted(true); + Assertions.assertNotNull(net3.getAlternateSource()); + Assertions.assertTrue(net3.getAlternateSource().getName().equals("H_O")); + si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158")); + SitePinInst snk = net3.createPin("SRST_B2", si); + snk.setRouted(true); + SitePinInst altSnk = net3.createPin("B2", si); + altSnk.setRouted(true); + + // Unroute just the H_O alternate source + removeSourcePinHelper(useUnroutePins, net3.getAlternateSource(), 11); + Assertions.assertEquals(4, net3.getPIPs().size()); + Assertions.assertTrue(src.isRouted()); + Assertions.assertFalse(altSrc.isRouted()); + Assertions.assertTrue(snk.isRouted()); + Assertions.assertFalse(altSnk.isRouted()); } }