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

Adding shape support for DREAMPlaceFPGA inputs and Interchange Netlist #1011

Open
wants to merge 14 commits into
base: dreamplacefpga
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,7 @@ public static void createMissingStaticSitePins(BELPin belPin, SiteInst si, Cell
//NOTE: SRL16E (reference name SRL16E, EDIFCell in RW) uses A2-A5, so we need to connect A1 & A6 to VCC,
//however, when SitePinInsts (e.g. A3) are already in GND, adding those again will cause problems to A1
static String[] lut6BELPins = new String[] {"A1", "A6"};
static HashSet<String> unisimFlipFlopTypes;
public static HashSet<String> unisimFlipFlopTypes;
static {
unisimFlipFlopTypes = new HashSet<>();
unisimFlipFlopTypes.add("FDSE");//S CE, logical cell
Expand Down
183 changes: 183 additions & 0 deletions src/com/xilinx/rapidwright/design/shapes/Shape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* 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.shapes;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.xilinx.rapidwright.design.Cell;
import com.xilinx.rapidwright.design.Design;
import com.xilinx.rapidwright.device.BEL;
import com.xilinx.rapidwright.device.Device;
import com.xilinx.rapidwright.device.Site;
import com.xilinx.rapidwright.device.SiteTypeEnum;

/**
* A set of cells that are intended to be placed together as a structured unit.
*/
public class Shape {

private Map<Cell, ShapeLocation> map;

private Set<ShapeTag> tags;

private int width;

private int height;

private Shape nextChain;

public Shape() {
map = new LinkedHashMap<>();
tags = new HashSet<>();
width = 1;
height = 1;
}

public Set<Cell> getCells() {
return map.keySet();
}

public Map<Cell, ShapeLocation> getCellMap() {
return map;
}

protected void setCellMap(Map<Cell, ShapeLocation> map) {
this.map = map;
}

/**
* @return the width
*/
public int getWidth() {
return width;
}

/**
* @param width the width to set
*/
public void setWidth(int width) {
this.width = width;
}

/**
* @return the height
*/
public int getHeight() {
return height;
}

/**
* @param height the height to set
*/
public void setHeight(int height) {
this.height = height;
}

public Cell addCell(String name, Design design, int dx, int dy, String belName, String cellType) {
Cell cell = design.getCell(name);
if (cell == null) {
cell = new Cell(name);
cell.setType(cellType);
design.addCell(cell);
cell.setEDIFHierCellInst(design.getNetlist().getHierCellInstFromName(name));
assert (cellType.equals(cell.getEDIFHierCellInst().getCellName()));
} else if (cell.getEDIFHierCellInst() == null) {
cell.setEDIFHierCellInst(design.getNetlist().getHierCellInstFromName(name));
}

Map<SiteTypeEnum, Set<String>> placements = cell.getCompatiblePlacements();

List<SiteTypeEnum> compatibleSiteTypes = new ArrayList<>();
for (Entry<SiteTypeEnum, Set<String>> e : placements.entrySet()) {
if (e.getValue().contains(belName)) {
compatibleSiteTypes.add(e.getKey());
}
}

ShapeLocation loc = new ShapeLocation(compatibleSiteTypes, belName, dx, dy);
map.put(cell, loc);
return cell;
}

public Set<ShapeTag> getTags() {
return tags;
}

public void setTags(Set<ShapeTag> tags) {
this.tags = tags;
}

public boolean addTag(ShapeTag tag) {
return tags.add(tag);
}

public boolean hasTag(ShapeTag tag) {
return tags.contains(tag);
}

public String toString() {
StringBuilder sb = new StringBuilder();
for (Entry<Cell, ShapeLocation> e : map.entrySet()) {
sb.append("(" + e.getValue().getCompatibleSiteTypes() + "_X" + e.getValue().getDx() + "Y"
+ e.getValue().getDy() + ", " + e.getValue().getBelName() + ")\t" + e.getKey().getName() + " ("
+ e.getKey().getType() + ")\n");
}
sb.append("Tags(s): " + getTags() + "\n");
sb.append("WxH: " + getWidth() + "x" + getHeight() + "\n");
return sb.toString();
}

protected Shape getNextChain() {
return nextChain;
}

protected void setNextChain(Shape nextChain) {
this.nextChain = nextChain;
}

/**
* Gets the highest/largest LUT letter name from the BEL names used in all the
* cells. Examines both 6LUT and 5LUT locations.
*
* @return The highest LUT letter used in the shape.
*/
public char getLargestLUTLetter() {
char c = Character.MIN_VALUE;
for (ShapeLocation loc : map.values()) {
String belName = loc.getBelName();
if (belName.contains("LUT")) {
char lutLetter = belName.charAt(0);
if (c < lutLetter) {
c = lutLetter;
}
}
}
return c;
}
}
88 changes: 88 additions & 0 deletions src/com/xilinx/rapidwright/design/shapes/ShapeLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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.shapes;

import java.util.List;

import com.xilinx.rapidwright.device.SiteTypeEnum;

/**
* Set of attributes applied to a cell that is part of a shape.
*/
public class ShapeLocation {

private List<SiteTypeEnum> compatibleSiteTypes;

private String belName;

private int dx;

private int dy;

public ShapeLocation(List<SiteTypeEnum> siteTypes, String belName, int dx, int dy) {
this.compatibleSiteTypes = siteTypes;
this.belName = belName;
this.dx = dx;
this.dy = dy;
}

/**
* @return the compatibleSiteTypes
*/
public List<SiteTypeEnum> getCompatibleSiteTypes() {
return compatibleSiteTypes;
}

/**
* @return the belName
*/
public String getBelName() {
return belName;
}

public void setBelName(String belName) {
this.belName = belName;
}

/**
* @return the dx
*/
public int getDx() {
return dx;
}

/**
* @return the dy
*/
public int getDy() {
return dy;
}

public void setDx(int dx) {
this.dx = dx;
}

public void setDy(int dy) {
this.dy = dy;
}

}
59 changes: 59 additions & 0 deletions src/com/xilinx/rapidwright/design/shapes/ShapeTag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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.shapes;

import java.util.HashMap;
import java.util.Map;

public enum ShapeTag {

CLUSTER("Cluster"),
LUTNM("LUTNM"),
CARRY_CHAIN("Carry-chain"),
MUXF7("MuxF7"),
MUXF8("MuxF8"),
MUXF9("MuxF9"),
SRL("SRL"),
RAM32M16("RAM32M16");

private String name;

public static Map<String, ShapeTag> values;

static {
values = new HashMap<>();
for (ShapeTag tag : values()) {
values.put(tag.name, tag);
values.put(tag.name(), tag);
}
}

private ShapeTag(String name) {
this.name = name;
}

public String toString() {
return name;
}

}
Loading
Loading