Skip to content

Commit

Permalink
Ensure both clock pins are unrouted on a BRAM
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lavin <[email protected]>
  • Loading branch information
clavin-xlnx committed Feb 25, 2025
1 parent eb3eff8 commit e4591fb
Showing 1 changed file with 96 additions and 95 deletions.
191 changes: 96 additions & 95 deletions src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1542,38 +1542,39 @@ public static void makeBlackBox(Design d, String hierarchicalCellName) {
* @returns A list of site pins (if any) that should also be removed from inter-site routing to complete the unroute.
*/
public static List<SitePinInst> unrouteCellPinSiteRouting(Cell cell, String logicalPinName) {
String physPinName = cell.getPhysicalPinMapping(logicalPinName);
if (physPinName == null) {
physPinName = cell.getDefaultPinMapping(logicalPinName);
}
if (physPinName == null) {
// Assume not routed
return Collections.emptyList();
}
BELPin belPin = cell.getBEL().getPin(physPinName);
SiteInst siteInst = cell.getSiteInst();
Net net = siteInst.getNetFromSiteWire(belPin.getSiteWireName());
if (net == null)
return Collections.emptyList();

List<String> sitePinNames = new ArrayList<>();
List<BELPin> internalTerminals = new ArrayList<>();
List<BELPin> internalSinks = new ArrayList<>();
Set<BELPin> visited = new HashSet<>();
Queue<BELPin> queue = new LinkedList<>();
queue.add(belPin);
List<SitePinInst> sitePinsToRemove = new ArrayList<>();
for (String physPinName : cell.getAllPhysicalPinMappings(logicalPinName)) {
if (physPinName == null) {
physPinName = cell.getDefaultPinMapping(logicalPinName);
}
if (physPinName == null) {
// Assume not routed
return Collections.emptyList();
}
BELPin belPin = cell.getBEL().getPin(physPinName);
SiteInst siteInst = cell.getSiteInst();
Net net = siteInst.getNetFromSiteWire(belPin.getSiteWireName());
if (net == null)
return Collections.emptyList();

while (!queue.isEmpty()) {
BELPin currPin = queue.poll();
visited.add(currPin);
BELPin unrouteSegment = null;
for (BELPin pin : siteInst.getSiteWirePins(currPin.getSiteWireIndex())) {
if (currPin == pin || visited.contains(pin)) {
visited.add(pin);
continue;
}
// Check if it is a site pin, cell pin, sitepip or routethru
switch (pin.getBEL().getBELClass()) {
List<String> sitePinNames = new ArrayList<>();
List<BELPin> internalTerminals = new ArrayList<>();
List<BELPin> internalSinks = new ArrayList<>();
Set<BELPin> visited = new HashSet<>();
Queue<BELPin> queue = new LinkedList<>();
queue.add(belPin);

while (!queue.isEmpty()) {
BELPin currPin = queue.poll();
visited.add(currPin);
BELPin unrouteSegment = null;
for (BELPin pin : siteInst.getSiteWirePins(currPin.getSiteWireIndex())) {
if (currPin == pin || visited.contains(pin)) {
visited.add(pin);
continue;
}
// Check if it is a site pin, cell pin, sitepip or routethru
switch (pin.getBEL().getBELClass()) {
case PORT: {
// We found a site pin, add it to solution set
sitePinNames.add(pin.getName());
Expand All @@ -1594,7 +1595,7 @@ public static List<SitePinInst> unrouteCellPinSiteRouting(Cell cell, String logi
if (pin.getName().equals(otherPinName)) {
otherPin = LUTTools.getLUTOutputPin(pin.getBEL());
}
}
}
if (otherPin != null) {
Net otherNet = siteInst.getNetFromSiteWire(otherPin.getSiteWireName());
if (otherNet != null && net.getName().equals(otherNet.getName())) {
Expand All @@ -1611,84 +1612,84 @@ public static List<SitePinInst> unrouteCellPinSiteRouting(Cell cell, String logi
siteInst.removeCell(otherCell.getBEL());
siteInst.unrouteIntraSiteNet(pin, pin);
}
}
}

}
} else {
// site routing terminates here or is invalid
}
}

} else if (otherCell != cell && otherCell.getLogicalPinMapping(pin.getName()) != null) {
// Don't search farther, we don't need to unroute anything else
if (pin.isInput() && belPin.isInput()) {
internalSinks.add(pin);
} else {
// site routing terminates here or is invalid
}
}

} else if (otherCell != cell && otherCell.getLogicalPinMapping(pin.getName()) != null) {
// Don't search farther, we don't need to unroute anything else
if (pin.isInput() && belPin.isInput()) {
internalSinks.add(pin);
} else {
internalTerminals.add(pin);
}
internalTerminals.add(pin);
}

}
}
break;
}
break;
}
case RBEL: {
// We found a routing BEL, follow its sitepip
SitePIP sitePIP = siteInst.getUsedSitePIP(pin);
if (sitePIP != null) {
BELPin otherPin = pin.isInput() ? sitePIP.getOutputPin() : sitePIP.getInputPin();
Net otherNet = siteInst.getNetFromSiteWire(otherPin.getSiteWireName());
if (otherNet != null && net.getName().equals(otherNet.getName())) {
queue.add(otherPin);
unrouteSegment = otherPin;
} else {
// site routing terminates here or is invalid
case RBEL: {
// We found a routing BEL, follow its sitepip
SitePIP sitePIP = siteInst.getUsedSitePIP(pin);
if (sitePIP != null) {
BELPin otherPin = pin.isInput() ? sitePIP.getOutputPin() : sitePIP.getInputPin();
Net otherNet = siteInst.getNetFromSiteWire(otherPin.getSiteWireName());
if (otherNet != null && net.getName().equals(otherNet.getName())) {
queue.add(otherPin);
unrouteSegment = otherPin;
} else {
// site routing terminates here or is invalid
}
}
break;
}
break;
}
visited.add(pin);
}
if (unrouteSegment != null && unrouteSegment.isInput() && internalSinks.size() == 0) {
// Unroute this branch of the sitePIP
Net otherNet = siteInst.getNetFromSiteWire(unrouteSegment.getSiteWireName());
siteInst.unrouteIntraSiteNet(unrouteSegment, belPin);
siteInst.routeIntraSiteNet(otherNet, unrouteSegment, unrouteSegment);
}
visited.add(pin);
}
if (unrouteSegment != null && unrouteSegment.isInput() && internalSinks.size() == 0) {
// Unroute this branch of the sitePIP
Net otherNet = siteInst.getNetFromSiteWire(unrouteSegment.getSiteWireName());
siteInst.unrouteIntraSiteNet(unrouteSegment, belPin);
siteInst.routeIntraSiteNet(otherNet, unrouteSegment, unrouteSegment);
}
}

List<SitePinInst> sitePinsToRemove = new ArrayList<>();

// This net is routed internally to the site
for (BELPin internalTerminal : internalTerminals) {
if (internalTerminal.isOutput() && internalSinks.size() > 0) {
continue;
}
if (belPin.isOutput()) {
siteInst.unrouteIntraSiteNet(belPin, internalTerminal);
} else {
siteInst.unrouteIntraSiteNet(internalTerminal, belPin);
// This net is routed internally to the site
for (BELPin internalTerminal : internalTerminals) {
if (internalTerminal.isOutput() && internalSinks.size() > 0) {
continue;
}
if (belPin.isOutput()) {
siteInst.unrouteIntraSiteNet(belPin, internalTerminal);
} else {
siteInst.unrouteIntraSiteNet(internalTerminal, belPin);
}
}
}
if (internalSinks.size() == 0) {
for (String sitePinName : sitePinNames) {
SitePinInst pin = siteInst.getSitePinInst(sitePinName);
if (pin != null) {
sitePinsToRemove.add(pin);
if (belPin.isInput()) {
siteInst.unrouteIntraSiteNet(pin.getBELPin(), belPin);
if (internalSinks.size() == 0) {
for (String sitePinName : sitePinNames) {
SitePinInst pin = siteInst.getSitePinInst(sitePinName);
if (pin != null) {
sitePinsToRemove.add(pin);
if (belPin.isInput()) {
siteInst.unrouteIntraSiteNet(pin.getBELPin(), belPin);
} else {
siteInst.unrouteIntraSiteNet(belPin, pin.getBELPin());
}
} else {
siteInst.unrouteIntraSiteNet(belPin, pin.getBELPin());
// Vivado leaves dual output *MUX partially routed, unroute the site for this
// MUX pin
// Could also be a cell with no loads
siteInst.unrouteIntraSiteNet(belPin, siteInst.getBELPin(sitePinName, sitePinName));
}
} else {
// Vivado leaves dual output *MUX partially routed, unroute the site for this MUX pin
// Could also be a cell with no loads
siteInst.unrouteIntraSiteNet(belPin, siteInst.getBELPin(sitePinName, sitePinName));
}
}
if (internalTerminals.size() == 0 && sitePinNames.size() == 0) {
// internal site route with no loads
siteInst.unrouteIntraSiteNet(belPin, belPin);
if (internalTerminals.size() == 0 && sitePinNames.size() == 0) {
// internal site route with no loads
siteInst.unrouteIntraSiteNet(belPin, belPin);
}
}
}
return sitePinsToRemove;
Expand Down Expand Up @@ -4355,7 +4356,7 @@ public static void prepareShellBlackBoxForRouting(Design design) {
}
}

addProhibitConstraint(design, bels);
// addProhibitConstraint(design, bels);
}

private static boolean isUsingSLICEGND(BELPin input, SiteInst si) {
Expand Down

0 comments on commit e4591fb

Please sign in to comment.