Skip to content

Commit 790066a

Browse files
committed
Routing Heat Map Example
Signed-off-by: Chris Lavin <[email protected]>
1 parent d6c5567 commit 790066a

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

src/com/xilinx/rapidwright/MainEntrypoint.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import com.xilinx.rapidwright.placer.handplacer.ModuleOptimizer;
8686
import com.xilinx.rapidwright.router.RouteThruHelper;
8787
import com.xilinx.rapidwright.router.Router;
88+
import com.xilinx.rapidwright.router.RoutingHeatMap;
8889
import com.xilinx.rapidwright.rwroute.CUFR;
8990
import com.xilinx.rapidwright.rwroute.PartialCUFR;
9091
import com.xilinx.rapidwright.rwroute.PartialRouter;
@@ -191,6 +192,7 @@ private static void addFunction(String name, MainStyleFunction<?> func) {
191192
addFunction("ReportTimingExample", ReportTimingExample::main);
192193
addFunction("Router", Router::main);
193194
addFunction("RouteThruHelper", RouteThruHelper::main);
195+
addFunction("RoutingHeatMap", RoutingHeatMap::main);
194196
addFunction("RunSATRouterExample", RunSATRouterExample::main);
195197
addFunction("RWRoute", RWRoute::main);
196198
addFunction("SLRCrosserGenerator", SLRCrosserGenerator::main);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2025, Advanced Micro Devices, Inc.
3+
* All rights reserved.
4+
*
5+
* Author: Chris Lavin, AMD Research and Advanced Development.
6+
*
7+
* This file is part of RapidWright.
8+
*
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
*
21+
*/
22+
23+
package com.xilinx.rapidwright.router;
24+
25+
import java.io.BufferedWriter;
26+
import java.io.FileWriter;
27+
import java.io.IOException;
28+
import java.util.HashMap;
29+
import java.util.Map;
30+
31+
import com.xilinx.rapidwright.design.Design;
32+
import com.xilinx.rapidwright.design.Net;
33+
import com.xilinx.rapidwright.device.PIP;
34+
import com.xilinx.rapidwright.device.Tile;
35+
import com.xilinx.rapidwright.device.TileTypeEnum;
36+
37+
/**
38+
* Simple tool for generating a routing heat map as a CSV for a given DCP.
39+
*/
40+
public class RoutingHeatMap {
41+
42+
public static void main(String[] args) {
43+
if (args.length != 2) {
44+
System.out.println("USAGE: <routed_input.dcp> <output.csv>");
45+
return;
46+
}
47+
Design d = Design.readCheckpoint(args[0]);
48+
Map<Tile, Integer> heatMap = new HashMap<>();
49+
50+
for (Net n : d.getNets()) {
51+
for (PIP p : n.getPIPs()) {
52+
if (p.getTile().getTileTypeEnum() == TileTypeEnum.INT) {
53+
heatMap.merge(p.getTile(), 1, Integer::sum);
54+
}
55+
}
56+
}
57+
58+
Tile[][] intTiles = d.getDevice().getTilesByRootName(TileTypeEnum.INT.name());
59+
60+
try (BufferedWriter bw = new BufferedWriter(new FileWriter(args[1]))) {
61+
for (int i = 0; i < intTiles.length; i++) {
62+
Tile[] intArray = intTiles[i];
63+
for (int j = 0; j < intArray.length; j++) {
64+
Tile t = intArray[j];
65+
Integer val = heatMap.get(t);
66+
bw.write((val == null ? 0 : val) + ",");
67+
}
68+
bw.write("\n");
69+
}
70+
} catch (IOException e) {
71+
e.printStackTrace();
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)