Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Interchange] Reorders tile types and tiles to follow their Vivado index #1039

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ public static boolean verifyDeviceResources(String devResFileName, String device
}

// Create a lookup map for tile types
Map<String,TileType.Reader> tileTypeMap = new HashMap<String, TileType.Reader>();
Map<String, TileType.Reader> tileTypeMap = new HashMap<String, TileType.Reader>();
int tileTypeCount = dReader.getTileTypeList().size();
Map<TileTypeEnum, TileType.Reader> tileTypeEnumMap = new HashMap<TileTypeEnum, TileType.Reader>();
HashMap<String, StructList.Reader<DeviceResources.Device.PIP.Reader>> ttPIPMap = new HashMap<>();
for (int i=0; i < dReader.getTileTypeList().size(); i++) {
for (int i=0; i < tileTypeCount; i++) {
TileType.Reader ttReader = dReader.getTileTypeList().get(i);
String name = allStrings.get(ttReader.getName());
tileTypeMap.put(name, ttReader);
Expand Down Expand Up @@ -338,6 +339,7 @@ public static boolean verifyDeviceResources(String devResFileName, String device
expect(tile.getTileTypeEnum().name(), tileTypeName);
expect(tile.getRow(), tileReader.getRow());
expect(tile.getColumn(), tileReader.getCol());
expect(tile.getUniqueAddress(), i);
clavin-xlnx marked this conversation as resolved.
Show resolved Hide resolved

// Verify Tile Types
TileType.Reader tileType = tileTypeMap.get(tileTypeName);
Expand Down
50 changes: 29 additions & 21 deletions src/com/xilinx/rapidwright/interchange/DeviceResourcesWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
Expand All @@ -37,6 +36,7 @@
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import org.capnproto.MessageBuilder;
Expand Down Expand Up @@ -694,13 +694,20 @@ public static Map<TileTypeEnum, Integer> writeAllTileTypesToBuilder(Design desig

Map<TileTypeEnum, Integer> tileTypeIndicies = new HashMap<TileTypeEnum, Integer>();

int i=0;
// Order tile types by their TILE_TYPE_IDX
clavin-xlnx marked this conversation as resolved.
Show resolved Hide resolved
Map<Integer, TileTypeEnum> tileTypeIndexMap = new TreeMap<>();
for (Entry<TileTypeEnum,Tile> e : tileTypes.entrySet()) {
Tile tile = e.getValue();
tileTypeIndexMap.put(e.getValue().getTileTypeIndex(), e.getKey());
}

int i = 0;
for (Entry<Integer, TileTypeEnum> e : tileTypeIndexMap.entrySet()) {
TileTypeEnum type = e.getValue();
Tile tile = tileTypes.get(type);
TileType.Builder tileType = tileTypesList.get(i);
tileTypeIndicies.put(e.getKey(), i);
tileTypeIndicies.put(type, i);
// name
tileType.setName(allStrings.getIndex(e.getKey().name()));
tileType.setName(allStrings.getIndex(type.name()));

// siteTypes
Site[] sites = tile.getSites();
Expand Down Expand Up @@ -785,26 +792,27 @@ public static Map<TileTypeEnum, Integer> writeAllTileTypesToBuilder(Design desig
}

public static void writeAllTilesToBuilder(Device device, DeviceResources.Device.Builder devBuilder, Map<TileTypeEnum, Integer> tileTypeIndicies) {
Collection<Tile> tiles = device.getAllTiles();
StructList.Builder<DeviceResources.Device.Tile.Builder> tileBuilders =
devBuilder.initTileList(tiles.size());
devBuilder.initTileList(device.getColumns() * device.getRows());

int i=0;
for (Tile tile : tiles) {
DeviceResources.Device.Tile.Builder tileBuilder = tileBuilders.get(i);
tileBuilder.setName(allStrings.getIndex(tile.getName()));
tileBuilder.setType(tileTypeIndicies.get(tile.getTileTypeEnum()));
Site[] sites = tile.getSites();
StructList.Builder<DeviceResources.Device.Site.Builder> siteBuilders =
tileBuilder.initSites(sites.length);
for (int j=0; j < sites.length; j++) {
DeviceResources.Device.Site.Builder siteBuilder = siteBuilders.get(j);
siteBuilder.setName(allStrings.getIndex(sites[j].getName()));
siteBuilder.setType(j);
for (Tile[] tiles : device.getTiles()) {
for (Tile tile : tiles) {
DeviceResources.Device.Tile.Builder tileBuilder = tileBuilders.get(i);
tileBuilder.setName(allStrings.getIndex(tile.getName()));
tileBuilder.setType(tileTypeIndicies.get(tile.getTileTypeEnum()));
Site[] sites = tile.getSites();
StructList.Builder<DeviceResources.Device.Site.Builder> siteBuilders = tileBuilder
.initSites(sites.length);
for (int j = 0; j < sites.length; j++) {
DeviceResources.Device.Site.Builder siteBuilder = siteBuilders.get(j);
siteBuilder.setName(allStrings.getIndex(sites[j].getName()));
siteBuilder.setType(j);
}
tileBuilder.setRow((short) tile.getRow());
tileBuilder.setCol((short) tile.getColumn());
i++;
}
tileBuilder.setRow((short)tile.getRow());
tileBuilder.setCol((short)tile.getColumn());
i++;
}

}
Expand Down
Loading