Skip to content

Commit 041daf0

Browse files
authored
[LUTTools] LUT pin swapping fixes (#938)
* DesignTools.swapMultipleLutPins() to ignore SRL* cells Signed-off-by: Eddie Hung <eddie.hung@amd.com> * DesignTools.swapSingleLutPins() to also swap alt pin mappings Populated for intra-site LUT routethrus (e.g. to get to a FF) Signed-off-by: Eddie Hung <eddie.hung@amd.com> * Bump year Signed-off-by: Eddie Hung <eddie.hung@amd.com> --------- Signed-off-by: Eddie Hung <eddie.hung@amd.com>
1 parent 881c4ca commit 041daf0

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/com/xilinx/rapidwright/design/tools/LUTTools.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
*
33
* Copyright (c) 2018-2022, Xilinx, Inc.
4-
* Copyright (c) 2022-2023, Advanced Micro Devices, Inc.
4+
* Copyright (c) 2022-2024, Advanced Micro Devices, Inc.
55
* All rights reserved.
66
*
77
* Author: Chris Lavin, Xilinx Research Labs.
@@ -36,6 +36,7 @@
3636
import java.util.Queue;
3737
import java.util.Set;
3838

39+
import com.xilinx.rapidwright.design.AltPinMapping;
3940
import com.xilinx.rapidwright.design.Cell;
4041
import com.xilinx.rapidwright.design.Design;
4142
import com.xilinx.rapidwright.design.DesignTools;
@@ -503,11 +504,14 @@ public static int swapMultipleLutPins(Map<SitePinInst, String> oldPinToNewPins)
503504
continue;
504505
}
505506

506-
// Either this is a LUT cell or a routethru ...
507-
assert(cell.getType().startsWith("LUT") ||
508-
cell.isRoutethru() ||
509-
// ... or a distributed RAM cell not on a "H" BEL
510-
cell.getType().startsWith("RAM") && !bel.getName().startsWith("H"));
507+
// Only consider LUT cell or a routethru ...
508+
if (!cell.getType().startsWith("LUT") && !cell.isRoutethru() &&
509+
// ... or distributed RAM cells not on a "H" BEL
510+
(!cell.getType().startsWith("RAM") || bel.getName().startsWith("H"))) {
511+
// SRL cells do not support pin swapping
512+
assert(cell.getType().startsWith("SRL"));
513+
continue;
514+
}
511515

512516
String oldPhysicalPinName = "A" + oldSinkSpi.getName().charAt(1);
513517
String oldLogicalPinName = cell.getLogicalPinMapping(oldPhysicalPinName);
@@ -649,7 +653,15 @@ public static void swapSingleLutPins(String key, Collection<PinSwap> pinSwaps) {
649653

650654
// Perform the actual swap on cell pin mappings
651655
for (PinSwap ps : copyOnWritePinSwaps) {
652-
ps.getCell().addPinMapping(ps.getNewPhysicalName(), ps.getLogicalName());
656+
Cell cell = ps.getCell();
657+
cell.addPinMapping(ps.getNewPhysicalName(), ps.getLogicalName());
658+
if (cell.isRoutethru() && cell.hasAltPinMappings()) {
659+
Map<String, AltPinMapping> altPinMappings = cell.getAltPinMappings();
660+
assert(altPinMappings.size() == 1);
661+
AltPinMapping apm = altPinMappings.remove(ps.getOldPhysicalName());
662+
assert(apm != null);
663+
cell.addAltPinMapping(ps.getNewPhysicalName(), apm);
664+
}
653665
if (ps.getCompanionCell() != null) {
654666
ps.getCompanionCell().addPinMapping(ps.getNewPhysicalName(), ps.getCompanionLogicalName());
655667
}
@@ -658,7 +670,7 @@ public static void swapSingleLutPins(String key, Collection<PinSwap> pinSwaps) {
658670
continue;
659671
}
660672
pinToMove.setPinName(ps.getNewNetPinName());
661-
pinToMove.setSiteInst(ps.getCell().getSiteInst());
673+
pinToMove.setSiteInst(cell.getSiteInst());
662674
}
663675

664676
assert(q.isEmpty());

0 commit comments

Comments
 (0)