Skip to content

Commit

Permalink
Fix for design merging, including designs with encrypted cells (#1035)
Browse files Browse the repository at this point in the history
* Fix for design merging, including designs with encrypted cells

Signed-off-by: Chris Lavin <[email protected]>

* Adds a method to help with encrypted cell replacement.

Signed-off-by: Chris Lavin <[email protected]>

* Update src/com/xilinx/rapidwright/design/DesignTools.java

Co-authored-by: eddieh-xlnx <[email protected]>
Signed-off-by: Chris Lavin <[email protected]>

* Update src/com/xilinx/rapidwright/design/DesignTools.java

Co-authored-by: eddieh-xlnx <[email protected]>
Signed-off-by: Chris Lavin <[email protected]>

* Simplify

Signed-off-by: Chris Lavin <[email protected]>

---------

Signed-off-by: Chris Lavin <[email protected]>
Co-authored-by: eddieh-xlnx <[email protected]>
  • Loading branch information
clavin-xlnx and eddieh-xlnx authored Aug 28, 2024
1 parent 113e28e commit 4fab822
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
25 changes: 25 additions & 0 deletions src/com/xilinx/rapidwright/design/DesignTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -4192,4 +4192,29 @@ public static void updatePinsIsRouted(Design design) {
updatePinsIsRouted(net);
}
}

/**
* Removes all the existing encrypted cell files from a design and replaces them
* with the provided list and black boxes those cells. The provided files
* should be named after the cell type. This is useful in the scenarios where a
* design has many thousand of individual encrypted cell files that are time
* consuming to load. By providing a higher level of hierarchy cell definition,
* encompassing all existing encrypted cells, the number of individual
* files to be loaded by Vivado can be reduced.
*
* @param design The design to modify.
* @param netlists The list of encrypted cell files (*.edn, *.edf, or *.dcp)
* that should be used instead.
*/
public static void replaceEncryptedCells(Design design, List<Path> netlists) {
EDIFNetlist n = design.getNetlist();
for (Path p : netlists) {
String fileName = p.getFileName().toString();
String cellType = fileName.substring(0, fileName.lastIndexOf('.'));
EDIFCell cell = n.getCell(cellType);
cell.makePrimitive();
}
n.removeUnusedCellsFromAllWorkLibraries();
n.setEncryptedCells(netlists.stream().map(Object::toString).collect(Collectors.toList()));
}
}
2 changes: 1 addition & 1 deletion src/com/xilinx/rapidwright/design/merge/MergeDesigns.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static Design mergeDesigns(Design design0, Design design1, AbstractDesig
}

design0.getNetlist().removeUnusedCellsFromAllWorkLibraries();

design0.getNetlist().resetParentNetMap();
return design0;
}

Expand Down
11 changes: 9 additions & 2 deletions src/com/xilinx/rapidwright/edif/EDIFNetlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -1886,11 +1886,18 @@ public List<String> getEncryptedCells() {
return encryptedCells != null ? encryptedCells : Collections.emptyList();
}

protected void setEncryptedCells(List<String> encryptedCells) {
this.encryptedCells = encryptedCells;
public void setEncryptedCells(List<String> encryptedCells) {
if (encryptedCells == null || encryptedCells.isEmpty()) {
this.encryptedCells = null;
} else {
this.encryptedCells = encryptedCells;
}
}

public void addEncryptedCells(List<String> encryptedCells) {
if (encryptedCells == null || encryptedCells.size() == 0) {
return;
}
if (this.encryptedCells == null) {
setEncryptedCells(encryptedCells);
return;
Expand Down
10 changes: 9 additions & 1 deletion src/com/xilinx/rapidwright/edif/EDIFTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,15 @@ public static void writeTclLoadScriptForPartialEncryptedDesigns(EDIFNetlist edif
Path dcpFileName, String partName) {
ArrayList<String> lines = new ArrayList<String>();
for (String cellName : edif.getEncryptedCells()) {
lines.add(EDIFNetlist.READ_EDIF_CMD + " {" + cellName + "}");
if (cellName.endsWith(".edn") || cellName.endsWith(".edf")) {
lines.add(EDIFNetlist.READ_EDIF_CMD + " {" + cellName + "}");
} else if (cellName.endsWith(".dcp")) {
lines.add("read_checkpoint {" + cellName + "}");
} else if (cellName.endsWith(".v")) {
lines.add("read_verilog {" + cellName + "}");
} else {
System.err.println("ERROR: Unrecognized or missing extension for encrypted cell file: " + cellName);
}
}
Path pathDCPFileName = dcpFileName.toAbsolutePath();

Expand Down

0 comments on commit 4fab822

Please sign in to comment.