⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cellchangejobs.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				List<NodeInst> replaceThese = new ArrayList<NodeInst>();				for (Iterator<NodeInst> it = newCell.getNodes(); it.hasNext(); )				{					NodeInst ni = it.next();					Cell replaceCell = newCells.get(ni.getProto());					if (replaceCell != null) replaceThese.add(ni);				}				for(NodeInst ni : replaceThese)				{					// replace old icon(s) in duplicated cell					Cell replaceCell = newCells.get(ni.getProto());					ni.replace(replaceCell, true, true);				}			}			return true;		}		public void terminateOK()		{			// change the display of old cell to the new one			WindowFrame curWf = WindowFrame.getCurrentWindowFrame();			if (curWf != null)			{				WindowContent content = curWf.getContent();				if (content != null && content.getCell() == cell)				{					curWf.setCellWindow(dupCell, null);					return;				}			}			// current cell was not duplicated: see if any displayed cell is			for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); )			{				WindowFrame wf = it.next();				WindowContent content = wf.getContent();				if (content != null && content.getCell() == cell)				{					curWf.setCellWindow(dupCell, null);					return;				}			}		}	}	/****************************** COPY CELLS ******************************/	/**	 * Method to recursively copy cells between libraries.	 * @param fromCells the original cells being copied.	 * @param toLib the destination library to copy the cell.	 * @param verbose true to display extra information.	 * @param move true to move instead of copy.	 * @param allRelatedViews true to copy all related views (schematic cell with layout, etc.)	 * If false, only schematic/icon relations are copied.	 * @param copySubCells true to recursively copy sub-cells.  If true, "useExisting" must be true.	 * @param useExisting true to use any existing cells in the destination library	 * instead of creating a cross-library reference.  False to copy everything needed.	 * @return address of a copied cell (null on failure).	 */	public static IdMapper copyRecursively(List<Cell> fromCells, Library toLib, boolean verbose, boolean move,		boolean allRelatedViews, boolean copySubCells, boolean useExisting)	{		IdMapper idMapper = new IdMapper();		Cell.setAllowCircularLibraryDependences(true);		try {			Map<String,Map<String,String>> existing = new HashMap<String,Map<String,String>>();			for(Cell fromCell : fromCells)			{				Cell copiedCell = copyRecursively(fromCell, toLib, verbose, move, "", true,					allRelatedViews, allRelatedViews, copySubCells, useExisting, existing, idMapper);				if (copiedCell == null) break;			}		} finally {			Cell.setAllowCircularLibraryDependences(false);		}		return idMapper;	}	/**	 * Method to recursively copy cells between libraries.	 * @param fromCell the original cell being copied.	 * @param toLib the destination library to copy the cell.	 * @param verbose true to display extra information.	 * @param move true to move instead of copy.	 * @param subDescript a String describing the nature of this copy (empty string initially).	 * @param schematicRelatedView true to copy a schematic related view.  Typically this is true,	 * meaning that if copying an icon, also copy the schematic.  If already copying the example icon,	 * this is set to false so that we don't get into a loop.	 * @param allRelatedViews true to copy all related views (schematic cell with layout, etc.)	 * If false, only schematic/icon relations are copied.	 * @param allRelatedViewsThisLevel true to copy related views for this	 * level of invocation only (but further recursion will use "allRelatedViews").	 * @param copySubCells true to recursively copy sub-cells.  If true, "useExisting" must be true.	 * @param useExisting true to use any existing cells in the destination library	 * instead of creating a cross-library reference.  False to copy everything needed.	 * @param existing a map that disambiguates cell names when they clash in different original libraries.	 * The main key is an old cell name, and the value for that key is a map of library names to new cell names.	 * So, for example, if libraries "A" and "B" both have a cell called "X", then existing.get("X").get("A") is "X" but	 * existing.get(X").get("B") is "X_1" which disambiguates the cell names in the destination library.	 */	private static Cell copyRecursively(Cell fromCell, Library toLib, boolean verbose, boolean move, String subDescript,		boolean schematicRelatedView, boolean allRelatedViews, boolean allRelatedViewsThisLevel, boolean copySubCells,		boolean useExisting, Map<String,Map<String,String>> existing, IdMapper idMapper)	{		// check for sensibility		if (copySubCells && !useExisting)			System.out.println("Cross-library copy warning: It makes no sense to copy subcells but not use them");		// see if the cell is already there		String toName = fromCell.getName();		View toView = fromCell.getView();		Cell copiedCell = inDestLib(fromCell, existing, toLib);		if (copiedCell != null)			return copiedCell;		// copy subcells		if (copySubCells || fromCell.isSchematic())		{			boolean found = true;			while (found)			{				found = false;				for(Iterator<NodeInst> it = fromCell.getNodes(); it.hasNext(); )				{					NodeInst ni = it.next();					if (!copySubCells && !ni.isIconOfParent()) continue;					if (!ni.isCellInstance()) continue;					Cell cell = (Cell)ni.getProto();					// allow cross-library references to stay					if (cell.getLibrary() == toLib) continue;					// see if the cell is already there					if (inDestLib(cell, existing, toLib) != null) continue;					// do not copy subcell if it exists already (and was not copied by this operation)					if (useExisting && !copySubCells)					{						if (toLib.findNodeProto(cell.noLibDescribe()) != null) continue;					}					// copy subcell if not already there					boolean doCopySchematicView = true;					if (ni.isIconOfParent()) doCopySchematicView = false;					Cell oNp = copyRecursively(cell, toLib, verbose,						move, "subcell ", doCopySchematicView, allRelatedViews, allRelatedViewsThisLevel,						copySubCells, useExisting, existing, idMapper);					if (oNp == null)					{						if (move) System.out.println("Move of sub" + cell + " failed"); else							System.out.println("Copy of sub" + cell + " failed");						return null;					}					found = true;					break;				}			}		}		// see if copying related views		if (!allRelatedViewsThisLevel)		{			// not copying related views: just copy schematic if this was icon			if (toView == View.ICON && schematicRelatedView /*&& move*/ )			{				// now copy the schematics				boolean found = true;				while (found)				{					found = false;					assert fromCell.isLinked();					for(Iterator<Cell> it = fromCell.getCellGroup().getCells(); it.hasNext(); )					{						Cell np = it.next();						if (!np.isSchematic()) continue;						// see if the cell is already there						if (inDestLib(np, existing, toLib) != null) continue;						// copy equivalent view if not already there						Cell oNp = copyRecursively(np, toLib, verbose,							move, "schematic view ", true, allRelatedViews, false, copySubCells, useExisting, existing, idMapper);						if (oNp == null)						{							if (move) System.out.println("Move of schematic view " + np + " failed"); else								System.out.println("Copy of schematic view " + np + " failed");							return null;						}						found = true;						break;					}					if (!fromCell.isLinked())						return inDestLib(fromCell, existing, toLib);				}			}		} else		{			// first copy the icons			boolean found = true;			Cell fromCellWalk = fromCell;			while (found)			{				found = false;				for(Iterator<Cell> it = fromCellWalk.getCellGroup().getCells(); it.hasNext(); )				{					Cell np = it.next();					if (!np.isIcon()) continue;					// see if the cell is already there					if (inDestLib(np, existing, toLib) != null) continue;					// copy equivalent view if not already there					Cell oNp = copyRecursively(np, toLib, verbose,						move, "alternate view ", true, allRelatedViews, false, copySubCells, useExisting, existing, idMapper);					if (oNp == null)					{						if (move) System.out.println("Move of alternate view " + np + " failed"); else							System.out.println("Copy of alternate view " + np + " failed");						return null;					}					found = true;					break;				}			}			// now copy the rest			found = true;			while (found)			{				found = false;				for(Iterator<Cell> it = fromCellWalk.getCellGroup().getCells(); it.hasNext(); )				{					Cell np = it.next();					if (np.isIcon()) continue;					// see if the cell is already there					if (inDestLib(np, existing, toLib) != null) continue;					// copy equivalent view if not already there					Cell oNp = copyRecursively(np, toLib, verbose,						move, "alternate view ", true, allRelatedViews, false, copySubCells, useExisting, existing, idMapper);					if (oNp == null)					{						if (move) System.out.println("Move of alternate view " + np + " failed"); else							System.out.println("Copy of alternate view " + np + " failed");						return null;					}					found = true;					break;				}			}		}		// see if the cell is NOW there		copiedCell = inDestLib(fromCell, existing, toLib);		if (copiedCell != null) return copiedCell;		// get the proper cell name to use in the destination library		Map<String,String> libToNameMap = existing.get(fromCell.getName());		if (libToNameMap == null)		{			libToNameMap = new HashMap<String,String>();			existing.put(fromCell.getName(), libToNameMap);		}		String newName = libToNameMap.get(fromCell.getLibrary().getName());		if (newName == null)		{			for(int i=0; i<1000; i++)			{				newName = toName;				if (i > 0) newName += "_" + i;				if (!libToNameMap.values().contains(newName)) break;			}			libToNameMap.put(fromCell.getLibrary().getName(), newName);		}		newName += ";" + fromCell.getVersion();		if (toView.getAbbreviation().length() > 0)			newName += toView.getAbbreviationExtension();		Cell newFromCell = Cell.copyNodeProto(fromCell, toLib, newName, useExisting, existing);		if (newFromCell == null)		{			System.out.println("Copy of " + subDescript + fromCell + " failed");			return null;		}		// Message before the delete!!		if (verbose)		{			if (fromCell.getLibrary() != toLib)			{				String msg = "";				if (move) msg += "Moved "; else					 msg += "Copied ";				msg += subDescript + fromCell.libDescribe() + " to " + toLib;				System.out.println(msg);			} else			{				System.out.println("Copied " + subDescript + newFromCell);			}		}		// if moving, adjust pointers and kill original cell		if (move)		{			// now replace old instances with the moved one			for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )			{				Library lib = it.next();				for(Iterator<Cell> cIt = lib.getCells(); cIt.hasNext(); )				{					Cell np = cIt.next();					boolean found = true;					while (found)					{						found = false;						for(Iterator<NodeInst> nIt = np.getNodes(); nIt.hasNext(); )						{							NodeInst ni = nIt.next();							if (ni.getProto() == fromCell)							{								NodeInst replacedNi = ni.replace(newFromCell, false, false);								if (replacedNi == null)								{									System.out.println("Error moving " + ni + " in " + np);									found = false;								}								else									found = true;								break;							}						}					}				}			}			idMapper.moveCell(fromCell.backup(), newFromCell.getId());			fromCell.kill();		}		return newFromCell;	}	/**	 * Method to tell whether a cell exists in the destination library.	 * @param cell the Cell in question.	 * @param existing a map that disambiguates cell names when they clash in different original libraries.	 * The main key is an old cell name, and the value for that key is a map of library names to new cell names.	 * So, for example, if libraries "A" and "B" both have a cell called "X", then existing.get("X").get("A") is "X" but	 * existing.get(X").get("B") is "X_1" which disambiguates the cell names in the destination library.	 * @param destLib the destination library being searched.	 * @return a Cell from the destination library that matches the Cell being searched (null if none).	 */	private static Cell inDestLib(Cell cell, Map<String,Map<String,String>> existing, Library destLib)	{		Map<String,String> libToNameMap = existing.get(cell.getName());		if (libToNameMap == null) return null;		String newCellName = libToNameMap.get(cell.getLibrary().getName());		if (newCellName == null) return null;		Cell copiedCell = destLib.findNodeProto(newCellName + ";" + cell.getVersion() + cell.getView().getAbbreviationExtension());		return copiedCell;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -