Skip to content

Commit

Permalink
[LUTTools] Versal pin swapping fixes (#1130)
Browse files Browse the repository at this point in the history
* [LUTTools] Versal fixes

Signed-off-by: Eddie Hung <[email protected]>

* [LUTTools] Cleanup

Signed-off-by: Eddie Hung <[email protected]>

* [TestLUTTools] Add testSwapMultipleLutPinsVersal()

Signed-off-by: Eddie Hung <[email protected]>

* [LUTTools] Revert to using updated DesignTools.getConnectedCells()

Signed-off-by: Eddie Hung <[email protected]>

* Remove unused import

Signed-off-by: Eddie Hung <[email protected]>

---------

Signed-off-by: Eddie Hung <[email protected]>
  • Loading branch information
eddieh-xlnx authored Jan 3, 2025
1 parent f6ac9f9 commit 2e3de2c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/com/xilinx/rapidwright/design/tools/LUTTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public static void swapSingleLutPins(String key, Collection<PinSwap> pinSwaps) {
String oldPhysicalPin = oPins[i];
String newPhysicalPin = ePins[i];
Cell c = emptySlots.get(newPhysicalPin).getCell();
String newNetPinName = c.getSiteWireNameFromPhysicalPin(newPhysicalPin);
String newNetPinName = c.getBELName().substring(0, 1) + newPhysicalPin.charAt(1);
// Handles special cases
if (c.getLogicalPinMapping(oldPhysicalPin) == null) {
Cell neighborLUT = emptySlots.get(newPhysicalPin).checkForCompanionCell();
Expand Down Expand Up @@ -636,13 +636,14 @@ public static void swapSingleLutPins(String key, Collection<PinSwap> pinSwaps) {
Queue<SitePinInst> q = new LinkedList<>();
for (PinSwap ps : copyOnWritePinSwaps) {
Cell cell = ps.getCell();
String oldSitePinName = cell.getSiteWireNameFromPhysicalPin(ps.getOldPhysicalName());
String oldSitePinName = cell.getBELName().substring(0, 1) + ps.getOldPhysicalName().charAt(1);
SiteInst si = cell.getSiteInst();
SitePinInst pinToMove = si.getSitePinInst(oldSitePinName);
q.add(pinToMove);
if (pinToMove == null) {
continue;
}
si.unrouteIntraSiteNet(pinToMove.getBELPin(), cell.getBEL().getPin(ps.getOldPhysicalName()));
pinToMove.setSiteInst(null,true);
// Removes pin mappings to prepare for new pin mappings
cell.removePinMapping(ps.getOldPhysicalName());
Expand Down Expand Up @@ -672,7 +673,9 @@ public static void swapSingleLutPins(String key, Collection<PinSwap> pinSwaps) {
continue;
}
pinToMove.setPinName(ps.getNewNetPinName());
pinToMove.setSiteInst(cell.getSiteInst());
SiteInst si = cell.getSiteInst();
pinToMove.setSiteInst(si);
si.routeIntraSiteNet(pinToMove.getNet(), pinToMove.getBELPin(), cell.getBEL().getPin(ps.getNewPhysicalName()));
}

assert(q.isEmpty());
Expand Down
56 changes: 56 additions & 0 deletions test/src/com/xilinx/rapidwright/design/tools/TestLUTTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
package com.xilinx.rapidwright.design.tools;

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

import com.xilinx.rapidwright.device.SitePIPStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -176,6 +179,59 @@ public void testUpdateLutPinSwapsFromPIPsWithRWRoute(String path, boolean lutPin
System.setProperty("rapidwright.rwroute.lutPinSwapping.deferIntraSiteRoutingUpdates", "false");
}
}

@Test
public void testSwapMultipleLutPinsVersal() {
Design design = RapidWrightDCP.loadDCP("picoblaze_2022.2.dcp");
SiteInst si = design.getSiteInstFromSiteName("SLICE_X140Y3");
SitePinInst spiF6 = si.getSitePinInst("F6");
Net f6 = spiF6.getNet();
Assertions.assertEquals("processor/pc_mode1_lut/O5", f6.getName());
Assertions.assertSame(f6, si.getNetFromSiteWire("F6"));
Assertions.assertTrue(si.getCell("F6_IMR").isRoutethru());
Assertions.assertSame(f6, si.getNetFromSiteWire("F6_IMR_Q"));

SitePinInst spiF3 = si.getSitePinInst("F3");
Net f3 = spiF3.getNet();
Assertions.assertEquals("processor/address_loop[4].output_data.pc_vector_mux_lut/O6", f3.getName());
Assertions.assertSame(f3, si.getNetFromSiteWire("F3"));
Assertions.assertTrue(si.getCell("F3_IMR").isRoutethru());
Assertions.assertSame(f3, si.getNetFromSiteWire("F3_IMR_Q"));

SitePinInst spiF1 = si.getSitePinInst("F1");
Net f1 = spiF1.getNet();
Assertions.assertEquals("processor/address[5]", f1.getName());
Assertions.assertSame(f1, si.getNetFromSiteWire("F1"));
Assertions.assertTrue(si.getCell("F1_IMR").isRoutethru());
Assertions.assertSame(f1, si.getNetFromSiteWire("F1_IMR_Q"));

Map<SitePinInst, String> oldPinToNewPins = new HashMap<>();
oldPinToNewPins.put(spiF6, "F3");
oldPinToNewPins.put(spiF3, "F1");
oldPinToNewPins.put(spiF1, "F6");
LUTTools.swapMultipleLutPins(oldPinToNewPins);

spiF6 = si.getSitePinInst("F6");
Assertions.assertSame(f1, spiF6.getNet());
Assertions.assertSame(f1, si.getNetFromSiteWire("F6"));
Assertions.assertNull(si.getCell("F6_IMR"));
Assertions.assertEquals(SitePIPStatus.ON, si.getSitePIPStatus(si.getSitePIP("F6_IMR", "D")));
Assertions.assertSame(f1, si.getNetFromSiteWire("F6_IMR_Q"));

spiF3 = si.getSitePinInst("F3");
Assertions.assertSame(f6, spiF3.getNet());
Assertions.assertSame(f6, si.getNetFromSiteWire("F3"));
Assertions.assertNull(si.getCell("F3_IMR"));
Assertions.assertEquals(SitePIPStatus.ON, si.getSitePIPStatus(si.getSitePIP("F3_IMR", "D")));
Assertions.assertSame(f6, si.getNetFromSiteWire("F3_IMR_Q"));

spiF1 = si.getSitePinInst("F1");
Assertions.assertSame(f3, spiF1.getNet());
Assertions.assertSame(f3, si.getNetFromSiteWire("F1"));
Assertions.assertNull(si.getCell("F1_IMR"));
Assertions.assertEquals(SitePIPStatus.ON, si.getSitePIPStatus(si.getSitePIP("F1_IMR", "D")));
Assertions.assertSame(f3, si.getNetFromSiteWire("F1_IMR_Q"));
}

@ParameterizedTest
@CsvSource({
Expand Down

0 comments on commit 2e3de2c

Please sign in to comment.