Skip to content

Commit

Permalink
Merge branch 'signal_router_optimize' into rwroute_cleanup2
Browse files Browse the repository at this point in the history
Conflicts:
	src/com/xilinx/rapidwright/rwroute/RWRoute.java
	src/com/xilinx/rapidwright/rwroute/RouteNode.java
	src/com/xilinx/rapidwright/rwroute/RouteNodeGraph.java
	src/com/xilinx/rapidwright/rwroute/RouteNodeType.java
  • Loading branch information
eddieh-xlnx committed Nov 14, 2024
2 parents e00bd91 + fb08d82 commit 3bfcdf4
Show file tree
Hide file tree
Showing 40 changed files with 2,041 additions and 366 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ jobs:
single_threaded: [multi-threaded, single-threaded]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- uses: actions/checkout@v4

- name: Setup JDK 1.11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

- name: Setup Python 3.7
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.7

- name: Cache Jars & Data
id: cache-rapidwright
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
data
Expand Down
6 changes: 1 addition & 5 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ configurations.testFixturesImplementation.canBeResolved = true
configurations.api.canBeResolved = true

tasks.withType(Test) {
if (System.getenv("GITHUB_ACTION")) {
maxHeapSize = "5G"
} else {
maxHeapSize = "10G"
}
maxHeapSize = "10G"
//Propagate JVM settings to test JVM
jvmArgs applicationDefaultJvmArgs

Expand Down
4 changes: 3 additions & 1 deletion src/com/xilinx/rapidwright/MainEntrypoint.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021-2022, Xilinx, Inc.
* Copyright (c) 2022-2023, Advanced Micro Devices, Inc.
* Copyright (c) 2022-2024, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Author: Jakob Wenzel, Xilinx Research Labs.
Expand Down Expand Up @@ -103,6 +103,7 @@
import com.xilinx.rapidwright.util.PartPrinter;
import com.xilinx.rapidwright.util.PerformanceExplorer;
import com.xilinx.rapidwright.util.ReplaceEDIFInDCP;
import com.xilinx.rapidwright.util.ReportRouteStatus;
import com.xilinx.rapidwright.util.StringTools;
import com.xilinx.rapidwright.util.Unzip;
import com.xilinx.rapidwright.util.performance_evaluation.PerformanceEvaluation;
Expand Down Expand Up @@ -186,6 +187,7 @@ private static void addFunction(String name, MainStyleFunction<?> func) {
addFunction("RelocationTools", RelocationTools::main);
addFunction("ReplaceEDIFInDCP", ReplaceEDIFInDCP::main);
addFunction("ReportDevicePerformance", ReportDevicePerformance::main);
addFunction("ReportRouteStatus", ReportRouteStatus::main);
addFunction("ReportTimingExample", ReportTimingExample::main);
addFunction("Router", Router::main);
addFunction("RouteThruHelper", RouteThruHelper::main);
Expand Down
42 changes: 10 additions & 32 deletions src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -4317,49 +4317,27 @@ public static void updatePinsIsRouted(Net net) {
return;
}

Queue<Node> queue = new ArrayDeque<>();
Map<Node, List<Node>> node2fanout = new HashMap<>();
for (PIP pip : net.getPIPs()) {
boolean isReversed = pip.isReversed();
Node startNode = isReversed ? pip.getEndNode() : pip.getStartNode();
Node endNode = isReversed ? pip.getStartNode() : pip.getEndNode();
node2fanout.computeIfAbsent(startNode, k -> new ArrayList<>())
.add(endNode);
if (pip.isBidirectional()) {
node2fanout.computeIfAbsent(endNode, k -> new ArrayList<>())
.add(startNode);
}

if ((net.getType() == NetType.GND && startNode.isTiedToGnd()) ||
(net.getType() == NetType.VCC && startNode.isTiedToVcc())) {
queue.add(startNode);
}
}

Map<Node, SitePinInst> node2spi = new HashMap<>();
for (SitePinInst spi : net.getPins()) {
Node node = spi.getConnectedNode();
if (spi.isOutPin()) {
if (node2fanout.get(node) == null) {
// Skip source pins with no fanout
continue;
}
queue.add(node);
}
node2spi.put(node, spi);
}

Queue<NetTools.NodeTree> queue = new ArrayDeque<>();
for (NetTools.NodeTree node : NetTools.getNodeTrees(net)) {
if (node.fanouts.isEmpty()) {
// Skip source pins with no fanout
continue;
}
queue.add(node);
}
while (!queue.isEmpty()) {
Node node = queue.poll();
NetTools.NodeTree node = queue.poll();
SitePinInst spi = node2spi.get(node);
if (spi != null) {
spi.setRouted(true);
}

List<Node> fanouts = node2fanout.remove(node);
if (fanouts != null) {
queue.addAll(fanouts);
}
queue.addAll(node.fanouts);
}
}

Expand Down
98 changes: 98 additions & 0 deletions src/com/xilinx/rapidwright/design/NetTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@

package com.xilinx.rapidwright.design;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.xilinx.rapidwright.device.Node;
import com.xilinx.rapidwright.device.PIP;
import com.xilinx.rapidwright.device.SiteTypeEnum;

public class NetTools {
Expand All @@ -46,4 +53,95 @@ public static boolean isGlobalClock(Net net) {

return clkSrcSiteTypeEnums.contains(srcSpi.getSiteTypeEnum());
}

public static class NodeTree extends Node {
public List<NodeTree> fanouts = Collections.emptyList();
public NodeTree(Node node) {
super(node);
}

public void addFanout(NodeTree node) {
if (fanouts.isEmpty()) {
fanouts = new ArrayList<>(1);
}
fanouts.add(node);
}

private void buildString(StringBuilder sb,
boolean subtreeStart,
boolean branchStart,
boolean branchEndIfNoFanouts,
boolean subTreeEndIfNoFanouts) {
// Adopt the same spacing as Vivado's report_route_status
sb.append(" ");
sb.append(subtreeStart ? "[" : " ");
sb.append(branchStart ? "{" : " ");
sb.append(" ");
boolean branchEnd = branchEndIfNoFanouts && fanouts.isEmpty();
sb.append(branchEnd ? "}" : " ");
boolean subtreeEnd = subTreeEndIfNoFanouts && branchEnd;
sb.append(subtreeEnd ? "]" : " ");
sb.append(String.format(" %30s", super.toString()));
sb.append("\n");

subtreeStart = false;
for (int i = 0; i < fanouts.size(); i++) {
NodeTree fanout = fanouts.get(i);
boolean lastFanout = (i == fanouts.size() - 1);
branchStart = !lastFanout && (fanouts.size() > 1);
branchEndIfNoFanouts = lastFanout || branchStart;
fanout.buildString(sb, subtreeStart, branchStart, branchEndIfNoFanouts,
subTreeEndIfNoFanouts && !branchStart && lastFanout);
}
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
boolean subtreeStart = true;
boolean branchStart = true;
boolean branchEndIfNoFanouts = true;
boolean subTreeEndIfNoFanouts = true;
buildString(sb, branchStart, subtreeStart, branchEndIfNoFanouts, subTreeEndIfNoFanouts);
return sb.toString();
}
}

/**
* Compute the node routing tree of the given Net by examining its PIPs.
* Note that this method: (a) assumes that no loops are present, (b) only discovers subtrees that start at an
* output SitePinInst or a node tied to VCC/GND (i.e. gaps and islands will be ignored).
* @param net Net to analyze
* @return A list of NodeTree objects, corresponding to the root of each subtree.
*/
public static List<NodeTree> getNodeTrees(Net net) {
List<NodeTree> subtrees = new ArrayList<>();
Map<Node, NodeTree> nodeMap = new HashMap<>();
for (PIP pip : net.getPIPs()) {
if (pip.isEndWireNull()) {
continue;
}
boolean isReversed = pip.isReversed();
NodeTree startNode = nodeMap.computeIfAbsent(isReversed ? pip.getEndNode() : pip.getStartNode(), NodeTree::new);
NodeTree endNode = nodeMap.computeIfAbsent(isReversed ? pip.getStartNode() : pip.getEndNode(), NodeTree::new);
startNode.addFanout(endNode);
if (!pip.isBidirectional()) {
if ((net.getType() == NetType.GND && startNode.isTiedToGnd()) ||
(net.getType() == NetType.VCC && startNode.isTiedToVcc())) {
subtrees.add(startNode);
}
}
}

for (SitePinInst spi : net.getPins()) {
if (!spi.isOutPin()) {
continue;
}
Node node = spi.getConnectedNode();
NodeTree nodeTree = nodeMap.computeIfAbsent(node, NodeTree::new);
subtrees.add(nodeTree);
}

return subtrees;
}
}
3 changes: 3 additions & 0 deletions src/com/xilinx/rapidwright/design/blocks/PBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class PBlock extends ArrayList<PBlockRange> {
pblockTypes.add(SiteTypeEnum.SLICEM);
pblockTypes.add(SiteTypeEnum.DSP48E1);
pblockTypes.add(SiteTypeEnum.DSP48E2);
pblockTypes.add(SiteTypeEnum.DSP58_PRIMARY);
pblockTypes.add(SiteTypeEnum.DSP58);
pblockTypes.add(SiteTypeEnum.DSPFP);
pblockTypes.add(SiteTypeEnum.RAMB180);
pblockTypes.add(SiteTypeEnum.RAMB181);
pblockTypes.add(SiteTypeEnum.RAMB18E1);
Expand Down
43 changes: 43 additions & 0 deletions src/com/xilinx/rapidwright/design/tools/Edge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Author: Chris Lavin, AMD Research and Advanced Development.
*
* This file is part of RapidWright.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xilinx.rapidwright.design.tools;

/**
* Describes the edge types of rectangles when composed of tiles.
*/
public enum Edge {
NORTH,
EAST,
SOUTH,
WEST,
NORTH_EAST,
SOUTH_EAST,
SOUTH_WEST,
NORTH_WEST,
INTERNAL,
EXTERNAL;

public boolean isEdgeCrossing() {
return this != INTERNAL && this != EXTERNAL;
}
}
3 changes: 2 additions & 1 deletion src/com/xilinx/rapidwright/design/tools/LUTTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ public static String getLUTInitFromEquation(String equation, int lutSize) {
boolean result = b.eval(i);
if (result) init = setBit(init,i);
}
return length + "'h" + Long.toUnsignedString(init, 16).toUpperCase();
int initLength = Integer.max(1, length >>> 2);
return length + "'h" + String.format("%0" + initLength + "x", init).toUpperCase();
}

/**
Expand Down
Loading

0 comments on commit 3bfcdf4

Please sign in to comment.