Skip to content

Commit

Permalink
[RWRoute] Further fix/cleanup around alternate source pins (#830)
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Hung <[email protected]>
  • Loading branch information
eddieh-xlnx authored Oct 4, 2023
1 parent 04204ce commit 5f7ed36
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/com/xilinx/rapidwright/rwroute/RWRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.xilinx.rapidwright.design.DesignTools;
import com.xilinx.rapidwright.design.Net;
import com.xilinx.rapidwright.design.NetType;
import com.xilinx.rapidwright.design.SiteInst;
import com.xilinx.rapidwright.design.SitePinInst;
import com.xilinx.rapidwright.device.IntentCode;
import com.xilinx.rapidwright.device.Node;
Expand Down Expand Up @@ -533,6 +534,7 @@ protected NetWrapper createNetWrapperAndConnections(Net net) {
if (altSource == null) {
altSource = DesignTools.getLegalAlternativeOutputPin(net);
if (altSource != null) {
// Add this SitePinInst to the net, but not to the SiteInst
net.addPin(altSource);
DesignTools.routeAlternativeOutputSitePin(net, altSource);
}
Expand Down Expand Up @@ -842,10 +844,12 @@ protected void postRouteProcess() {
Net net = e.getKey();
SitePinInst source = net.getSource();
SitePinInst altSource = net.getAlternateSource();
SiteInst si = source.getSiteInst();
boolean altSourcePreviouslyRouted = altSource != null ? altSource.isRouted() : false;
for (SitePinInst spi : Arrays.asList(source, altSource)) {
if (spi != null) {
spi.setRouted(false);
assert(spi.getSiteInst() == si);
}
}

Expand All @@ -862,21 +866,22 @@ protected void postRouteProcess() {
// Set the routed state of the used source node
// and if used and not already present, add it to the SiteInst
Node sourceNode = nodes.get(nodes.size() - 1);
if (sourceNode.equals(connection.getSource().getConnectedNode())) {
SitePinInst src = connection.getSource();
src.setRouted(true);
if (src.getSiteInst().getSitePinInst(src.getName()) == null) {
src.getSiteInst().addPin(src);
}
} else {
// Source used must have been the Net's alternate source
assert(!altSource.equals(connection.getSource()));
assert(sourceNode.equals(altSource.getConnectedNode()));
altSource.setRouted(true);
if (altSource.getSiteInst().getSitePinInst(altSource.getName()) == null) {
altSource.getSiteInst().addPin(altSource);
SitePinInst usedSpi = null;
for (SitePinInst spi : Arrays.asList(source, altSource)) {
if (spi != null && sourceNode.equals(spi.getConnectedNode())) {
usedSpi = spi;
}
}
if (usedSpi == null) {
throw new RuntimeException("ERROR: Unknown source node " + sourceNode + " on net " + net.getName());
}

// Now that we know this SitePinInst is used, make sure it exists in
// the SiteInst
usedSpi.setRouted(true);
if (si.getSitePinInst(usedSpi.getName()) == null) {
si.addPin(usedSpi);
}

if (source.isRouted() && (altSource == null || altSource.isRouted())) {
// Break if all sources have been set to be routed
Expand Down

0 comments on commit 5f7ed36

Please sign in to comment.