Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DesignTools] updatePinsIsRouted() to return num unrouted sinks #1131

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -4367,13 +4367,18 @@ public static void addProhibitConstraint(Design design, List<String> belLocation
* tied to GND or VCC) when following the Net's PIPs.
* A source pin will be marked as being routed if it drives at least one PIP.
* @param net Net on which pins are to be updated.
* @return Number of unrouted sink pins on net.
*/
public static void updatePinsIsRouted(Net net) {
public static int updatePinsIsRouted(Net net) {
int numUnroutedSinkPins = 0;
for (SitePinInst spi : net.getPins()) {
spi.setRouted(false);
if (!spi.isOutPin()) {
numUnroutedSinkPins++;
}
}
if (!net.hasPIPs()) {
return;
return numUnroutedSinkPins;
}

Map<Node, SitePinInst> node2spi = new HashMap<>();
Expand All @@ -4392,23 +4397,34 @@ public static void updatePinsIsRouted(Net net) {
}
while (!queue.isEmpty()) {
NetTools.NodeTree node = queue.poll();
SitePinInst spi = node2spi.get(node);
SitePinInst spi = node2spi.remove(node);
if (spi != null) {
spi.setRouted(true);
if (!spi.isOutPin()) {
assert(numUnroutedSinkPins > 0);
numUnroutedSinkPins--;
}
}
queue.addAll(node.fanouts);
}
return numUnroutedSinkPins;
}

/**
* Update the SitePinInst.isRouted() value of all sink pins in the given
* Design. See {@link #updatePinsIsRouted(Net)}.
* @param design Design in which pins are to be updated.
* @return Number of unrouted sink pins (not driven by hierarchical ports) across design.
*/
public static void updatePinsIsRouted(Design design) {
public static int updatePinsIsRouted(Design design) {
int totalUnroutedSinkPins = 0;
for (Net net : design.getNets()) {
updatePinsIsRouted(net);
int numUnroutedSinkPins = updatePinsIsRouted(net);
if (!DesignTools.isNetDrivenByHierPort(net)) {
totalUnroutedSinkPins += numUnroutedSinkPins;
}
}
return totalUnroutedSinkPins;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/src/com/xilinx/rapidwright/eco/TestECOTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void testConnectNetSwapSinks() {
EDIFNetlist netlist = design.getNetlist();
Map<Net, Set<SitePinInst>> deferredRemovals = new HashMap<>();

DesignTools.updatePinsIsRouted(design);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(design));

// Disconnect the ILA inputs
List<EDIFHierPortInst> disconnectPins = new ArrayList<>();
Expand Down Expand Up @@ -253,7 +253,7 @@ public void testConnectNetSwapSource() {
EDIFNetlist netlist = design.getNetlist();
Map<Net, Set<SitePinInst>> deferredRemovals = new HashMap<>();

DesignTools.updatePinsIsRouted(design);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(design));

// Disconnect the outputs
List<EDIFHierPortInst> disconnectPins = new ArrayList<>();
Expand Down Expand Up @@ -386,7 +386,7 @@ public void testCreateCell() {
Design design = RapidWrightDCP.loadDCP("picoblaze_ooc_X10Y235.dcp");
EDIFNetlist netlist = design.getNetlist();

DesignTools.updatePinsIsRouted(design);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(design));

EDIFCell reference = netlist.getCell("kcpsm6");
List<String> instNames = Arrays.asList("processor2", "processor3");
Expand Down Expand Up @@ -474,7 +474,7 @@ public void testCreateNet() {
Design design = RapidWrightDCP.loadDCP("picoblaze_ooc_X10Y235.dcp");
EDIFNetlist netlist = design.getNetlist();

DesignTools.updatePinsIsRouted(design);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(design));

List<String> netNames = Arrays.asList("processor/foo", "your_program/bar");
ECOTools.createNet(design, netNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void testSimulateSwappedLutPinsWithRWRoute(String path, @TempDir Path tem
inputDesign = null;

Assertions.assertTrue(LUTTools.swapLutPinsFromPIPs(outputDesign) > 0);
DesignTools.updatePinsIsRouted(outputDesign);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(outputDesign));
TestRWRoute.assertAllSourcesRoutedFlagSet(outputDesign);
TestRWRoute.assertAllPinsRouted(outputDesign);
VivadoToolsHelper.assertFullyRouted(outputDesign);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void testSymmetricClkRouting() {
if (node != null) used.add(node);
}
}
DesignTools.updatePinsIsRouted(net);
Assertions.assertEquals(0, DesignTools.updatePinsIsRouted(net));
for (SitePinInst spi : net.getPins()) {
Assertions.assertTrue(spi.isRouted());
}
Expand Down
Loading