Skip to content

Commit

Permalink
DesignTools.unroutePins() to handle source pins too (#493)
Browse files Browse the repository at this point in the history
* 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 <clavin@xilinx.com>
Signed-off-by: eddieh-xlnx <eddie.hung@amd.com>

Signed-off-by: eddieh-xlnx <eddie.hung@amd.com>
Co-authored-by: eddieh-xlnx <eddieh-xlnx@users.noreply.github.com>
Co-authored-by: Chris Lavin <clavin@xilinx.com>
  • Loading branch information
3 people authored Sep 16, 2022
1 parent acbe053 commit bb3dc2b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 57 deletions.
19 changes: 14 additions & 5 deletions src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SitePinInst> pins) {
removePIPsFromNet(net,getTrimmablePIPsFromPins(net, pins));
for(SitePinInst pin : pins) {
List<SitePinInst> 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);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/com/xilinx/rapidwright/design/tools/RelocationTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ public static boolean relocate(Design design,
}

Collection<SitePinInst> pins = n.getPins();
Collection<SitePinInst> nonMatchingPins = pins.stream().filter(
(spi) -> !oldSite.containsKey(spi.getSiteInst()))
Collection<SitePinInst> 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;
Expand Down
106 changes: 56 additions & 50 deletions test/src/com/xilinx/rapidwright/design/TestDesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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<PIP> 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());
}
}

0 comments on commit bb3dc2b

Please sign in to comment.