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

Fixed file naming issues when having multiple instances of an IP #58

Merged
merged 6 commits into from
Mar 18, 2020
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
4 changes: 2 additions & 2 deletions src/com/xilinx/rapidwright/design/blocks/PBlockGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,14 @@ public ArrayList<String> generatePBlockFromReport(String reportFileName, String
}
sb.append("SLICE_X" + upperLeft.getInstanceX() + "Y" + (upperLeft.getInstanceY()-(numSLICERows-1)) +
":SLICE_X" + (upperLeft.getInstanceX()+(numSLICEColumns+numSLICEMColumns)-1) + "Y" + upperLeft.getInstanceY());
}
}
if(numBRAMColumns > 0){
int pIdx = 0;
for(int i=0; pIdx < p.size(); i++){
TileTypeEnum t = dev.getTile(row, col+i).getTileTypeEnum();
if(Utils.isBRAM(t)){
for(Site s : dev.getTile(row, col+i).getSites()){
if(s.getSiteTypeEnum() == SiteTypeEnum.RAMBFIFO36) upperLeft = s;
if((s.getSiteTypeEnum() == SiteTypeEnum.RAMBFIFO36)||(s.getSiteTypeEnum() == SiteTypeEnum.RAMBFIFO36E1)) upperLeft = s; // Update. Goal: support for 7 series
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this change looks good. I will follow up later with a better check for BRAMs.

}
break;
}
Expand Down
51 changes: 41 additions & 10 deletions src/com/xilinx/rapidwright/placer/blockplacer/BlockPlacer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public class BlockPlacer2 {
private String inputXPNFileName;
private double alpha;
private double beta;

// Update. Added variable to support partial .dcp
public boolean save_partial_dcp = true;

/**
* Empty Constructor
Expand Down Expand Up @@ -602,6 +605,8 @@ public Design placeDesign(Design design, boolean debugFlow){
Arrays.sort(array);

HashSet<Tile> usedTiles = new HashSet<Tile>();
// Added variable for genreating partial dcp
boolean save_and_exit = false;
// Perform final placement of all hard macros
for(HardMacro hm : array){
//System.out.println(moveCount.get(hm) + " " + hm.tileSize + " " + hm.getName());
Expand All @@ -610,13 +615,25 @@ public Design placeDesign(Design design, boolean debugFlow){

if(!placeModuleNear((ModuleInst)hm, hm.getTempAnchorSite().getTile(), usedTiles)){
System.out.println("Saving as debug.");
MessageGenerator.briefErrorAndExit("ERROR: Placement failed, couldn't find valid site for " + hm.getName());
// Updated code. Goal: if placement fails, unplace that IP and generate .dcp in order to let vivado continue PAR
if(save_partial_dcp) {
save_and_exit = true;
System.out.println("ERROR: Placement failed for "+hm.getName());
hm.unplace();
} else
MessageGenerator.briefErrorAndExit("ERROR: Placement failed, couldn't find valid site for " + hm.getName());
}
}
else{
usedTiles.addAll(footPrint);
if(!hm.place(hm.getTempAnchorSite())){
MessageGenerator.briefErrorAndExit("ERROR: Problem placing " + hm.getName() + " on site: " + hm.getTempAnchorSite());
// Updated code. Goal: if placement fails, unplace that IP and generate .dcp in order to let vivado continue PAR
if(save_partial_dcp) {
save_and_exit = true;
System.out.println("ERROR: Placement failed for "+hm.getName());
hm.unplace();
} else
MessageGenerator.briefErrorAndExit("ERROR: Problem placing " + hm.getName() + " on site: " + hm.getTempAnchorSite());
}
}
}
Expand All @@ -626,6 +643,13 @@ public Design placeDesign(Design design, boolean debugFlow){
i.place(i.getSite());
}

// Updated code. Goal: if placement fails, unplace that IP and generate .dcp in order to let vivado continue PAR
if(save_and_exit) {
String placedDCPName = "partialy_placed.dcp";
design.writeCheckpoint(placedDCPName);
MessageGenerator.briefErrorAndExit("ERROR: Placement failed, couldn't find valid site for all the IPs. Partially placed .dcp saved for debug " );
}

return design;
}

Expand Down Expand Up @@ -838,7 +862,9 @@ private boolean getNextMove(HardMacro selected){
}
}


// Updated code. Store initial number of valid Sites
int nr_valid_sites = validSiteRange.size();
int rand_site = 0;
while(true){
/*if(iterations > 10*validSites.size()){
selected = hardMacros.get(rand.nextInt(hardMacros.size()-1));
Expand All @@ -847,25 +873,28 @@ private boolean getNextMove(HardMacro selected){
hm0 = selected;
iterations = 0;
}*/
if(iterations > hardMacros.size()*validSiteRange.size()){
return false;
if(iterations >= nr_valid_sites){ // Updated code. Maximum trial nr = nr valid Sites
return false;
}
iterations++;

//site1 = validSites.get(rand.nextInt(validSites.size()-1));
if (validSiteRange.size()> 0){
if (validSiteRange.size()>1){
site1 = validSiteRange.get(rand.nextInt(validSiteRange.size()-1));
rand_site = rand.nextInt(validSiteRange.size()-1);
site1 = validSiteRange.get(rand_site);
}else{
//site1 = validSiteRange.get(rand.nextInt(validSiteRange.size()));
rand_site = 0;
site1 = validSiteRange.get(0);
}
}else{
return false;
}
if(site0.equals(site1)) {
//if(DEBUG_LEVEL > 1) System.out.println(" SAME SITE");
continue;
validSiteRange.remove(rand_site); // Updated code. Remove sites that were already checked
continue;
}
hm1 = currentPlacements.get(site1);

Expand All @@ -876,7 +905,8 @@ private boolean getNextMove(HardMacro selected){
hm1.setTempAnchorSite(site1, currentPlacements);
hm0.setTempAnchorSite(site0, currentPlacements);
//if(DEBUG_LEVEL > 1) System.out.println(" BAD SWAP");
continue;
validSiteRange.remove(rand_site); // Updated code. Remove sites that were already checked
continue;
}
//System.out.println(hm0.getName()+"<->"+hm1.getName());
break;
Expand All @@ -886,13 +916,14 @@ private boolean getNextMove(HardMacro selected){
if(!checkValidPlacement(hm0)){
hm0.setTempAnchorSite(site0, currentPlacements);
//if(DEBUG_LEVEL > 1) System.out.println(" BAD SITE0");
continue;
validSiteRange.remove(rand_site); // Updated code. Remove sites that were already checked
continue;
}
//System.out.println(hm0.getName()+"-> EMPTY");
break;
}
}
currentMove.setMove(site0, site1, hm0, hm1);
currentMove.setMove(site0, site1, hm0, hm1);
return true;
}

Expand Down
29 changes: 28 additions & 1 deletion tcl/rapidwright.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ proc compile_block_dcp { dcpFile } {
puts "RAPIDWRIGHT_PATH=$rwpath"
puts "CLASSPATH=$cpath"
exec java com.xilinx.rapidwright.util.Unzip ${dcpFile} ${unzipDir}
read_xdc ${unzipDir}/${rootDcpFileName}_in_context.xdc
# Avoid naming problems caused by the fact that the files copied into IP_CACHE have different names as the ones expected by RW. Error appears only in designs with multiple IPs with the same ID
set file_name_xdc [glob -directory ${unzipDir} *_in_context.xdc]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should work. I'm ok with this change, you can delete the old line as it stays in the history of git.

read_xdc $file_name_xdc
file delete -force ${unzipDir}
# END Work around

Expand Down Expand Up @@ -394,6 +396,10 @@ proc prep_for_block_stitcher {} {
puts "WILL RUN: $ip_run $name $ip $id $ip_cell"
}
} elseif { [needs_impl_run $cachePath $ip] && ![info exists uniqueImplIPs($id)] } {
# Goal: avoid errors caused by IP names (in case of multiple IPs, files copied into the IP_CACHE might have different names as RW expects. Possible explanation = RW reads IPs in this loop in a different order as it copies the .dcps already generated by vivado )
if {[get_uniq_ip_name $cachePath $ip]!="none"} {
set ip [get_uniq_ip_name $cachePath $ip]
}
puts "OPT RUN: $ip"
lappend opt_runs_needed $ip
set uniqueImplIPs($id) $ip
Expand Down Expand Up @@ -662,3 +668,24 @@ proc offset_dsps { count } {
puts "Moving $c from $s to $new_site"
}
}


# Get name of ip based on the name of the files copied into the directory with the corresponding ID. Useful for designs using multiple IPs, in order to avoid naming errors after copying files into the IP_CACHE
proc get_uniq_ip_name {cachePath ip} {
set cache_id [config_ip_cache -get_id $ip]
set cacheIPDir "${cachePath}[cache_version_dir]/$cache_id"
if { ! [file exists $cacheIPDir] } {
puts "ERROR! No IP in this folder"
return "none"
}
set existingIP [lindex [get_lines_matching instanceName ${cacheIPDir}/${cache_id}.xci] 0]
set existingIP [string map {"<spirit:instanceName>" ""} $existingIP]
set existingIP [string map {"</spirit:instanceName>" ""} $existingIP]
set existingIP [string trim $existingIP]
set ip_return [get_ips $existingIP]
if {$ip_return!={}} {
return $ip_return
} else {
return $ip
}
}