|
| 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