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

ModuleInst.place() to check both RAMB36/RAMB18 sites for overlap #841

Merged
merged 4 commits into from
Oct 10, 2023
Merged
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
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));
}
}