Skip to content

Commit

Permalink
More tidying
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Hung <eddie.hung@amd.com>
  • Loading branch information
eddieh-xlnx committed Nov 19, 2024
1 parent ed6f80e commit c43c9fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
6 changes: 6 additions & 0 deletions src/com/xilinx/rapidwright/device/IntentCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public boolean isUltraScaleClockDistribution() {
return NODE_GLOBAL_HDISTR == this || NODE_GLOBAL_VDISTR == this;
}

public boolean isVersalClocking() {
return NODE_GLOBAL_HDISTR == this || NODE_GLOBAL_HDISTR_LOCAL == this || NODE_GLOBAL_HROUTE_HSR == this ||
NODE_GLOBAL_VDISTR == this || NODE_GLOBAL_VDISTR_LVL2 == this || NODE_GLOBAL_VROUTE == this ||
NODE_GLOBAL_GCLK == this || NODE_GLOBAL_LEAF == this || NODE_GLOBAL_BUFG == this;
}

private static final int SERIES7_START_IDX = 23;
private static final int SERIES7_END_IDX = SERIES7_START_IDX + 33 - 1;

Expand Down
52 changes: 19 additions & 33 deletions src/com/xilinx/rapidwright/router/VersalClockRouting.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ public static RouteNode routeToCentroid(Net clk, RouteNode startingRouteNode, Cl
Node currNode = Node.getNode(curr);
RouteNode parent = curr.getParent();
for (Node downhill : currNode.getAllDownhillNodes()) {
IntentCode intentCode = downhill.getIntentCode();
if (parent != null) {
Node parentNode = Node.getNode(parent);
if (parentNode.getIntentCode() == IntentCode.NODE_GLOBAL_VROUTE &&
currNode.getIntentCode() == IntentCode.NODE_GLOBAL_HROUTE_HSR) {
// Disallow ability to go from VROUTE back to HROUTE
continue;
}
if (downhill.getIntentCode() == IntentCode.NODE_GLOBAL_VDISTR_LVL2 &&
if (intentCode == IntentCode.NODE_GLOBAL_VDISTR_LVL2 &&
currNode.getIntentCode() == IntentCode.NODE_GLOBAL_GCLK &&
parentNode.getIntentCode() == IntentCode.NODE_GLOBAL_VROUTE &&
clockRegion.equals(currNode.getTile().getClockRegion()) &&
Expand All @@ -138,13 +139,13 @@ public static RouteNode routeToCentroid(Net clk, RouteNode startingRouteNode, Cl
}

// Only using routing lines to get to centroid
if (!allowedIntentCodes.contains(downhill.getIntentCode())) {
if (!intentCode.isVersalClocking()) {
continue;
}
if (!findCentroidHroute && downhill.getIntentCode() == IntentCode.NODE_GLOBAL_HROUTE_HSR) {
if (!findCentroidHroute && intentCode == IntentCode.NODE_GLOBAL_HROUTE_HSR) {
continue;
}
if (visited.contains(downhill)) continue;
if (!visited.add(downhill)) continue;
RouteNode rn = new RouteNode(downhill.getTile(), downhill.getWireIndex(), curr, curr.getLevel()+1);

// The clockRegion.getApproximateCenter() may return an INVALID_* tile with huge coordinates.
Expand All @@ -153,7 +154,6 @@ public static RouteNode routeToCentroid(Net clk, RouteNode startingRouteNode, Cl
int cost = Math.abs(rnClockRegion.getColumn() - clockRegion.getColumn()) + Math.abs(rnClockRegion.getRow() - clockRegion.getRow());
rn.setCost(cost);
q.add(rn);
visited.add(downhill);
}
if (watchDog-- == 0) {
throw new RuntimeException("ERROR: Could not route from " + startingRouteNode + " to clock region " + clockRegion);
Expand Down Expand Up @@ -296,30 +296,22 @@ public static Map<ClockRegion, RouteNode> routeVrouteToVerticalDistributionLines
* Routes from a vertical distribution centroid to destination horizontal distribution lines
* in the clock regions provided.
* @param clk The current clock net
* @param vertDistLines A map of target clock regions and their respective vertical distribution lines
* @param clockRegions target clock regions
* @param crMap A map of target clock regions and their respective vertical distribution lines
* @return The List of nodes from the centroid to the horizontal distribution line.
*/
public static Map<ClockRegion, RouteNode> routeVerticalToHorizontalDistributionLines(Net clk,
Map<ClockRegion, RouteNode> vertDistLines,
Collection<ClockRegion> clockRegions,
Function<Node, NodeStatus> getNodeStatus) {
Map<ClockRegion, RouteNode> crMap,
Function<Node, NodeStatus> getNodeStatus) {
Map<ClockRegion, RouteNode> distLines = new HashMap<>();
Queue<RouteNode> q = new LinkedList<>();
Set<PIP> allPIPs = new HashSet<>();
Set<Node> visited = new HashSet<>();
Set<IntentCode> allowedIntentCodes = EnumSet.of(
IntentCode.NODE_GLOBAL_HDISTR,
IntentCode.NODE_GLOBAL_VDISTR,
IntentCode.NODE_PINFEED,
IntentCode.NODE_GLOBAL_HDISTR_LOCAL,
IntentCode.NODE_GLOBAL_GCLK
);
nextClockRegion: for (ClockRegion targetCR : clockRegions) {
nextClockRegion: for (Entry<ClockRegion,RouteNode> e : crMap.entrySet()) {
q.clear();
RouteNode vertDistLine = vertDistLines.get(targetCR);
RouteNode vertDistLine = e.getValue();
vertDistLine.setParent(null);
q.add(vertDistLine);
ClockRegion targetCR = e.getKey();
visited.clear();
visited.add(Node.getNode(vertDistLine));

Expand All @@ -328,9 +320,8 @@ public static Map<ClockRegion, RouteNode> routeVerticalToHorizontalDistributionL
IntentCode c = curr.getIntentCode();
Node currNode = Node.getNode(curr);
RouteNode parent = curr.getParent();
if (targetCR.equals(curr.getTile().getClockRegion()) &&
c == IntentCode.NODE_GLOBAL_GCLK &&
parent.getIntentCode() == IntentCode.NODE_GLOBAL_HDISTR_LOCAL) {
if (targetCR.equals(curr.getTile().getClockRegion()) && c == IntentCode.NODE_GLOBAL_GCLK &&
parent.getIntentCode() == IntentCode.NODE_GLOBAL_HDISTR_LOCAL) {
List<PIP> pips = parent.getPIPsBackToSourceByNodes();
for (PIP pip : pips) {
allPIPs.add(pip);
Expand All @@ -347,9 +338,9 @@ public static Map<ClockRegion, RouteNode> routeVerticalToHorizontalDistributionL
}

for (Node downhill: currNode.getAllDownhillNodes()) {
if (!allowedIntentCodes.contains(downhill.getIntentCode())) continue;
if (visited.contains(downhill)) continue;
visited.add(downhill);
IntentCode intentCode = downhill.getIntentCode();
if (intentCode != IntentCode.NODE_PINFEED && !intentCode.isVersalClocking()) continue;
if (!visited.add(downhill)) continue;
q.add(new RouteNode(downhill.getTile(), downhill.getWireIndex(), curr, curr.getLevel()+1));
}
}
Expand Down Expand Up @@ -382,11 +373,6 @@ public static void routeToLCBs(Net clk, Map<ClockRegion, Set<RouteNode>> startin
Queue<RouteNode> q = RouteNode.createPriorityQueue();
Set<PIP> allPIPs = new HashSet<>();
HashSet<RouteNode> visited = new HashSet<>();
Set<IntentCode> allowedIntentCodes = EnumSet.of(
IntentCode.NODE_PINFEED,
IntentCode.NODE_GLOBAL_LEAF,
IntentCode.NODE_GLOBAL_GCLK
);

nextLCB: for (RouteNode lcb : lcbTargets) {
q.clear();
Expand Down Expand Up @@ -415,7 +401,8 @@ public static void routeToLCBs(Net clk, Map<ClockRegion, Set<RouteNode>> startin
for (Node downhill : currNode.getAllDownhillNodes()) {
// Stay in this clock region
if (!currCR.equals(downhill.getTile().getClockRegion())) continue;
if (!allowedIntentCodes.contains(downhill.getIntentCode())) continue;
IntentCode intentCode = downhill.getIntentCode();
if (intentCode != IntentCode.NODE_PINFEED && !intentCode.isVersalClocking()) continue;
RouteNode rn = new RouteNode(downhill.getTile(), downhill.getWireIndex(), curr, curr.getLevel()+1);
if (visited.contains(rn)) continue;
if (rn.getWireName().endsWith("_I_CASC_PIN")) continue;
Expand Down Expand Up @@ -531,8 +518,7 @@ public static Map<ClockRegion, RouteNode> routeToHorizontalDistributionLines(Net
Map<ClockRegion, RouteNode> vertDistLines = routeVrouteToVerticalDistributionLines(clk, vroute, clockRegions, getNodeStatus);

// Second step: start from the VDISTR node and try to find a HDISTR node in the target clock region.
Map<ClockRegion, RouteNode> horiDistLines = routeVerticalToHorizontalDistributionLines(clk, vertDistLines, clockRegions, getNodeStatus);
return horiDistLines;
return routeVerticalToHorizontalDistributionLines(clk, vertDistLines, getNodeStatus);
}

/**
Expand Down

0 comments on commit c43c9fe

Please sign in to comment.