Skip to content
Draft
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
13 changes: 11 additions & 2 deletions src/com/xilinx/rapidwright/rwroute/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ public RouteNode getSourceRnode() {
return sourceRnode;
}

public RouteNode getSourceRnode(boolean backwardRouting) {
return backwardRouting ? sinkRnode : sourceRnode;
}

public void setSourceRnode(RouteNode sourceNode) {
sourceRnode = sourceNode;
}
Expand All @@ -277,6 +281,10 @@ public RouteNode getSinkRnode() {
return sinkRnode;
}

public RouteNode getSinkRnode(boolean backwardRouting) {
return backwardRouting ? sourceRnode : sinkRnode;
}

public void setSinkRnode(RouteNode sinkRnode) {
this.sinkRnode = sinkRnode;

Expand Down Expand Up @@ -483,9 +491,10 @@ public String toString() {
return s.toString();
}

public void setAllTargets(RWRoute.ConnectionState state) {
sinkRnode.markTarget(state);
public void setAllTargets(RWRoute.ConnectionState state, boolean backwardRouting) {
getSinkRnode(backwardRouting).markTarget(state);
if (altSinkRnodes != null) {
assert(!backwardRouting); // TODO
for (RouteNode rnode : altSinkRnodes) {
assert(rnode.countConnectionsOfUser(netWrapper) == 0);
assert(!rnode.getType().isAnyExclusiveSink());
Expand Down
31 changes: 31 additions & 0 deletions src/com/xilinx/rapidwright/rwroute/PartialRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,37 @@ public static Design routeDesignPartialTimingDriven(Design design, Collection<Si
pinsToRoute, softPreserve);
}

/**
* Routes a design in the partial non-timing-driven backward routing mode.
* @param design The {@link Design} instance to be routed.
* @param pinsToRoute Collection of {@link SitePinInst}-s to be routed. If null, route all unrouted pins in the design.
* @param softPreserve Allow routed nets to be unrouted and subsequently rerouted in order to improve routability.
*/
public static Design routeDesignPartialNonTimingDrivenBackward(Design design, Collection<SitePinInst> pinsToRoute, boolean softPreserve) {
return routeDesignWithUserDefinedArguments(design, new String[] {
"--fixBoundingBox",
"--useUTurnNodes",
"--nonTimingDriven",
"--backwardRouting",
"--verbose"},
pinsToRoute, softPreserve);
}

/**
* Routes a design in the partial timing-driven backward routing mode.
* @param design The {@link Design} instance to be routed.
* @param pinsToRoute Collection of {@link SitePinInst}-s to be routed. If null, route all unrouted pins in the design.
* @param softPreserve Allow routed nets to be unrouted and subsequently rerouted in order to improve routability.
*/
public static Design routeDesignPartialTimingDrivenBackward(Design design, Collection<SitePinInst> pinsToRoute, boolean softPreserve) {
return routeDesignWithUserDefinedArguments(design, new String[] {
"--fixBoundingBox",
"--useUTurnNodes",
"--backwardRouting",
"--verbose"},
pinsToRoute, softPreserve);
}

/**
* The main interface of {@link PartialRouter} that reads in a {@link Design} checkpoint,
* and parses the arguments for the {@link RWRouteConfig} object of the router.
Expand Down
217 changes: 115 additions & 102 deletions src/com/xilinx/rapidwright/rwroute/RWRoute.java

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/com/xilinx/rapidwright/rwroute/RWRouteConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public class RWRouteConfig {
private float husActivateThreshold;
/* PBlock within which RWRoute must stay within */
private String pblock;

/* true to route backward (Sink ->...->Source) */
private boolean backwardRouting;

/** Constructs a Configuration Object */
public RWRouteConfig(String[] arguments) {
Expand Down Expand Up @@ -247,6 +250,9 @@ private void parseArguments(String[] arguments) {
case "--lutRoutethru":
setLutRoutethru(true);
break;
case "--backwardRouting":
setBackwardRouting(true);
break;
case "--noInvertGndToVccForLutInputs":
setInvertGndToVccForLutInputs(false);
break;
Expand Down Expand Up @@ -1081,4 +1087,20 @@ public String toString() {

return s.toString();
}

/**
* Checks if backward routing is enabled.
* @return true if backward routing is enabled, false otherwise.
*/
public boolean isBackwardRouting() {
return backwardRouting;
}

/**
* Sets the backward routing flag.
* @param backwardRouting true to enable backward routing, false otherwise.
*/
public void setBackwardRouting(boolean backwardRouting) {
this.backwardRouting = backwardRouting;
}
}
6 changes: 5 additions & 1 deletion src/com/xilinx/rapidwright/rwroute/RouteNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ private void setBaseCost(RouteNodeGraph routingGraph) {
case NODE_LAGUNA_DATA: // LAG_LAG.UBUMP* super long lines for u-turns at the boundary of the device (US+)
case NODE_SLL_INPUT: // Versal only
case NODE_SLL_OUTPUT: // Versal only
case NODE_GLOBAL_LEAF:
case NODE_INT_INTERFACE:
case NODE_DEDICATED:
case NODE_OPTDELAY:
Comment on lines +176 to +179
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be excluding these nodes from the routing graph entirely (they weren't needed during forward routing)

case INTENT_DEFAULT: // INT.VCC_WIRE
assert(length == 0);
break;
Expand Down Expand Up @@ -495,7 +499,7 @@ public float getBaseCost() {
public RouteNode[] getChildren(RouteNodeGraph routingGraph) {
if (children == null) {
long start = RuntimeTracker.now();
List<Node> allDownHillNodes = getAllDownhillNodes();
List<Node> allDownHillNodes = routingGraph.backwardRouting ? getAllUphillNodes() : getAllDownhillNodes();
List<RouteNode> childrenList = new ArrayList<>(allDownHillNodes.size());
for (Node downhill : allDownHillNodes) {
if (isExcluded(routingGraph, downhill)) {
Expand Down
8 changes: 8 additions & 0 deletions src/com/xilinx/rapidwright/rwroute/RouteNodeGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ protected static int getTileCount(Design design) {
/** Flag to enable really comprehensive (but performance-impacting) assertions */
protected final static boolean enableComprehensiveAssertions = false;

protected final boolean backwardRouting;

public RouteNodeGraph(Design design, RWRouteConfig config) {
this.design = design;
lutRoutethru = config.isLutRoutethru();
lutPinSwapping = config.isLutPinSwapping();
backwardRouting = config.isBackwardRouting();

this.nodesMap = new RouteNode[getTileCount(design)][];
nodesMapSize = new AtomicInteger();
Expand Down Expand Up @@ -1171,6 +1174,11 @@ public boolean isAccessible(RouteNode childRnode, RouteNode parentRnode, Connect
protected boolean allowRoutethru(RouteNode head, Node tail) {
final boolean isCLB = Utils.isCLB(tail.getTile().getTileTypeEnum());

if (backwardRouting) {
// FIXME: Need a better way to identify LUT routethrus than INT -> CLB edge
return true;
}

if (isVersal) {
if (tail.getIntentCode() == IntentCode.NODE_CLE_OUTPUT &&
head.getIntentCode() == IntentCode.NODE_PINFEED &&
Expand Down
32 changes: 31 additions & 1 deletion test/src/com/xilinx/rapidwright/rwroute/TestRWRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,15 @@ Design testSingleConnectionHelper(String partName,
String srcSiteName, String srcPinName,
String dstSiteName, String dstPinName,
long nodesPoppedLimit) {
boolean backwardRouting = false;
return testSingleConnectionHelper(partName, srcSiteName, srcPinName, dstSiteName, dstPinName, nodesPoppedLimit, backwardRouting);
}

Design testSingleConnectionHelper(String partName,
String srcSiteName, String srcPinName,
String dstSiteName, String dstPinName,
long nodesPoppedLimit,
boolean backwardRouting) {
Design design = new Design("top", partName);

Net net = design.createNet("net");
Expand All @@ -394,10 +403,16 @@ Design testSingleConnectionHelper(String partName,
List<SitePinInst> pinsToRoute = new ArrayList<>();
pinsToRoute.add(dstSpi);
boolean softPreserve = false;
PartialRouter.routeDesignPartialNonTimingDriven(design, pinsToRoute, softPreserve);

if (backwardRouting) {
PartialRouter.routeDesignPartialNonTimingDrivenBackward(design, pinsToRoute, softPreserve);
} else {
PartialRouter.routeDesignPartialNonTimingDriven(design, pinsToRoute, softPreserve);
}

Assertions.assertTrue(srcSpi.isRouted());
Assertions.assertTrue(dstSpi.isRouted());

long nodesPopped = Long.parseLong(System.getProperty("rapidwright.rwroute.nodesPopped"));
Assertions.assertTrue(nodesPopped >= (nodesPoppedLimit - 100) && nodesPopped <= nodesPoppedLimit);

Expand Down Expand Up @@ -559,6 +574,21 @@ public void testSingleConnection(String partName,
nodesPoppedLimit);
}

@ParameterizedTest
@CsvSource({
"xcau10p,SLICE_X0Y0,A_O,SLICE_X0Y1,A1,400"
})
public void testSingleConnectionBackward(String partName,
String srcSiteName, String srcPinName,
String dstSiteName, String dstPinName,
int nodesPoppedLimit) {
testSingleConnectionHelper(partName,
srcSiteName, srcPinName,
dstSiteName, dstPinName,
nodesPoppedLimit,
true);
}

@Test
public void testDiscussion1245_20250805() {
// Adapted from https://github.com/Xilinx/RapidWright/discussions/1245#discussioncomment-14003055
Expand Down