Skip to content

Commit

Permalink
Merge branch 'master' into clock_router
Browse files Browse the repository at this point in the history
  • Loading branch information
eddieh-xlnx committed Nov 18, 2024
2 parents 7470bba + 9cd25a6 commit e23eea3
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 233 deletions.
4 changes: 2 additions & 2 deletions src/com/xilinx/rapidwright/rwroute/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void addAltSinkRnode(RouteNode sinkRnode) {
} else {
assert(!altSinkRnodes.contains(sinkRnode));
}
assert(sinkRnode.getType().isExclusiveSink() ||
assert(sinkRnode.getType().isAnyExclusiveSink() ||
// Can be a WIRE if node is not exclusive a sink
sinkRnode.getType() == RouteNodeType.NON_LOCAL);
altSinkRnodes.add(sinkRnode);
Expand Down Expand Up @@ -487,7 +487,7 @@ public void setAllTargets(RWRoute.ConnectionState state) {
// where the same physical pin services more than one logical pin
if (rnode.countConnectionsOfUser(netWrapper) == 0 ||
// Except if it is not an EXCLUSIVE_SINK
rnode.getType().isExclusiveSink()) {
!rnode.getType().isAnyExclusiveSink()) {
assert(rnode.getIntentCode() != IntentCode.NODE_PINBOUNCE);
rnode.markTarget(state);
}
Expand Down
49 changes: 25 additions & 24 deletions src/com/xilinx/rapidwright/rwroute/GlobalSignalRouting.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,22 +462,20 @@ private static ClockRegion findCentroid(Net clk, Device device) {
}

/**
* Routes a static net (GND or VCC).
* @param currNet The current static net to be routed.
* Routes pins from a static net (GND or VCC).
* @param pins A list of static pins to be routed (must all be on the same net).
* @param getNodeState Lambda to get a node's status (available, unavailable, already in-use).
* @param design The {@link Design} instance to use.
* @param routeThruHelper The {@link RouteThruHelper} instance to use.
*/
public static void routeStaticNet(Net currNet,
public static void routeStaticNet(List<SitePinInst> pins,
Function<Node,NodeStatus> getNodeState,
Design design, RouteThruHelper routeThruHelper) {
NetType netType = currNet.getType();
Set<PIP> netPIPs = new HashSet<>(currNet.getPIPs());
Queue<Node> q = new ArrayDeque<>();
Set<Node> usedRoutingNodes = new HashSet<>();
Map<Node, Node> prevNode = new HashMap<>();
List<Node> pathNodes = new ArrayList<>();
Set<SitePin> sitePinsToCreate = new HashSet<>();
List<SitePin> sitePinsToCreate = new ArrayList<>();
final Node INVALID_NODE = new Node(null, Integer.MAX_VALUE);
assert(INVALID_NODE.isInvalidNode());

Expand Down Expand Up @@ -512,19 +510,33 @@ public static void routeStaticNet(Net currNet,
}

// Collect all node-sink pairs to be routed
Net currNet = null;
Map<Node,SitePinInst> nodeToRouteToSink = new HashMap<>();
for (SitePinInst sink : currNet.getPins()) {
if (sink.isRouted() || sink.isOutPin()) {
for (SitePinInst sink : pins) {
if (currNet == null) {
currNet = sink.getNet();
assert(currNet != null);
} else {
assert(currNet == sink.getNet());
}
assert(!sink.isOutPin());
if (sink.isRouted()) {
continue;
}
nodeToRouteToSink.put(sink.getConnectedNode(), sink);

Node node = sink.getConnectedNode();
if (getNodeState.apply(node) != NodeStatus.INUSE) {
throw new RuntimeException("ERROR: Site pin " + sink + " is not available for net " + currNet);
}
nodeToRouteToSink.put(node, sink);
}

// Sort them by their tile, ensuring that sinks in the same tile are routed in sequence
// to maximize sharing
List<Node> nodesToRoute = new ArrayList<>(nodeToRouteToSink.keySet());
nodesToRoute.sort(Comparator.comparing((n) -> n.getTile().getUniqueAddress()));

NetType netType = currNet.getType();
for (Node node : nodesToRoute) {
int watchdog = 10000;
SitePinInst sink = nodeToRouteToSink.get(node);
Expand Down Expand Up @@ -651,18 +663,6 @@ public static void routeStaticNet(Net currNet,
node = uphillNode;
break search;
}

// uphillNode must be a sink to be routed; preserve only the current routing, clear the queue,
// and restart routing from this new sink to encourage reuse
assert(!uphillSink.isRouted());
do {
usedRoutingNodes.add(node);
node = prevNode.get(node);
} while (node != INVALID_NODE);
prevNode.keySet().removeIf((n) -> !usedRoutingNodes.contains(n) && !n.equals(uphillNode));
q.clear();
q.add(uphillNode);
continue search;
}

q.add(uphillNode);
Expand All @@ -684,7 +684,9 @@ public static void routeStaticNet(Net currNet,

// Note that the static net router goes backward from sinks to sources,
// requiring the srcToSinkOrder parameter to be set to true below
netPIPs.addAll(RouterHelper.getPIPsFromNodes(pathNodes, true));
for (PIP pip : RouterHelper.getPIPsFromNodes(pathNodes, true)) {
currNet.addPIP(pip);
}

pathNodes.clear();
sink.setRouted(true);
Expand All @@ -695,6 +697,7 @@ public static void routeStaticNet(Net currNet,
}
}

assert(sitePinsToCreate.stream().distinct().count() == sitePinsToCreate.size());
for (SitePin sitePin : sitePinsToCreate) {
Site site = sitePin.getSite();
SiteInst si = design.getSiteInstFromSite(site);
Expand Down Expand Up @@ -722,8 +725,6 @@ public static void routeStaticNet(Net currNet,
currNet.addPin(spi, updateSiteRouting);
spi.setRouted(true);
}

currNet.setPIPs(netPIPs);
}

/**
Expand Down
23 changes: 18 additions & 5 deletions src/com/xilinx/rapidwright/rwroute/PartialRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected void determineRoutingTargets() {
preservedNet = routingGraph.getPreservedNet(sinkRnode);
if (preservedNet != null && preservedNet != net) {
unpreserveNets.add(preservedNet);
assert(sinkRnode.getType().isExclusiveSink());
assert(sinkRnode.getType().isAnyExclusiveSink());
}
}

Expand Down Expand Up @@ -290,8 +290,17 @@ protected void addGlobalClkRoutingTargets(Net clk) {

@Override
protected void addStaticNetRoutingTargets(Net staticNet) {
preserveNet(staticNet, true);
if (staticNet.hasPIPs()) {
// Preserve only the static net's PIPs and its output pins; its input pins will be
// preserved by routeStaticNets()
List<SitePinInst> outputPins = new ArrayList<>();
for (SitePinInst spi : staticNet.getPins()) {
if (!spi.isOutPin()) {
continue;
}
outputPins.add(spi);
}
routingGraph.preserveAsync(staticNet, outputPins);
numPreservedStaticNets++;
}

Expand All @@ -310,8 +319,12 @@ protected void addStaticNetRoutingTargets(Net staticNet) {

@Override
protected void preserveNet(Net net, boolean async) {
List<SitePinInst> pinsToRoute = netToPins.get(net);
// Only preserve those pins that are not to be routed
List<SitePinInst> pinsToRoute = null;
if (!net.isStaticNet()) {
// For signal nets, only preserve those pins that are not to be routed
// All sink pins must be preserved for static nets since the static router does not resolve conflicts
pinsToRoute = netToPins.get(net);
}
List<SitePinInst> pinsToPreserve;
if (pinsToRoute == null) {
pinsToPreserve = net.getPins();
Expand Down Expand Up @@ -599,7 +612,7 @@ protected void unpreserveNet(Net net) {
RouteNode sourceRnode = connection.getSourceRnode();
RouteNode sinkRnode = connection.getSinkRnode();
assert(sourceRnode.getType() == RouteNodeType.EXCLUSIVE_SOURCE);
assert(sinkRnode.getType().isExclusiveSink());
assert(sinkRnode.getType().isAnyExclusiveSink());

// Even though this connection is not expected to have any routing yet,
// perform a rip up anyway in order to release any exclusive sinks
Expand Down
Loading

0 comments on commit e23eea3

Please sign in to comment.