📄 viewchanges.java
字号:
startJob(); } public boolean doIt() throws JobException { // convert the cell and all subcells Library newLib = Library.getCurrent(); if (newLibName.length() > 0) { newLib = Library.findLibrary(newLibName); if (newLib == null) newLib = Library.newInstance(newLibName, null); } createdCells = new ArrayList<Cell>(); MakeLayoutVisitor visitor = new MakeLayoutVisitor(oldTech, newTech, oldCell.getLibrary(), createdCells, newLib); HierarchyEnumerator.enumerateCell(oldCell, context, visitor, Netlist.ShortResistors.ALL); fieldVariableChanged("createdCells"); return true; } public void terminateOK() { Cell showCell = null; for(Cell cell : createdCells) { showCell = cell;// System.out.println("Created cell " + cell.describe(true) + " in technology " + newTech.getTechName()); } if (showCell != null) WindowFrame.createEditWindow(showCell); } private static class Info extends HierarchyEnumerator.CellInfo { private Map<Nodable,Cell> generatedCells; public Info() { generatedCells = new HashMap<Nodable,Cell>(); } } private static class MakeLayoutVisitor extends HierarchyEnumerator.Visitor { private Technology oldTech, newTech; private Library defaultLib; private Map<Cell,Cell> convertedCells; private StdCellParams stdCell; private List<Cell> createdCells; private Library newLib; private MakeLayoutVisitor(Technology oldTech, Technology newTech, Library defaultLib, List<Cell> createdCells, Library newLib) { this.oldTech = oldTech; this.newTech = newTech; this.defaultLib = defaultLib; this.createdCells = createdCells; this.newLib = newLib; convertedCells = new HashMap<Cell,Cell>(); TechType.TechTypeEnum type = null; // TODO This code "steals" the intended functionality and diverts it into the gate generator if (oldTech == Schematics.tech()) { if (newTech == Technology.getMocmosTechnology()) type = TechType.TechTypeEnum.MOCMOS; else if (newTech == Technology.findTechnology("TSMC180")) type = TechType.TechTypeEnum.TSMC180; else if (newTech == Technology.findTechnology("CMOS90")) type = TechType.TechTypeEnum.CMOS90; Tech.setTechType(type.getTechType()); Technology cmos90 = Technology.getCMOS90Technology(); if (cmos90 != null && type == TechType.TechTypeEnum.CMOS90) { stdCell = GateLayoutGenerator.sportParams(false); } else { //stdCell = locoParams(outLib); stdCell = GateLayoutGenerator.dividerParams(type, false); //stdCell = justinParams(outLib, technology); if (type == null) stdCell = null; } } } public HierarchyEnumerator.CellInfo newCellInfo() { return new Info(); } private static class Conn { private Nodable no; private PortProto pp; private Name portName; private Conn(Nodable no, PortProto pp, Name portName) { this.no = no; this.pp = pp; this.portName = portName; } } public boolean enterCell(HierarchyEnumerator.CellInfo info) { Cell oldCell = info.getCell(); if (convertedCells.containsKey(oldCell)) return false; if (stdCell != null) { Info myInfo = (Info)info; myInfo.generatedCells = GateLayoutGenerator.generateLayoutFromSchematics( oldCell.getLibrary(), oldCell, info.getContext(), stdCell, true); } return true; } public boolean visitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) { Cell layCell = getLayoutCell(ni, (Info)info); if (layCell == null) return true; return false; } private Cell getLayoutCell(Nodable no, Info myInfo) { if (!no.isCellInstance()) return null; Cell layCell = null; Cell subCell = (Cell)no.getProto(); layCell = myInfo.generatedCells.get(no); if (layCell == null) layCell = convertedCells.get(subCell); if (layCell == null) { if (oldTech == Schematics.tech()) { // see if it already exists for (Iterator<Cell> it = subCell.getCellGroup().getCells(); it.hasNext(); ) { Cell c = it.next(); if (c.getView() == View.LAYOUT) { layCell = c; break; } } if (layCell == null) { String searchCellName = subCell.getName() + "{lay}"; layCell = defaultLib.findNodeProto(searchCellName); } } } if (layCell != null) { convertedCells.put(subCell, layCell); } return layCell; } public void exitCell(HierarchyEnumerator.CellInfo info) { Cell oldCell = info.getCell(); String newCellName = oldCell.getName(); // create the cell Cell newCell = makeNewCell(newCellName, View.LAYOUT, oldCell, newLib); if (newCell == null) return; createdCells.add(newCell); Map<Network,List<Conn>> connections = new HashMap<Network,List<Conn>>(); Map<Nodable,NodeInst> convertedNodes = new HashMap<Nodable,NodeInst>(); // create node placement tree and network connections list PlacerGrid placer = new PlacerGrid(); for (Iterator<Nodable> it = info.getNetlist().getNodables(); it.hasNext(); ) { Nodable no = it.next(); NodeProto np = null; if (no.isCellInstance()) { np = getLayoutCell(no, (Info)info); if (np == null) { System.out.println("Warning: Unable to find layout version of cell "+no.getProto().describe(false)); } } else { np = figureNewNodeProto(no.getNodeInst(), newTech); } if (np != null) { if (oldTech != Schematics.tech()) { // layout Conversion NodeInst newNi = placeLayoutNode(no, np, newCell, info.getContext()); convertedNodes.put(no, newNi); } else { if (np.getFunction() == PrimitiveNode.Function.PIN) continue; if (np.getFunction() == PrimitiveNode.Function.CONNECT) continue; if (no.getName().startsWith("fill") || no.getName().startsWith("tfill")) continue; placer.insert(new Leaf(no, info.getContext(), np, newCell)); // record connections on ports for (Iterator<PortProto> itp = no.getProto().getPorts(); itp.hasNext(); ) { PortProto pp = itp.next(); Name ppname = pp.getNameKey(); for (int i=0; i<ppname.busWidth(); i++) { Name subname = ppname.subname(i); Conn conn = new Conn(no, pp, subname); Network net = info.getNetlist().getNetwork(no, pp, i); List<Conn> list = connections.get(net); if (list == null) { list = new ArrayList<Conn>(); connections.put(net, list); } // if port on same node already connects to this network, skip it boolean add = true; for (Conn aconn : list) { if (aconn.no == conn.no) { add = false; break; } } if (add) list.add(conn); } } } } } if (oldTech == Schematics.tech()) { // place all new nodes placer.place(this, convertedNodes); // create rats nest of connections ArcProto ratArc = Generic.tech().unrouted_arc; for (Iterator<Network> it = info.getNetlist().getNetworks(); it.hasNext(); ) { Network network = it.next(); List<Conn> list = connections.get(network); if (list == null) continue; if (list.size() == 0) continue; Conn conn = list.get(0); PortInst pi = getLayoutPortInst(conn, convertedNodes); if (pi == null) { System.out.println("Cannot find port "+conn.portName+" on "+conn.no.getName()+" in cell "+newCell.describe(false)); continue; } String exportName = null; Export e = null; Iterator<Export> eIt = network.getExports(); if (eIt.hasNext()) { e = eIt.next(); exportName = network.getName(); } for (int i=1; i<list.size(); i++) { Conn nextConn = list.get(i); PortInst nextPi = getLayoutPortInst(nextConn, convertedNodes); if (nextPi == null) { System.out.println("Cannot find port "+nextConn.portName+" on "+nextConn.no.getName()+" in cell "+newCell.describe(false)); continue; } ArcInst newAi = ArcInst.makeInstanceBase(ratArc, ratArc.getDefaultLambdaBaseWidth(), pi, nextPi, pi.getCenter(), nextPi.getCenter(), null); if (newAi == null) { System.out.println("Cell " + newCell.describe(true) + ": can't run " + ratArc + " from " + pi.getNodeInst() + " " + pi + " at (" + pi.getCenter().getX() + "," + pi.getCenter().getY() + ") to " + nextPi.getNodeInst() + " " + nextPi + " at (" + nextPi.getCenter().getX() + "," + nextPi.getCenter().getY() + ")"); continue; } newAi.setFixedAngle(false); newAi.setRigid(false); // create export if name matches if (exportName != null && nextPi.getPortProto().getName().equals(exportName)) { Export pp2 = Export.newInstance(newCell, nextPi, exportName, e.getCharacteristic()); pp2.copyTextDescriptorFrom(e, Export.EXPORT_NAME); pp2.copyVarsFrom(e); exportName = null; } } if (exportName != null) { Export pp2 = Export.newInstance(newCell, pi, exportName, e.getCharacteristic()); pp2.copyTextDescriptorFrom(e, Export.EXPORT_NAME); pp2.copyVarsFrom(e); exportName = null; } } convertedCells.put(oldCell, newCell); } else { makeLayoutParts(oldCell, newCell, oldCell.getTechnology(), newTech, View.LAYOUT, convertedCells, convertedNodes); convertedCells.put(oldCell, newCell); } } private PortInst getLayoutPortInst(Conn schConn, Map<Nodable,NodeInst> convertedNodes) { NodeInst layNi = convertedNodes.get(schConn.no); if (layNi == null) return null; PortInst pi = layNi.findPortInst(schConn.portName.toString()); if (pi != null) return pi; // if each has only 1 port, they match int numNewPorts = layNi.getProto().getNumPorts(); if (numNewPorts == 0) return null; if (numNewPorts == 1) { return layNi.getPortInst(0); } if (schConn.no.getNodeInst().getFunction().isTransistor()) { if (schConn.portName.toString().equals("g")) return layNi.getTransistorGatePort(); if (schConn.portName.toString().equals("s")) return layNi.getTransistorSourcePort(); if (schConn.portName.toString().equals("d")) return layNi.getTransistorDrainPort(); } // associate by position in port list for (int i=0; i<schConn.no.getNodeInst().getNumPortInsts() && i<layNi.getNumPortInsts(); i++) { PortInst api = schConn.no.getNodeInst().getPortInst(i); if (api.getPortProto() == schConn.pp) { //System.out.println("Associated port "+i+": "+schConn.no.getProto().getName()+"."+schConn.pp.getName()+" to "+ // layNi.getProto().getName()+"."+layNi.getProto().getPort(i).getName()); return layNi.getPortInst(i); } } // special case again: one-port capacitors are OK PrimitiveNode.Function oldFun = schConn.no.getNodeInst().getFunction(); PrimitiveNode.Function newFun = layNi.getFunction(); if (oldFun == PrimitiveNode.Function.CAPAC && newFun == PrimitiveNode.Function.ECAPAC) return layNi.getPortInst(0); // association has failed: assume the first port System.out.println("No port association between " + schConn.no.getName() + ", " + schConn.pp.getName() + " and " + layNi.getProto()); return layNi.getPortInst(0); } /** * Method to create a new cell in "newcell" from the contents of an old cell * in "oldcell". The technology for the old cell is "oldtech" and the * technology to use for the new cell is "newTech". */ private void makeLayoutParts(Cell oldCell, Cell newCell, Technology oldTech, Technology newTech, View nView, Map<Cell,Cell> convertedCells, Map<Nodable,NodeInst> convertedNodes) {// // first convert the nodes// for(Iterator<NodeInst> it = oldCell.getNodes(); it.hasNext(); )// {// NodeInst ni = it.next();// // handle sub-cells// if (ni.isCellInstance())// {// Cell newCellType = (Cell)convertedCells.get((Cell)ni.getProto());// if (newCellType == null)// {// System.out.println("No equivalent cell for " + ni.getProto());// continue;// }// placeLayoutNode(ni, newCellType, newCell, VarContext.globalContext);// continue;// }//// // handle primitives// if (ni.getProto() == Generic.tech.cellCenterNode) continue;// NodeProt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -