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

📄 elib.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        if (additionalVarKey != null) count++;        writeInt("variables: ", count);        if (d instanceof ImmutableCell) {            // write the parameters            for(Iterator<Variable> it = ((ImmutableCell)d).getParameters(); it.hasNext(); ) {                Variable var = it.next();                writeVariable(null, var);            }        } else if (d instanceof ImmutableIconInst) {            for(Iterator<Variable> it = ((ImmutableIconInst)d).getDefinedParameters(); it.hasNext(); ) {                Variable var = it.next();                writeVariable(null, var);            }        }        // write the variables        for(Iterator<Variable> it = d.getVariables(); it.hasNext(); ) {            Variable var = it.next();            writeVariable(null, var);        }        // write variables on PortInsts        if (d instanceof ImmutableNodeInst) {            ImmutableNodeInst n = (ImmutableNodeInst)d;            if (n.hasPortInstVariables()) {                TreeMap<String, ImmutablePortInst> portVars = new TreeMap<String, ImmutablePortInst>(TextUtils.STRING_NUMBER_ORDER);                for (Iterator<PortProtoId> pit = n.getPortsWithVariables(); pit.hasNext(); ) {                    PortProtoId portId = pit.next();                    portVars.put(portId.getName(snapshot), n.getPortInst(portId));                }                for (Map.Entry<String, ImmutablePortInst> e: portVars.entrySet()) {                    String portName = e.getKey();                    ImmutablePortInst p = e.getValue();                    for (Iterator<Variable> it = p.getVariables(); it.hasNext(); ) {                        Variable var = it.next();                        writeVariable(portName, var);                    }                }            }        }        // write the additional variable        if (additionalVarKey != null) {            writeVariableName(additionalVarKey.getName());            writeTextDescriptor(additionalVarType, additionalTextDescriptor);            writeVarValue(additionalVarValue);        }    }    /**     * Method to write an object variables.     * @param portName if this variable is on PortInst, then its name otherwise null.     * @param var variable     */    void writeVariable(String portName, Variable var) throws IOException {        // create the "type" field        Object varObj = var.getObject();        // special case for "trace" information on NodeInsts        if (varObj instanceof EPoint[]) {            EPoint [] points = (EPoint [])varObj;            int len = points.length * 2;            Float [] newPoints = new Float[len];            for(int j=0; j<points.length; j++) {                if (points[j] != null) {                    newPoints[j*2] = new Float(points[j].getLambdaX());                    newPoints[j*2+1] = new Float(points[j].getLambdaY());                } else {                    newPoints[j*2] = newPoints[j*2+1] = Float.valueOf(Float.NaN);                }            }            varObj = newPoints;        } else if (varObj instanceof EPoint) {            EPoint p = (EPoint)varObj;            varObj = new Float[] { new Float(p.getLambdaX()), new Float(p.getLambdaY()) };        }        int type = ELIBConstants.getVarType(varObj);        if (compatibleWith6 && type == ELIBConstants.VDOUBLE) type = ELIBConstants.VFLOAT;        assert type != 0;        if (var.isDisplay())            type |= ELIBConstants.VDISPLAY;        if (varObj instanceof Object[]) {            Object [] objList = (Object [])varObj;            // This doesn't seem to work properly for trace//			if (objList.length > 0)            type |= ELIBConstants.VISARRAY | (objList.length << ELIBConstants.VLENGTHSH);        }        // Only string variables may have language code bits.        assert (type&ELIBConstants.VTYPE) == ELIBConstants.VSTRING || (type&(ELIBConstants.VCODE1|ELIBConstants.VCODE2)) == 0;        // write the text descriptor        writeVariableName(diskName(portName, var));        writeTextDescriptor(type, var.getTextDescriptor());        writeVarValue(varObj);    }    /**     * Method to write a set of project settings.     */    void writeMeaningPrefs(Object obj) throws IOException {        Collection<Setting> settings = null;        if (obj instanceof Tool)            settings = ((Tool)obj).getDiskSettings();        else if (obj instanceof Technology)            settings = ((Technology)obj).getDiskSettings();        writeInt("variables: ", settings.size());        for (Setting setting : settings) {            // create the "type" field            Object varObj = setting.getValue();            projectSettings.put(setting, varObj);            if (varObj instanceof Boolean) varObj = Integer.valueOf(((Boolean)varObj).booleanValue() ? 1 : 0);            int type = ELIBConstants.getVarType(varObj);            if (compatibleWith6 && type == ELIBConstants.VDOUBLE) type = ELIBConstants.VFLOAT;            writeVariableName(setting.getPrefName());            writeTextDescriptor(type, null);            writeVarValue(varObj);            projectSettings.put(setting, varObj);        }    }    /**     * Method to write the value of variable.     * @param obj value of variable.     */    void writeVarValue(Object varObj) throws IOException {        if (varObj instanceof Object[]) {            Object [] objList = (Object [])varObj;            int len = objList.length;            writeBigInteger(len);            for(int i=0; i<len; i++) {                Object oneObj = objList[i];                putOutVar(oneObj);            }        } else {            putOutVar(varObj);        }    }    /**     * Helper method to write a variable at address "addr" of type "ty".     * Returns zero if OK, negative on memory error, positive if there were     * correctable problems in the write.     */    private void putOutVar(Object obj) throws IOException {        if (obj instanceof String) {            writeString((String)obj);            return;        }        if (obj instanceof CodeExpression) {            writeString(((CodeExpression)obj).getExpr());            return;        }        if (obj instanceof Double) {            if (compatibleWith6)                writeFloat(((Double)obj).floatValue());            else                writeDouble(((Double)obj).doubleValue());            return;        }        if (obj instanceof Float) {            writeFloat(((Float)obj).floatValue());            return;        }        if (obj instanceof Long) {            writeBigInteger(((Long)obj).intValue());            return;        }        if (obj instanceof Integer) {            writeBigInteger(((Integer)obj).intValue());            return;        }        if (obj instanceof Short) {            writeSmallInteger(((Short)obj).shortValue());            return;        }        if (obj instanceof Byte) {            writeByte(((Byte)obj).byteValue());            return;        }        if (obj instanceof Boolean) {            writeByte(((Boolean)obj).booleanValue() ? (byte)1 : (byte)0);            return;        }        if (obj instanceof Tool) {            Tool tool = (Tool)obj;            writeBigInteger(tool.getIndex());            return;        }        if (obj instanceof LibId) {            LibId libId = (LibId)obj;            writeString(libId.libName);            return;        }        writeObj(obj);    }    /**     * Method to write a text descriptor (possibly with variable bits).     * Face of text descriptor is mapped according to "faceMap".     * @param varBits variableBits or -1.     * @param td TextDescriptor to write.     */    private void writeTextDescriptor(int varBits, TextDescriptor td) throws IOException {        int td0;        int td1;        if (td != null) {            td0 = td.lowLevelGet0();            td1 = td.lowLevelGet1();            // Convert font face            if ((td1 & ELIBConstants.VTFACE) != 0) {                int face = (td1 & ELIBConstants.VTFACE) >> ELIBConstants.VTFACESH;                td1 = (td1 & ~ELIBConstants.VTFACE) | (faceMap[face] << ELIBConstants.VTFACESH);            }        } else {            td0 = 0;            td1 = 0;        }        writeTextDescriptor(varBits, td0, td1);    }    /**     * Method to write a text descriptor (possibly with variable bits).     * Face of text descriptor is mapped according to "faceMap".     * @param varBits variableBits or -1.     * @param td0 first word of TextDescriptor to write.     * @param td1 first word of TextDescriptor to write.     */    void writeTextDescriptor(int varBits, int td0, int td1) throws IOException {        if (varBits != -1)            writeBigInteger(varBits);        writeBigInteger(td0);        writeBigInteger(td1);    }    /**     * Method to write a disk index of Object.     * Index is obtained fron objInfo map.     * @param obj Object to write     */    void writeObj(Object obj) throws IOException {        int objIndex = -1;        if (obj != null) {            Integer i = objInfo.get(obj);            if (i != null)                objIndex = i.intValue();        }        writeBigInteger(objIndex);    }    /**     * Method to write a coordinate as (4 bytes) integer to the ouput stream.     * @param cellBackup cell to determine scale     * @param keyword keywork fro ReadableDump     * @param gridCoord coordinate in grid units.     */    private void writeGridCoord(CellBackup cellBackup, String keyword, double gridCoord) throws IOException {        writeGridCoord(cellBackup.cellRevision, keyword, gridCoord);    }    /**     * Method to write a coordinate as (4 bytes) integer to the ouput stream.     * @param cellRevision cell to determine scale     * @param keyword keywork fro ReadableDump     * @param gridCoord coordinate in grid units.     */    private void writeGridCoord(CellRevision cellRevision, String keyword, double gridCoord) throws IOException {//        int i = gridCoordToElib(cellBackup.d.tech, gridCoord);        Technology tech = snapshot.getTech(cellRevision.d.techId);        writeInt(keyword, gridCoordToElib(tech, gridCoord));    }    int gridCoordToElib(Technology tech, double gridCoord) {        return (int)Math.round(gridCoord * getScale(tech)*2/DBMath.GRID);    }    double getScale(TechId techId) {        return getScale(snapshot.getTech(techId));    }    double getScale(Technology tech) {        return tech.isScaleRelevant() || tech == Generic.tech() ? tech.getScale() : irrelevantScale;    }    private Technology.SizeCorrector getSizeCorrector(TechId techId) {        Technology.SizeCorrector corrector = sizeCorrectors.get(techId);        if (corrector == null) {            corrector = techPool.getTech(techId).getSizeCorrector(Version.getVersion(), projectSettings, false, false);            sizeCorrectors.put(techId, corrector);        }        return corrector;    }    /**     * Method to write an integer (4 bytes) to the ouput stream.     * @param keyword keywork fro ReadableDump     * @parma i integer value.     */    void writeInt(String keyword, int i) throws IOException {        writeBigInteger(i);    }    /**     * Method to write a text into ReadableDump stream.     * @param txt a text to write into ReadableDump stream.     */    void writeTxt(String txt) throws IOException {}    /**     * Method to write a disk index of variable name.     * Index is obtained from the nameSpace map.     * @param name Variable Key to write     */    void writeVariableName(String name) throws IOException {        short varNameIndex = nameSpace.get(name).shortValue();        writeSmallInteger(varNameIndex);    }	// --------------------------------- LOW-LEVEL OUTPUT ---------------------------------	/**	 * Method to write a single byte from the input stream and return it.	 */	private void writeByte(byte b)		throws IOException	{		dataOutputStream.write(b);	}	/**	 * Method to write an integer (4 bytes) from the input stream and return it.	 */	void writeBigInteger(int i)		throws IOException	{		dataOutputStream.writeInt(i);	}	/**	 * Method to write a float (4 bytes) from the input stream and return it.	 */	private void writeFloat(float f)		throws IOException	{		dataOutputStream.writeFloat(f);	}	/**	 * Method to write a double (8 bytes) from the input stream and return it.	 */	private void writeDouble(double d)		throws IOException	{		dataOutputStream.writeDouble(d);	}	/**	 * Method to write an short (2 bytes) from the input stream and return it.	 */	private void writeSmallInteger(short s)		throws IOException	{		dataOutputStream.writeShort(s);	}	/**	 * Method to write a string from the input stream and return it.	 */	private void writeString(String s)		throws IOException	{		// disk and memory match: write the data		int len = s.length();		writeBigInteger(len);		dataOutputStream.write(s.getBytes(), 0, len);	}}

⌨️ 快捷键说明

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