Skip to content

Commit

Permalink
ModuleInst.place() to check both RAMB36/RAMB18 sites for overlap (#841)
Browse files Browse the repository at this point in the history
* ModuleInst.place() to check both RAMB36/RAMB18 sites for overlap

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

* Consider RAMBFIFO18 too

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

* Add test

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

---------

Signed-off-by: Eddie Hung <[email protected]>
  • Loading branch information
eddieh-xlnx authored Oct 10, 2023
1 parent cf1cdea commit ac3296b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/com/xilinx/rapidwright/design/ModuleInst.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,37 @@ public boolean place(Site newAnchorSite, boolean skipIncompatible, boolean allow
Tile newTile = module.getCorrespondingTile(templateSite.getTile(), newAnchorSite.getTile());
Site newSite = templateSite.getCorrespondingSite(inst.getSiteTypeEnum(), newTile);

SiteInst existingSiteInst = allowOverlap ? null : design.getSiteInstFromSite(newSite);
SiteInst existingSiteInst;
if (allowOverlap) {
existingSiteInst = null;
} else {
existingSiteInst = design.getSiteInstFromSite(newSite);
if (existingSiteInst == null) {
SiteTypeEnum siteType = newSite.getSiteTypeEnum();
if (siteType == SiteTypeEnum.RAMBFIFO36) { // UltraScale+
// Check that both RAMB18s are free
for (Site alternateSite : newTile.getSites()) {
if (alternateSite.getSiteTypeEnum() != SiteTypeEnum.RAMBFIFO18 &&
alternateSite.getSiteTypeEnum() != SiteTypeEnum.RAMB181) {
continue;
}
existingSiteInst = design.getSiteInstFromSite(alternateSite);
if (existingSiteInst != null) {
break;
}
}
} else if (siteType == SiteTypeEnum.RAMB181) { // UltraScale+
// Check that RAMB36 is free
for (Site alternateSite : newTile.getSites()) {
if (alternateSite.getSiteTypeEnum() != SiteTypeEnum.RAMBFIFO36) {
continue;
}
existingSiteInst = design.getSiteInstFromSite(alternateSite);
break;
}
}
}
}

if (newSite == null || existingSiteInst != null) {
//MessageGenerator.briefError("ERROR: No matching site found." +
Expand Down
42 changes: 42 additions & 0 deletions test/src/com/xilinx/rapidwright/design/TestModuleInst.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package com.xilinx.rapidwright.design;

import com.xilinx.rapidwright.device.Device;
import com.xilinx.rapidwright.device.PIP;
import com.xilinx.rapidwright.device.Site;
import com.xilinx.rapidwright.device.Tile;
Expand All @@ -34,6 +35,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.HashSet;
Expand Down Expand Up @@ -247,4 +249,44 @@ public void testPlaceWithDepopulatedNodes() {
Assertions.assertEquals(70560, validAnchorSites.size());

}

@ParameterizedTest
@CsvSource({
"RAMB36E2,RAMB36_X1Y0/RAMB36E2", // Regular RAMB36 conflict
"RAMB18E2,RAMB18_X1Y0/RAMB18E2_L", // Regular RAMB18 (lower) conflict
"RAMB18E2,RAMB18_X1Y1/RAMB18E2_U", // Regular RAMB18 (upper) conflict
"FIFO18E2,RAMB18_X1Y0/BELI_FIFO18E2_FIFO18E2", // Regular FIFO18 (lower) conflict
})
public void testPlaceChecksBRAM(String unisim, String location) {
Design design = RapidWrightDCP.loadDCP("picoblaze_ooc_X10Y235.dcp");
Device device = design.getDevice();

// Unroute partially routed clock that cannot be relocated
design.getNet("clk").unroute();

Design emptyDesign = new Design("emptyDesign", design.getPartName());
Module module = new Module(design, false);
design = null;

ModuleInst mi = emptyDesign.createModuleInst("inst", module);
// Check placement successful
boolean skipIncompatible = false;
boolean allowOverlap = false;
Site newAnchor = device.getSite("SLICE_X16Y2");
Assertions.assertTrue(mi.place(newAnchor, skipIncompatible, allowOverlap));
mi.unplace();

// Place a cell there
Cell cell = emptyDesign.createAndPlaceCell("test_ram", Unisim.valueOf(unisim), location);
SiteInst si = cell.getSiteInst();
Assertions.assertNotNull(si);

// Check conflict is detected
Assertions.assertFalse(mi.place(newAnchor, skipIncompatible, allowOverlap));
Assertions.assertFalse(mi.isPlaced());

// Check conflict is cleared
emptyDesign.unplaceDesign();
Assertions.assertTrue(mi.place(newAnchor, skipIncompatible, allowOverlap));
}
}

0 comments on commit ac3296b

Please sign in to comment.