📄 lenodable.java
字号:
* @param mfactor the parent's mfactor * @param su the parent's step-up */ private boolean instantiate(LENodable instance, VarContext context, LENetwork outputNetwork, float mfactor, float su, LENetlister2.NetlisterConstants constants, boolean testCachebility) { instance.outputNetwork = outputNetwork; boolean evalOk = true; // default values instance.context = context; instance.leX = getLeX(context, constants, testCachebility); if (instance.leX == -1f) evalOk = false; instance.mfactor = mfactor; instance.su = su; instance.parallelGroup = 0; // evaluate variables in context, if any if (parallelGroupVar != null) { Object retVal = context.evalVar(parallelGroupVar); if (retVal == null) evalOk = false; else instance.parallelGroup = VarContext.objectToInt(retVal, instance.parallelGroup); } if (suVar != null) { Object retVal = context.evalVar(suVar); if (retVal == null) evalOk = false; else { float localsu = VarContext.objectToFloat(retVal, -1f); instance.su = (localsu == -1f) ? instance.su : localsu; } } if (mfactorVar != null) { Object retVal = context.evalVar(mfactorVar); if (retVal == null) evalOk = false; else instance.mfactor *= VarContext.objectToFloat(retVal, 1f); } return evalOk; } /** * Get the leX size for the given LENodable * Returns -1 if any evaluations failed. * @param context the VarContext * @return the leX size, or -1 if eval failed */ private float getLeX(VarContext context, LENetlister2.NetlisterConstants constants, boolean testCachebility) { float leX = (float)0.0; Variable var = null; Object retVal = null; if (type == LENodable.Type.WIRE) { // Note that if inst is an LEWIRE, it will have no 'le' attributes. // we therefore assign pins to have default 'le' values of one. // This creates an instance which has Type LEWIRE, but has // boolean leGate set to false; it will not be sized // NEW: If we find ATTR_LEWIRECAP, that is the capacitance to use, // and we will not calculate the cap from L and W. var = no.getParameterOrVariable(LENetlister.ATTR_LEWIRECAP); float cap = 0; if (var != null) { retVal = context.evalVar(var); if (testCachebility && (retVal == null)) return -1f; cap = VarContext.objectToFloat(retVal, 0.0f); } else { var = no.getParameterOrVariable(LENetlister.ATTR_L); if (var == null) { System.out.println("Error, no L attribute found on LEWIRE "+no.getName()+" in Cell "+no.getParent()); if (testCachebility) return -1f; } retVal = context.evalVar(var); if (testCachebility && (retVal == null)) return -1f; float len = VarContext.objectToFloat(retVal, 0.0f); var = no.getParameterOrVariable(Schematics.ATTR_WIDTH); if (var == null) { System.out.println("Warning, no width attribute found on LEWIRE "+no.getName()+" in Cell "+no.getParent()); if (testCachebility) return -1f; } retVal = context.evalVar(var); if (testCachebility && (retVal == null)) return -1f; float width = VarContext.objectToFloat(retVal, 3.0f); cap = (0.95f*len + 0.05f*len*(width/3.0f)); } leX = cap*constants.wireRatio; // equivalent lambda of gate leX = leX/9.0f; // drive strength X=1 is 9 lambda of gate } else if (type == LENodable.Type.TRANSISTOR) { var = no.getParameterOrVariable(Schematics.ATTR_WIDTH); if (var == null) { System.out.println("Error: transistor "+no.getName()+" has no width in Cell "+no.getParent()); //ErrorLogger.ErrorLog log = errorLogger.logError("Error: transistor "+no+" has no width in Cell "+info.getCell(), info.getCell(), 0); //log.addGeom(ni.getNodeInst(), true, no.getParent(), context); return -1f; } retVal = context.evalVar(var); if (retVal == null) return -1f; //float width = VarContext.objectToFloat(retVal, (float)3.0); float width = VarContext.objectToFloat(retVal, -1f); if (width == -1f) return -1f;// var = no.getVar(Schematics.ATTR_LENGTH);// if (var == null) {// System.out.println("Error: transistor "+no.getName()+" has no length in Cell "+no.getParent());// //ErrorLogger.ErrorLog log = errorLogger.logError("Error: transistor "+ni+" has no length in Cell "+info.getCell(), info.getCell(), 0);// //log.addGeom(ni.getNodeInst(), true, info.getCell(), info.getContext());// return -1f;// }// retVal = context.evalVar(var);// if (retVal == null) return -1f;// float length = VarContext.objectToFloat(retVal, (float)2.0); // not exactly correct because assumes all cap is area cap, which it isn't leX = (float)(width/9.0f); } else if (type == Type.CAPACITOR) { var = no.getVar(Schematics.SCHEM_CAPACITANCE); if (var == null) { System.out.println("Error: capacitor "+no.getName()+" has no capacitance in Cell "+no.getParent()); //ErrorLogger.ErrorLog log = errorLogger.logError("Error: capacitor "+no+" has no capacitance in Cell "+info.getCell(), info.getCell(), 0); //log.addGeom(ni.getNodeInst(), true, no.getParent(), context); return -1f; } retVal = context.evalVar(var); if (testCachebility && (retVal == null)) return -1f; float cap = VarContext.objectToFloat(retVal, (float)0.0); leX = (float)(cap/constants.gateCap/1e-15/9.0f); } return leX; } // ----------------------------------------------------------------- protected String getName() { if (context == null) return no.getName(); return context.push(getNodable()).getInstPath("."); } protected void print() { System.out.println(getType().toString()+": "+getName()); System.out.println(" Size \t= "+leX); System.out.println(" Step-up \t= "+su); System.out.println(" Parallel Group\t= "+parallelGroup); System.out.println(" M Factor\t= "+mfactor); } protected String printOneLine(String indent) { StringBuffer buf = new StringBuffer(indent); buf.append(getType().toString()); buf.append(": Size="+TextUtils.formatDouble(leX, 2)); //buf.append(" M="+TextUtils.formatDouble(mfactor, 2)); buf.append(" M="+mfactor); buf.append(" tPG="+parallelGroup); buf.append(" "+getName()); return buf.toString(); } protected void printPins() { for (LEPin pin : pins) { System.out.println("Pin "+pin.getName()+", le="+pin.getLE()+", dir="+pin.getDir()+" on network "+pin.getNetwork()); } } protected float printLoadInfo(LEPin pin, float alpha) { StringBuffer buf = new StringBuffer(); buf.append(getType().toString()); buf.append("\tSize="+TextUtils.formatDouble(leX, 2)); buf.append("\tLE="+TextUtils.formatDouble(pin.getLE(), 2)); buf.append("\tM="+TextUtils.formatDouble(mfactor, 2)); float load; if (pin.getDir() == LEPin.Dir.OUTPUT) { load = (float)(leX*pin.getLE()*mfactor*alpha); buf.append("\tAlpha="+alpha); buf.append("\tLoad="+TextUtils.formatDouble(load, 2)); } else { load = (float)(leX*pin.getLE()*mfactor); buf.append("\tLoad="+TextUtils.formatDouble(load, 2)); } buf.append("\t"+getName()); System.out.println(buf.toString()); return load; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -