Skip to content

Commit bb3dc2b

Browse files
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 <[email protected]> Signed-off-by: eddieh-xlnx <[email protected]> Signed-off-by: eddieh-xlnx <[email protected]> Co-authored-by: eddieh-xlnx <[email protected]> Co-authored-by: Chris Lavin <[email protected]>
1 parent acbe053 commit bb3dc2b

File tree

3 files changed

+74
-57
lines changed

3 files changed

+74
-57
lines changed

src/com/xilinx/rapidwright/design/DesignTools.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,22 @@ public static boolean removeConnectedRouting(Net net, Node node){
10331033
* pins individually.
10341034
* @param net The current net to modify routing and to which all pins will have their routing
10351035
* removed. If any pin passed in is not of this net, it is skipped and no effect is taken.
1036-
* @param pins Sink pins that belong to the provided net that should have their selective routing
1037-
* removed. This method only works for sink pins.
1038-
* See {@link #unrouteSourcePin(SitePinInst)} for handling source pin unroutes.
1036+
* @param pins Pins that belong to the provided net that should have their selective routing
1037+
* removed.
1038+
* Source pins are handled by {@link #unrouteSourcePin(SitePinInst)}.
10391039
*/
10401040
public static void unroutePins(Net net, Collection<SitePinInst> pins) {
1041-
removePIPsFromNet(net,getTrimmablePIPsFromPins(net, pins));
1042-
for(SitePinInst pin : pins) {
1041+
List<SitePinInst> sinkPins = new ArrayList<>(pins.size());
1042+
pins.forEach((spi) -> {
1043+
if (spi.isOutPin()) {
1044+
// TODO - This can lead to a slow down in VCC and GND nets as it is not batched
1045+
DesignTools.unrouteSourcePin(spi);
1046+
} else {
1047+
sinkPins.add(spi);
1048+
}
1049+
});
1050+
removePIPsFromNet(net,getTrimmablePIPsFromPins(net, sinkPins));
1051+
for(SitePinInst pin : sinkPins) {
10431052
pin.setRouted(false);
10441053
}
10451054
}

src/com/xilinx/rapidwright/design/tools/RelocationTools.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ public static boolean relocate(Design design,
255255
}
256256

257257
Collection<SitePinInst> pins = n.getPins();
258-
Collection<SitePinInst> nonMatchingPins = pins.stream().filter(
259-
(spi) -> !oldSite.containsKey(spi.getSiteInst()))
258+
Collection<SitePinInst> nonMatchingPins = pins.stream()
259+
.filter((spi) -> !oldSite.containsKey(spi.getSiteInst()))
260+
// Filter out SPIs on a "STATIC_SOURCE" SiteInst that would have been unplaced above
261+
.filter((spi) -> spi.getSiteInst().isPlaced())
260262
.collect(Collectors.toList());
261263
if (nonMatchingPins.size() == pins.size()) {
262264
continue;

test/src/com/xilinx/rapidwright/design/TestDesignTools.java

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,18 @@ private Net createTestNet(Design design, String netName, String[] pips) {
298298
}
299299
return net;
300300
}
301-
302-
@Test
303-
public void testRemoveSourcePin() {
301+
302+
private void removeSourcePinHelper(boolean useUnroutePins, SitePinInst spi, int expectedPIPs) {
303+
if (useUnroutePins) {
304+
DesignTools.unroutePins(spi.getNet(), Arrays.asList(spi));
305+
} else {
306+
Assertions.assertEquals(expectedPIPs, DesignTools.unrouteSourcePin(spi).size());
307+
}
308+
}
309+
310+
@ParameterizedTest
311+
@ValueSource(booleans = {true, false})
312+
public void testRemoveSourcePin(boolean useUnroutePins) {
304313
Design design = new Design("test", Device.KCU105);
305314

306315
// 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() {
325334
net1.createPin("AQ2", si).setRouted(true);
326335
net1.createPin("A_I", si).setRouted(true);
327336
net1.createPin("FX", si).setRouted(true);
328-
329-
Assertions.assertEquals(12, DesignTools.unrouteSourcePin(net1.getSource()).size());
330-
337+
338+
removeSourcePinHelper(useUnroutePins, net1.getSource(), 12);
331339
Assertions.assertEquals(0, net1.getPIPs().size());
332340
for(SitePinInst pin : net1.getPins()) {
333341
Assertions.assertFalse(pin.isRouted());
@@ -346,9 +354,8 @@ public void testRemoveSourcePin() {
346354
net2.createPin("HMUX", si).setRouted(true);
347355
si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158"));
348356
net2.createPin("SRST_B2", si).setRouted(true);
349-
350-
Assertions.assertEquals(4, DesignTools.unrouteSourcePin(net2.getSource()).size());
351-
357+
358+
removeSourcePinHelper(useUnroutePins, net2.getSource(), 4);
352359
Assertions.assertEquals(0, net2.getPIPs().size());
353360
for(SitePinInst pin : net2.getPins()) {
354361
Assertions.assertFalse(pin.isRouted());
@@ -362,46 +369,45 @@ public void testRemoveSourcePin() {
362369

363370
// Net with two outputs (HMUX primary and H_O alternate) and two sinks (SRST_B2 & B2)
364371
Net net3 = createTestNet(design, "net3", new String[]{
365-
// SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2
366-
"INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT",
367-
"INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT",
368-
"INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1",
369-
"INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7",
370-
// Adding dual output net
371-
// SLICE_X65Y158/H_O-> SLICE_X64Y158/B2
372-
"INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT",
373-
"INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3",
374-
"INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT",
375-
"INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14",
376-
"INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT",
377-
"INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3",
378-
"INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT",
379-
"INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12",
380-
"INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1",
381-
"INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT",
382-
"INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0",
383-
});
384-
385-
si = design.createSiteInst(design.getDevice().getSite("SLICE_X65Y158"));
386-
SitePinInst src = net3.createPin("HMUX", si);
387-
src.setRouted(true);
388-
SitePinInst altSrc = net3.createPin("H_O", si);
389-
altSrc.setRouted(true);
390-
Assertions.assertNotNull(net3.getAlternateSource());
391-
Assertions.assertTrue(net3.getAlternateSource().getName().equals("H_O"));
392-
si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158"));
393-
SitePinInst snk = net3.createPin("SRST_B2", si);
394-
snk.setRouted(true);
395-
SitePinInst altSnk = net3.createPin("B2", si);
396-
altSnk.setRouted(true);
397-
398-
// Unroute just the H_O alternate source
399-
Set<PIP> unroutedPIPs = DesignTools.unrouteSourcePin(net3.getAlternateSource());
400-
Assertions.assertEquals(11, unroutedPIPs.size());
401-
Assertions.assertEquals(4, net3.getPIPs().size());
402-
Assertions.assertTrue(src.isRouted());
403-
Assertions.assertFalse(altSrc.isRouted());
404-
Assertions.assertTrue(snk.isRouted());
405-
Assertions.assertFalse(altSnk.isRouted());
372+
// SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2
373+
"INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT",
374+
"INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT",
375+
"INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1",
376+
"INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7",
377+
// Adding dual output net
378+
// SLICE_X65Y158/H_O-> SLICE_X64Y158/B2
379+
"INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT",
380+
"INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3",
381+
"INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT",
382+
"INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14",
383+
"INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT",
384+
"INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3",
385+
"INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT",
386+
"INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12",
387+
"INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1",
388+
"INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT",
389+
"INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0",
390+
});
391+
392+
si = design.createSiteInst(design.getDevice().getSite("SLICE_X65Y158"));
393+
SitePinInst src = net3.createPin("HMUX", si);
394+
src.setRouted(true);
395+
SitePinInst altSrc = net3.createPin("H_O", si);
396+
altSrc.setRouted(true);
397+
Assertions.assertNotNull(net3.getAlternateSource());
398+
Assertions.assertTrue(net3.getAlternateSource().getName().equals("H_O"));
399+
si = design.createSiteInst(design.getDevice().getSite("SLICE_X64Y158"));
400+
SitePinInst snk = net3.createPin("SRST_B2", si);
401+
snk.setRouted(true);
402+
SitePinInst altSnk = net3.createPin("B2", si);
403+
altSnk.setRouted(true);
404+
405+
// Unroute just the H_O alternate source
406+
removeSourcePinHelper(useUnroutePins, net3.getAlternateSource(), 11);
407+
Assertions.assertEquals(4, net3.getPIPs().size());
408+
Assertions.assertTrue(src.isRouted());
409+
Assertions.assertFalse(altSrc.isRouted());
410+
Assertions.assertTrue(snk.isRouted());
411+
Assertions.assertFalse(altSnk.isRouted());
406412
}
407413
}

0 commit comments

Comments
 (0)