diff --git a/src/com/xilinx/rapidwright/edif/EDIFNetlist.java b/src/com/xilinx/rapidwright/edif/EDIFNetlist.java index 601f0f3dc..dd00e981e 100644 --- a/src/com/xilinx/rapidwright/edif/EDIFNetlist.java +++ b/src/com/xilinx/rapidwright/edif/EDIFNetlist.java @@ -481,26 +481,41 @@ public List getComments() { } /** - * Migrates all cells in the provided library - * into the standard work library. - * @param library The library with cells to be migrated to work. + * Migrates all cells in the provided library into the standard work library. + * + * @param library The library with cells to be migrated to work. + * @param renameCollisions Flag to rename cells upon name collision */ - public void migrateToWorkLibrary(String library) { + public void migrateToWorkLibrary(String library, boolean renameCollisions) { EDIFLibrary work = getWorkLibrary(); EDIFLibrary oldWork = getLibrary(library); List toRemove = new ArrayList<>(oldWork.getCells()); for (EDIFCell c : toRemove) { oldWork.removeCell(c); - work.addCell(c); + if (renameCollisions) { + work.addCellRenameDuplicates(c, "Work"); + } else { + work.addCell(c); + } } removeLibrary(library); } /** - * Migrates all libraries except HDI primitives and work to - * the work library. + * Migrates all cells in the provided library into the standard work library. + * + * @param library The library with cells to be migrated to work. */ - public void consolidateAllToWorkLibrary() { + public void migrateToWorkLibrary(String library) { + migrateToWorkLibrary(library, false); + } + + /** + * Migrates all libraries except HDI primitives and work to the work library. + * + * @param renameCollisions Flag to rename cells upon name collision + */ + public void consolidateAllToWorkLibrary(boolean renameCollisions) { List librariesToMigrate = new ArrayList<>(); for (EDIFLibrary l : getLibraries()) { if (!l.isHDIPrimitivesLibrary() && !l.isWorkLibrary()) { @@ -508,10 +523,17 @@ public void consolidateAllToWorkLibrary() { } } for (EDIFLibrary l : librariesToMigrate) { - migrateToWorkLibrary(l.getName()); + migrateToWorkLibrary(l.getName(), renameCollisions); } } + /** + * Migrates all libraries except HDI primitives and work to the work library. + */ + public void consolidateAllToWorkLibrary() { + consolidateAllToWorkLibrary(false); + } + private EDIFCell migrateCellAndSubCellsWorker(EDIFCell cell) { EDIFLibrary srcLib = cell.getLibrary(); EDIFLibrary destLib = getLibrary(srcLib.getName()); diff --git a/src/com/xilinx/rapidwright/ipi/BlockStitcher.java b/src/com/xilinx/rapidwright/ipi/BlockStitcher.java index 2d84eaf58..0b7de6d52 100644 --- a/src/com/xilinx/rapidwright/ipi/BlockStitcher.java +++ b/src/com/xilinx/rapidwright/ipi/BlockStitcher.java @@ -107,16 +107,17 @@ public class BlockStitcher { private ArrayList getPassThruPortInsts(Port port, EDIFHierPortInst curr) { ArrayList list = new ArrayList<>(); for (String name : port.getPassThruPortNames()) { - EDIFPortInst passThruInst = curr.getPortInst().getCellInst().getPortInst(name); + EDIFHierCellInst hierInst = curr.getHierarchicalInst(); + EDIFPortInst passThruInst = hierInst.getInst().getPortInst(name); if (passThruInst == null) { - String unconnected = curr.getPortInst().getCellInst().getName() + EDIFTools.EDIF_HIER_SEP + name; + String unconnected = hierInst.getInst().getName() + EDIFTools.EDIF_HIER_SEP + name; if (!reportedUnconnects.contains(unconnected)) { System.out.println("INFO: Port " + unconnected + " is unconnected"); reportedUnconnects.add(unconnected); } continue; } - EDIFHierPortInst passThru = new EDIFHierPortInst(curr.getHierarchicalInst(), passThruInst); + EDIFHierPortInst passThru = new EDIFHierPortInst(hierInst.getParent(), passThruInst); list.add(passThru); } return list; @@ -462,7 +463,7 @@ public static void main(String[] args) { } t.stop().start("Reading Top Level EDIF"); EDIFNetlist topEdifNetlist = EDIFTools.readEdifFile(args[1]); - Design stitched = new Design("top_stitched", stitcher.partName); + Design stitched = new Design(topEdifNetlist.getName(), stitcher.partName); stitched.setNetlist(topEdifNetlist); t.stop().start("Implement Blocks"); stitcher.populateModuleInstMaps(topEdifNetlist); @@ -534,7 +535,7 @@ public static void main(String[] args) { } //System.out.println(modInstName + " " + implementationIndex); EDIFNetlist tmp = stitched.getNetlist(); - stitched.setNetlist(null); + stitched.setNetlist(EDIFTools.createNewNetlist("dummy")); ModuleInst mi = stitched.createModuleInst(modInstName, modImpls.get(implementationIndex)); stitched.setNetlist(tmp); miMap.put(mi, modImpls.getNetlist()); @@ -590,18 +591,19 @@ public static void main(String[] args) { inst.setCellType(cellType); } - for (EDIFCell c : stitched.getNetlist().getLibrary("IP_Integrator_Lib").getCells()) { - work.addCell(c); - } - - ArrayList libsToRemove = new ArrayList<>(); - for (EDIFLibrary lib : stitched.getNetlist().getLibraries()) { - if (lib.getName().equals(EDIFTools.EDIF_LIBRARY_HDI_PRIMITIVES_NAME) || - lib.getName().equals(EDIFTools.EDIF_LIBRARY_WORK_NAME)) continue; - libsToRemove.add(lib.getName()); - } - for (String lib : libsToRemove) { - stitched.getNetlist().removeLibrary(lib); + // Move all cells to 'work' library + boolean renameCollisions = true; + stitched.getNetlist().consolidateAllToWorkLibrary(renameCollisions); + EDIFLibrary workLib = stitched.getNetlist().getWorkLibrary(); + for (EDIFCell workCell : workLib.getCells()) { + for (EDIFCellInst inst : workCell.getCellInsts()) { + EDIFLibrary lib = inst.getCellType().getLibrary(); + if (lib.isHDIPrimitivesLibrary() || lib == workLib) { + continue; + } else { + inst.setCellType(work.getCell(inst.getCellType().getName())); + } + } } t.stop(); if (DUMP_SYNTH_DCP_ONLY) {