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

📄 snapshot.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        CellBackup cellBackup = getCell(cellIndex);        return cellBackup != null ? cellBackup.cellRevision : null;    }//    /**//     * Returns group name of cell with specified CellId.//     * Name of cell group is a base name of main schematics cell if any.//     * Otherwise it is a shortest base name among cells in the group.//     * If cell with the cellId is absent in this Snapshot, returns null.//     * @param cellId cellId of a cell.//     * @return name of cell group or null.//     *//     *///    public String getCellGroupName(CellId cellId) {//        int groupIndex = cellId.cellIndex < cellGroups.length ? cellGroups[cellId.cellIndex] : -1;//        if (groupIndex < 0) return null;//        ArrayList<CellName> cellNames = new ArrayList<CellName>();//        for (CellBackup cellBackup: cellBackups) {//            if (cellBackup == null) continue;//            if (cellGroups[cellBackup.d.cellId.cellIndex] != groupIndex) continue;//            cellNames.add(cellBackup.d.cellId.cellName);//        }//        if (cellNames.isEmpty()) return null;//        return makeCellGroupName(cellNames).getName();//    }    /**     * Returns group name of group with specified CellNames.     * Name of cell group is a base name of main schematics cell if any.     * Otherwise it is a shortest base name among cells in the group.     * @param cellNames collection of CellNames in a group.     * @return name of cell group.     * @throws InvalidArgumentException if cellNames is empty     */    public static CellName makeCellGroupName(Collection<CellName> cellNames) {        if (cellNames.isEmpty())            throw new IllegalArgumentException();        String groupName = null;        for (CellName cellName: cellNames) {            if (!cellName.isSchematic()) continue;            String name = cellName.getName();            if (groupName == null || TextUtils.STRING_NUMBER_ORDER.compare(name, groupName) < 0)                groupName = name;        }        if (groupName == null) {            for (CellName cellName: cellNames) {                String name = cellName.getName();                if (groupName == null || name.length() < groupName.length() ||                        name.length() == groupName.length() && TextUtils.STRING_NUMBER_ORDER.compare(name, groupName) < 0)                    groupName = name;            }        }        assert groupName != null;        return CellName.parseName(groupName + "{sch}");    }    public ERectangle getCellBounds(CellId cellId) { return getCellBounds(cellId.cellIndex); }    public ERectangle getCellBounds(int cellIndex) {        return cellIndex < cellBounds.length ? cellBounds[cellIndex] : null;    }    /** Returns TechPool of this Snapshot */    public TechPool getTechPool() { return techPool; }   /**     * Get Technology by TechId     * TechId must belong to same IdManager as TechPool     * @param techId TechId to find     * @return Technology b giben TechId or null     * @throws IllegalArgumentException of TechId is not from this IdManager     */    public Technology getTech(TechId techId) { return techPool.getTech(techId); }    /** Returns Artwork technology in this database */    public Artwork getArtwork() {        return techPool.getArtwork();    }    /** Returns Generic technology in this database */    public Generic getGeneric() {        return techPool.getGeneric();    }    /** Returns Schematic technology in this database */    public Schematics getSchematics() {        return techPool.getSchematics();    }//    private Technology getTech(int techIndex) {//        return techIndex < technologies.size() ? technologies.get(techIndex) : null;//    }    public LibraryBackup getLib(LibId libId) { return getLib(libId.libIndex); }    private LibraryBackup getLib(int libIndex) {        return libIndex < libBackups.size() ? libBackups.get(libIndex) : null;    }//    private boolean equals(Snapshot that) {//        return this.cellBackups.equals(that.cellBackups) &&//                this.libBackups.equals(that.libBackups) &&//                Arrays.equals(this.cellGroups, that.cellGroups) &&//                this.cellBounds.equals(that.cellBounds);//    }    public void writeDiffs(IdWriter writer, Snapshot oldSnapshot) throws IOException {        assert oldSnapshot.cellBoundsDefined();        assert cellBoundsDefined();        writer.writeDiffs();        writer.writeInt(snapshotId);        writer.writeBoolean(tool != null);        if (tool != null)            writer.writeTool(tool);        boolean technologiesChanged = techPool != oldSnapshot.techPool;        writer.writeBoolean(technologiesChanged);        if (technologiesChanged)            techPool.write(writer);        boolean libsChanged = oldSnapshot.libBackups != libBackups;        writer.writeBoolean(libsChanged);        if (libsChanged) {            writer.writeInt(libBackups.size());            for (int i = 0; i < libBackups.size(); i++) {                LibraryBackup oldBackup = oldSnapshot.getLib(i);                LibraryBackup newBackup = getLib(i);                if (oldBackup == newBackup) continue;                if (oldBackup == null) {                    writer.writeInt(i);                    newBackup.write(writer);                } else if (newBackup == null) {                    writer.writeInt(~i);                } else {                    writer.writeInt(i);                    newBackup.write(writer);                }            }            writer.writeInt(Integer.MAX_VALUE);        }        writer.writeInt(cellBackups.size());        boolean boundsChanged = oldSnapshot.cellBounds.length != cellBounds.length;        for (int cellIndex = 0; cellIndex < cellBounds.length; cellIndex++) {            if (cellBackups.get(cellIndex) == null) continue;            boundsChanged = boundsChanged || cellBounds[cellIndex] != oldSnapshot.cellBounds[cellIndex];        }        writer.writeBoolean(boundsChanged);        for (int i = 0; i < cellBackups.size(); i++) {            CellBackup oldBackup = oldSnapshot.getCell(i);            CellBackup newBackup = getCell(i);            if (oldBackup == newBackup) continue;            if (oldBackup == null) {                writer.writeInt(i);                newBackup.write(writer);            } else if (newBackup == null) {                writer.writeInt(~i);            } else {                writer.writeInt(i);                newBackup.write(writer);            }        }        writer.writeInt(Integer.MAX_VALUE);        if (boundsChanged) {            for (int i = 0; i < cellBackups.size(); i++) {                CellBackup newBackup = getCell(i);                if (newBackup == null) continue;                ERectangle oldBounds = oldSnapshot.getCellBounds(i);                ERectangle newBounds = getCellBounds(i);                assert newBounds != null;                if (oldBounds != newBounds) {                    writer.writeInt(i);                    writer.writeRectangle(newBounds);                }            }            writer.writeInt(Integer.MAX_VALUE);        }        boolean cellGroupsChanged = cellGroups != oldSnapshot.cellGroups;        writer.writeBoolean(cellGroupsChanged);        if (cellGroupsChanged) {            assert cellGroups.length == cellBackups.size();            for (int cellIndex = 0; cellIndex < cellGroups.length; cellIndex++)                writer.writeInt(cellGroups[cellIndex]);            for (int groupIndex = 0; groupIndex < groupMainSchematics.length; groupIndex++) {                CellId mainSchematics = groupMainSchematics[groupIndex];                writer.writeInt(mainSchematics != null ? mainSchematics.cellIndex : -1);            }        }    }    public static Snapshot readSnapshot(IdReader reader, Snapshot oldSnapshot) throws IOException {        assert reader.idManager == oldSnapshot.idManager;        assert oldSnapshot.cellBoundsDefined();        reader.readDiffs();        int snapshotId = reader.readInt();        boolean hasTool = reader.readBoolean();        Tool tool = hasTool ? reader.readTool() : null;        TechPool techPool = oldSnapshot.techPool;        boolean technologiesChanged = reader.readBoolean();        if (technologiesChanged)            techPool = TechPool.read(reader);        ImmutableArrayList<LibraryBackup> libBackups = oldSnapshot.libBackups;        boolean libsChanged = reader.readBoolean();        if (libsChanged) {            int libLen = reader.readInt();            LibraryBackup[] libBackupsArray = new LibraryBackup[libLen];            for (int libIndex = 0, numLibs = Math.min(oldSnapshot.libBackups.size(), libLen); libIndex < numLibs; libIndex++)                libBackupsArray[libIndex] = oldSnapshot.libBackups.get(libIndex);            for (;;) {                int libIndex = reader.readInt();                if (libIndex == Integer.MAX_VALUE) break;                if (libIndex >= 0) {                    LibraryBackup newBackup = LibraryBackup.read(reader);                    libBackupsArray[libIndex] = newBackup;                } else {                    libIndex = ~libIndex;                    assert libBackupsArray[libIndex] != null;                    libBackupsArray[libIndex] = null;                }            }            libBackups = new ImmutableArrayList<LibraryBackup>(libBackupsArray);        }        int cellLen = reader.readInt();        int cellMax = Math.min(oldSnapshot.cellBackups.size(), cellLen);        CellBackup[] cellBackupsArray = new CellBackup[cellLen];        for (int cellIndex = 0; cellIndex < cellMax; cellIndex++)            cellBackupsArray[cellIndex] = oldSnapshot.cellBackups.get(cellIndex);        boolean boundsChanged = reader.readBoolean();        ERectangle[] cellBoundsArray = oldSnapshot.cellBounds;        if (boundsChanged) {            cellBoundsArray = new ERectangle[cellLen];            for (int cellIndex = 0, numCells = Math.min(oldSnapshot.cellBounds.length, cellLen); cellIndex < numCells; cellIndex++)                cellBoundsArray[cellIndex] = oldSnapshot.cellBounds[cellIndex];        }        if (technologiesChanged) {            for (int cellIndex = 0; cellIndex < cellLen; cellIndex++) {                CellBackup cellBackup = cellBackupsArray[cellIndex];                if (cellBackup == null) continue;                cellBackupsArray[cellIndex] = cellBackup.withTechPool(techPool);            }        }        for (;;) {            int cellIndex = reader.readInt();            if (cellIndex == Integer.MAX_VALUE) break;            if (cellIndex >= 0) {

⌨️ 快捷键说明

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