Skip to content

Commit

Permalink
Merge branch '2024.2.0' of github.com:Xilinx/RapidWright into 2024.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lavin <chris.lavin@amd.com>
  • Loading branch information
clavin-xlnx committed Nov 22, 2024
2 parents 4eddf48 + 4f38f60 commit 6c81257
Show file tree
Hide file tree
Showing 18 changed files with 1,024 additions and 670 deletions.
4 changes: 2 additions & 2 deletions src/com/xilinx/rapidwright/rwroute/CUFR.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public CUFR(Design design, RWRouteConfig config) {

public static class RouteNodeGraphCUFR extends RouteNodeGraph {
public RouteNodeGraphCUFR(Design design, RWRouteConfig config) {
super(design, config, new ConcurrentHashMap<>());
super(design, config);
}

// Do not track createRnodeTime since it is meaningless when multithreading
Expand All @@ -92,7 +92,7 @@ protected void addCreateRnodeTime(long time) {}

public static class RouteNodeGraphCUFRTimingDriven extends RouteNodeGraphTimingDriven {
public RouteNodeGraphCUFRTimingDriven(Design design, RWRouteConfig config, DelayEstimatorBase delayEstimator) {
super(design, config, delayEstimator, new ConcurrentHashMap<>());
super(design, config, delayEstimator);
}

// Do not track createRnodeTime since it is meaningless when multithreading
Expand Down
35 changes: 19 additions & 16 deletions src/com/xilinx/rapidwright/rwroute/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,6 @@ public boolean isCongested() {
return false;
}

/**
* Checks if a connection is routed through any rnodes that have multiple drivers.
* @return
*/
public boolean useRnodesWithMultiDrivers() {
for (RouteNode rn : getRnodes()) {
if (rn.hasMultiDrivers()) {
return true;
}
}
return false;
}

/**
* Add the give RouteNode to the list of those used by this Connection.
* Expand the bounding box accordingly, since this node could describe an
Expand Down Expand Up @@ -299,13 +286,17 @@ public List<RouteNode> getAltSinkRnodes() {
return altSinkRnodes == null ? Collections.emptyList() : altSinkRnodes;
}

public boolean hasAltSinks() {
return altSinkRnodes != null && !altSinkRnodes.isEmpty();
}

public void addAltSinkRnode(RouteNode sinkRnode) {
if (altSinkRnodes == null) {
altSinkRnodes = new ArrayList<>(1);
} 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 @@ -351,6 +342,10 @@ public NetWrapper getNetWrapper() {
return this.netWrapper;
}

public Net getNet() {
return netWrapper.getNet();
}

public SitePinInst getSource() {
return source;
}
Expand Down Expand Up @@ -469,7 +464,7 @@ public String toString() {
}

public void setAllTargets(RWRoute.ConnectionState state) {
if (sinkRnode.countConnectionsOfUser(netWrapper) == 0 ||
if (sinkRnode.countConnectionsOfUser(netWrapper) == 1 ||
sinkRnode.getIntentCode() == IntentCode.NODE_PINBOUNCE) {
// Since this connection will have been ripped up, only mark a node
// as a target if it's not already used by this net.
Expand All @@ -487,7 +482,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 Expand Up @@ -515,4 +510,12 @@ protected Pair<SitePinInst,RouteNode> getOrCreateAlternateSource(RouteNodeGraph
assert(altSourceRnode != null);
return new Pair<>(altSource, altSourceRnode);
}

public boolean isRouted() {
return sink.isRouted();
}

public void setRouted(boolean isRouted) {
sink.setRouted(isRouted);
}
}
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 @@ -331,22 +331,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 @@ -381,19 +379,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 @@ -520,18 +532,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 @@ -553,7 +553,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 @@ -564,6 +566,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 @@ -591,8 +594,6 @@ public static void routeStaticNet(Net currNet,
currNet.addPin(spi, updateSiteRouting);
spi.setRouted(true);
}

currNet.setPIPs(netPIPs);
}

/**
Expand Down
30 changes: 30 additions & 0 deletions src/com/xilinx/rapidwright/rwroute/NetWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,34 @@ public SitePinInst getOrCreateAlternateSource(RouteNodeGraph routingGraph) {
public RouteNode getAltSourceRnode() {
return altSourceRnode;
}

public boolean hasMultipleDrivers(int sequence) {
for (Connection connection : connections) {
List<RouteNode> rnodes = connection.getRnodes();
if (rnodes.isEmpty()) {
continue;
}

RouteNode driver = rnodes.get(rnodes.size() - 2);
for (int i = rnodes.size() - 1; i >= 0; i--) {
assert(driver != null);
RouteNode rnode = rnodes.get(i);
if (rnode.isVisited(sequence)) {
// Rnode has already been visited by a prior connection;
// check if driver is same as this connection
RouteNode prev = rnode.getPrev();
if (prev != driver) {
return true;
}
} else {
// Rnode has not been visited by this net yet,
// set initial prev
rnode.setVisited(sequence);
rnode.setPrev(driver);
}
driver = rnode;
}
}
return false;
}
}
9 changes: 5 additions & 4 deletions src/com/xilinx/rapidwright/rwroute/PartialCUFR.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public PartialCUFR(Design design, RWRouteConfig config, Collection<SitePinInst>

public static class RouteNodeGraphPartialCUFR extends RouteNodeGraphPartial {
public RouteNodeGraphPartialCUFR(Design design, RWRouteConfig config) {
super(design, config, new ConcurrentHashMap<>());
super(design, config);
}

// Do not track createRnodeTime since it is meaningless when multithreading
Expand All @@ -72,7 +72,7 @@ protected void addCreateRnodeTime(long time) {}

public static class RouteNodeGraphPartialCUFRTimingDriven extends RouteNodeGraphPartialTimingDriven {
public RouteNodeGraphPartialCUFRTimingDriven(Design design, RWRouteConfig config, DelayEstimatorBase delayEstimator) {
super(design, config, delayEstimator, new ConcurrentHashMap<>());
super(design, config, delayEstimator);
}

// Do not track createRnodeTime since it is meaningless when multithreading
Expand Down Expand Up @@ -137,9 +137,10 @@ protected void routeIndirectConnections(Collection<Connection> connections) {
}

@Override
protected void unpreserveNet(Net net) {
super.unpreserveNet(net);
protected NetWrapper unpreserveNet(Net net) {
NetWrapper netWrapper = super.unpreserveNet(net);
needsRepartitioning = true;
return netWrapper;
}

@Override
Expand Down
Loading

0 comments on commit 6c81257

Please sign in to comment.