📄 spice.java
字号:
value = evalParam(context, info.getParentInst(), paramVar, forceEval); } else if (!isNetlistableParam(paramVar)) continue; infstr.append(" " + paramVar.getTrueName() + "=" + value); } } infstr.append("\n"); multiLinePrint(false, infstr.toString()); // write global comments if (Simulation.getSpiceGlobalTreatment() == Simulation.SpiceGlobal.USEGLOBALBLOCK) { for(int i=0; i<globalSize; i++) { Global global = globals.get(i); Network net = netList.getNetwork(global); CellSignal cs = cni.getCellSignal(net); multiLinePrint(true, "** GLOBAL " + cs.getName() + "\n"); } } } // write out any directly-typed SPICE declaratons for the cell if (!useCDL) { boolean firstDecl = true; for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (ni.getProto() != Generic.tech().invisiblePinNode) continue; Variable cardVar = ni.getVar(SPICE_DECLARATION_KEY); if (cardVar == null) continue; if (firstDecl) { firstDecl = false; multiLinePrint(true, "\n* Spice Declaration nodes in cell " + cell + "\n"); } emitEmbeddedSpice(cardVar, context, segmentedNets, info, false, forceEval); } } // third pass through the node list, print it this time for(Iterator<Nodable> nIt = netList.getNodables(); nIt.hasNext(); ) { Nodable no = nIt.next(); NodeProto niProto = no.getProto();// boolean includePwrVdd = Simulation.isSpiceWritePwrGndInTopCell(); // handle sub-cell calls if (no.isCellInstance()) { Cell subCell = (Cell)niProto; // get the SPICE template on the prototype (if any) Variable varTemplate = getEngineTemplate(subCell); if (varTemplate != null) { if (varTemplate.getObject() instanceof Object[]) { Object [] manyLines = (Object [])varTemplate.getObject(); for(int i=0; i<manyLines.length; i++) { String line = manyLines[i].toString(); StringBuffer infstr = replacePortsAndVars(line, no, context, cni, segmentedNets, info, false, forceEval); // Writing MFactor if available. Not sure here if (i == 0) writeMFactor(context, no, infstr); infstr.append('\n'); multiLinePrint(false, infstr.toString()); } } else { String line = varTemplate.getObject().toString(); StringBuffer infstr = replacePortsAndVars(line, no, context, cni, segmentedNets, info, false, forceEval); // Writing MFactor if available. Not sure here writeMFactor(context, no, infstr); infstr.append('\n'); multiLinePrint(false, infstr.toString()); } continue; } // get the ports on this node (in proper order) CellNetInfo subCni = getCellNetInfo(parameterizedName(no, context)); if (subCni == null) continue; if (!writeEmptySubckts) { // do not instantiate if empty if (cellIsEmpty((Cell)niProto)) continue; } String modelChar = "X"; if (no.getName() != null) modelChar += getSafeNetName(no.getName(), false); StringBuffer infstr = new StringBuffer(); infstr.append(modelChar); for(Iterator<CellSignal> sIt = subCni.getCellSignals(); sIt.hasNext(); ) { CellSignal subCS = sIt.next(); if (ignoreSubcktPort(subCS)) continue; PortProto pp = subCS.getExport(); if (!subCS.isGlobal() && pp == null) continue; // If global pwr/vdd will be included in the subcircuit // Preparing code for bug #1828// if (!Simulation.isSpiceWritePwrGndInTopCell() && pp!= null && subCS.isGlobal() && (subCS.isGround() || subCS.isPower()))// continue; Network net; int exportIndex = subCS.getExportIndex(); // This checks if we are netlisting a schematic top level with swapped-in layout subcells if (pp != null && cell.isSchematic() && (subCni.getCell().getView() == View.LAYOUT)) { // find equivalent pp from layout to schematic Network subNet = subCS.getNetwork(); // layout network name boolean found = false; for (Iterator<Export> eIt = subCell.getExports(); eIt.hasNext(); ) { Export ex = eIt.next(); for (int i=0; i<ex.getNameKey().busWidth(); i++) { String exName = ex.getNameKey().subname(i).toString(); if (exName.equals(subNet.getName())) { pp = ex; exportIndex = i; found = true; break; } } if (found) break; } if (!found) { if (pp.isGround() && pp.getName().startsWith("gnd")) { infstr.append(" gnd"); } else if (pp.isPower() && pp.getName().startsWith("vdd")) { infstr.append(" vdd"); } else { System.out.println("No matching export on schematic/icon found for export "+ subNet.getName()+" in cell "+subCni.getCell().describe(false)); infstr.append(" unknown"); } continue; } } if (subCS.isGlobal()) { net = netList.getNetwork(no, subCS.getGlobal()); } else net = netList.getNetwork(no, pp, exportIndex); if (net == null) { System.out.println("Warning: cannot find network for signal " + subCS.getName() + " in cell " + subCni.getCell().describe(false)); continue; } CellSignal cs = cni.getCellSignal(net); // special case for parasitic extraction SpiceSegmentedNets subSN = null; if (parasiticInfo != null && !cs.isGlobal()) subSN = parasiticInfo.getSegmentedNets((Cell)no.getProto()); if (subSN != null) { parasiticInfo.getParasiticName(no, subCS.getNetwork(), subSN, infstr); } else { String name = cs.getName(); if (parasiticInfo != null) { name = segmentedNets.getNetName(no.getNodeInst().findPortInstFromProto(pp)); } infstr.append(" " + name); } } if (useCDL) infstr.append(" /"); else infstr.append(" "); infstr.append(subCni.getParameterizedName()); if (!useCDL && Simulation.isSpiceUseCellParameters()) { // add in parameters to this instance Set<Variable.Key> spiceParams = detectSpiceParams(subCell); for(Iterator<Variable> it = subCell.getParameters(); it.hasNext(); ) { Variable paramVar = it.next(); if (DETECT_SPICE_PARAMS && !spiceParams.contains(paramVar.getKey())) continue; if (!USE_JAVA_CODE && !isNetlistableParam(paramVar)) continue; Variable instVar = no.getParameter(paramVar.getKey()); String paramStr = "??"; if (instVar != null) { if (USE_JAVA_CODE) { paramStr = evalParam(context, no, instVar, forceEval); } else { Object obj = null; if (isNetlistableParam(instVar)) { obj = context.evalSpice(instVar, false); } else { obj = context.evalVar(instVar, no); } if (obj != null) paramStr = formatParam(String.valueOf(obj), instVar.getUnit(), false); } } infstr.append(" " + paramVar.getTrueName() + "=" + paramStr); } } // Writing MFactor if available. writeMFactor(context, no, infstr); infstr.append("\n"); multiLinePrint(false, infstr.toString()); continue; } // get the type of this node NodeInst ni = (NodeInst)no; // look for a SPICE template on the primitive String line = ((PrimitiveNode)ni.getProto()).getSpiceTemplate(); if (line != null) { StringBuffer infstr = replacePortsAndVars(line, no, context, cni, segmentedNets, info, false, forceEval); // Writing MFactor if available. Not sure here writeMFactor(context, no, infstr); infstr.append('\n'); multiLinePrint(false, infstr.toString()); continue; } // handle resistors, inductors, capacitors, and diodes PrimitiveNode.Function fun = ni.getFunction(); if (fun.isResistor() || fun.isCapacitor() || fun == PrimitiveNode.Function.INDUCT || fun == PrimitiveNode.Function.DIODE || fun == PrimitiveNode.Function.DIODEZ) { if (fun.isResistor()) { if ((fun.isPolyOrWellResistor() && isShortExplicitResistors()) || (fun == PrimitiveNode.Function.RESIST && isShortResistors())) continue; Variable resistVar = ni.getVar(Schematics.SCHEM_RESISTANCE); String extra = ""; String partName = "R"; if (resistVar != null) { if (USE_JAVA_CODE) { extra = evalParam(context, ni, resistVar, forceEval); } else { if (resistVar.getCode() == CodeExpression.Code.SPICE) { if (!useCDL && Simulation.isSpiceUseCellParameters()) { Object obj = context.evalSpice(resistVar, false); extra = String.valueOf(obj); } else { extra = resistVar.describe(context, ni); } } if (extra == "") extra = resistVar.describe(context, ni); if (TextUtils.isANumber(extra)) { double pureValue = TextUtils.atof(extra); extra = TextUtils.formatDoublePostFix(pureValue); //displayedUnits(pureValue, TextDescriptor.Unit.RESISTANCE, TextUtils.UnitScale.NONE); } else extra = formatParam(extra, resistVar.getUnit(), false); } } else { // remove next 10 lines when PRESIST and WRESIST are finally deprecated// if (fun == PrimitiveNode.Function.PRESIST)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -