Skip to content

Commit

Permalink
Minor improvements for the PBlockGenerator, failure to produce a pblo…
Browse files Browse the repository at this point in the history
…ck when large number of shapes.
  • Loading branch information
clavin-xlnx committed Oct 24, 2018
1 parent 06d06c7 commit 035372c
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions com/xilinx/rapidwright/design/blocks/PBlockGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public class PBlockGenerator {
public int STARTING_X = -1; // Parameterized with command line argument when present.
public int STARTING_Y = -1; // Parameterized with command line argument when present.
public int PBLOCK_COUNT = 1;

public int MAX_COLUMNS = 30;


public static final int AVOID_NULL_COLUMN_COUNT = 2;

public static final PBlockGenEmitter emitter = new PBlockGenEmitter();
Expand Down Expand Up @@ -164,6 +166,10 @@ private void getTallestShape(String shapesReportFileName){
try {
BufferedReader br = new BufferedReader(new FileReader(shapesReportFileName));
String line = null;
int ffCount = 0;
int lutCount = 0;
int carryCount = 0;
double fractionalShapeArea = 0.0;
while((line = br.readLine()) != null){
if(line.startsWith("WxH: ")){
int pos = line.lastIndexOf('x');
Expand All @@ -176,16 +182,32 @@ private void getTallestShape(String shapesReportFileName){
if(widestShape < widthDim){
widestShape = widthDim;
}
shapeArea += widthDim * heightDim;

double sliceUsage = Math.max(((double)lutCount)/LUTS_PER_CLE, ((double)ffCount)/FF_PER_CLE);
sliceUsage = Math.max(sliceUsage, ((double)carryCount));
fractionalShapeArea += (carryCount > 0 || lutCount > 0 || ffCount > 0) ? sliceUsage : widthDim * heightDim;

lutCount = 0;
ffCount = 0;
carryCount = 0;
}else if(line.startsWith("(SLICE")){
if(line.contains("FF")) ffCount++;
else if(line.contains("LUT")) lutCount++;
else if(line.contains("CARRY")) carryCount++;
}else if(line.contains("Shape builder is called from")){
// It seems in some shape DB dumps, there is a stack trace followed by another, updated set of shapes.
// If we see this, reset and start over
tallestShape = 0;
widestShape = 0;
shapeArea = 0;
fractionalShapeArea = 0.0;
ffCount = 0;
lutCount = 0;
carryCount = 0;
continue;
}
}
shapeArea = (int) fractionalShapeArea;
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
Expand Down Expand Up @@ -803,6 +825,23 @@ public ArrayList<String> generatePBlockFromReport(String reportFileName, String
}else {
pblockCLEHeight = bramCLECount;
}

// Sanity check on height with respect to SLICE needs
// w
// |-------| Area = A (Math.max(slicesRequired,sliceMsRequired))
// | | Width = w
// | A | h Height = h
// | | Aspect Ratio = r (ASPECT_RATIO)
// |-------|
// A = w * h; w = h * r
// A = (h * r) * h
// A = h^2 * r
// h = sqrt(A / r)
//
int checkedCLEHeight = (int) Math.ceil(Math.sqrt(((double) Math.max(slicesRequired,sliceMsRequired)) / ASPECT_RATIO));
if(pblockCLEHeight < checkedCLEHeight){
pblockCLEHeight = checkedCLEHeight;
}

if(pblockCLEHeight > CLE_REGION_HEIGHT){
// If we are taller than a region, let's just stop at region height
Expand All @@ -811,6 +850,7 @@ public ArrayList<String> generatePBlockFromReport(String reportFileName, String
}



// Now, given an aspect ratio, we know how many columns of each we'll need
int numSLICEColumns = (int) Math.ceil((float)slicesRequired / pblockCLEHeight);
numSLICEColumns = (numSLICEColumns > 0) ? numSLICEColumns : 1;
Expand Down

0 comments on commit 035372c

Please sign in to comment.