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

📄 sclibrarygen.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.sun.electric.tool.generator.sclibrary;import java.awt.Color;import java.util.*;import com.sun.electric.database.geometry.EGraphics;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.hierarchy.*;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.database.variable.VarContext;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.generator.layout.GateLayoutGenerator;import com.sun.electric.tool.generator.layout.StdCellParams;import com.sun.electric.tool.generator.layout.TechType;import com.sun.electric.tool.Job;import com.sun.electric.tool.io.output.Verilog;import com.sun.electric.tool.user.User;/** * Generate a standard cell library from purple and red libraries * User: gainsley * Date: Nov 15, 2006 */public class SCLibraryGen {    private String purpleLibraryName = "purpleFour";    private String redLibraryName = "redFour";    private String scLibraryName = "sclib";    private Library purpleLibrary;    private Library redLibrary;    private Library scLibrary;    private List<StdCellSpec> scellSpecs = new ArrayList<StdCellSpec>();    private PrimitiveNode pin = Generic.tech().invisiblePinNode;    private Variable.Key sizeKey = Variable.findKey("ATTR_X");    public static final Variable.Key STANDARDCELL = Variable.newKey("ATTR_StandardCell");    private static final int blueColorIndex = EGraphics.makeIndex(Color.blue);    public SCLibraryGen() {}    private static class StdCellSpec {        private String type;        private double [] sizes;        private StdCellSpec(String type, double [] sizes) {            this.type = type;            this.sizes = sizes;        }    }    /* =======================================================     * Settings     * ======================================================= */    /**     * Set the names of the purple and red libraries. These must     * be loaded when running the generation, and are used     * as templates for the schematics and icons of standard cells.     * @param purpleLibraryName     * @param redLibraryName     */    public void setPurpleRedLibs(String purpleLibraryName, String redLibraryName) {        this.purpleLibraryName = purpleLibraryName;        this.redLibraryName = redLibraryName;    }    /**     * Set the name of the output standard cell library.     * Defaults to "sclib".     * @param name     */    public void setOutputLibName(String name) {        this.scLibraryName = name;    }    /**     * Add command to generate the standard cell type     * for the given space-separated list of sizes.     * @param type     * @param sizes     */    public void addStandardCell(String type, String sizes) {        sizes = sizes.trim();        if (sizes.equals("")) return;        String [] ss = sizes.split("\\s+");        double [] sss = new double [ss.length];        for (int i=0; i<ss.length; i++) {            sss[i] = Double.parseDouble(ss[i]);        }        scellSpecs.add(new StdCellSpec(type, sss));    }    /**     * Generates the standard cell library     * @param sc standard cell parameters     * @return false on error, true otherwise     */    public boolean generate(StdCellParams sc) {        // check for red and purple libraries        purpleLibrary = Library.findLibrary(purpleLibraryName);        if (purpleLibrary == null) {            prErr("Purple library \""+purpleLibraryName+"\" is not loaded.");            return false;        }        redLibrary = Library.findLibrary(redLibraryName);        if (redLibrary == null) {            prErr("Red library \""+redLibraryName+"\" is not loaded.");            return false;        }        prMsg("Using purple library \""+purpleLibraryName+"\" and red library \""+redLibraryName+"\"");        if (sc.getTechType() == TechType.TechTypeEnum.TSMC180.getTechType())            scLibraryName = "sclibTSMC180";        else if (sc.getTechType() == TechType.TechTypeEnum.CMOS90.getTechType())            scLibraryName = "sclibCMOS90";        scLibrary = Library.findLibrary(scLibraryName);        if (scLibrary == null) {            scLibrary = Library.newInstance(scLibraryName, null);            prMsg("Created standard cell library "+scLibraryName);        }        prMsg("Using standard cell library "+scLibraryName);        // dunno how to set standard cell params        sc.enableNCC(purpleLibraryName);        for (StdCellSpec stdcell : scellSpecs) {            for (double d : stdcell.sizes) {                String cellname = sc.sizedName(stdcell.type, d);                cellname = cellname.substring(0, cellname.indexOf('{'));                // generate layout first                Cell laycell = scLibrary.findNodeProto(cellname+"{lay}");                if (laycell == null) {                    laycell = GateLayoutGenerator.generateCell(scLibrary, sc, stdcell.type, d);                    if (laycell == null) {                        prErr("Error creating layout cell "+stdcell.type+" of size "+d);                        continue;                    }                }                // generate icon next                Cell iconcell = scLibrary.findNodeProto(cellname+"{ic}");                if (iconcell == null) {                    copyIconCell(stdcell.type, purpleLibrary, cellname, scLibrary, d);                }                // generate sch last                Cell schcell = scLibrary.findNodeProto(cellname+"{sch}");                if (schcell == null) {                    copySchCell(stdcell.type, purpleLibrary, cellname, scLibrary, d);                }                schcell = scLibrary.findNodeProto(cellname+"{sch}");                // mark schematic as standard cell                List<Cell> cells = new ArrayList<Cell>();                cells.add(schcell);                markStandardCell(cells, null);            }        }        return true;    }    private boolean copyIconCell(String name, Library lib, String toName, Library toLib, double size) {        // check if icon already exists        Cell iconcell = toLib.findNodeProto(toName+"{ic}");        Cell fromIconCell = lib.findNodeProto(name+"{ic}");        if (iconcell == null && fromIconCell != null) {            iconcell = Cell.copyNodeProto(fromIconCell, toLib, toName, false);            if (iconcell == null) {                prErr("Unable to copy purple cell "+fromIconCell.describe(false)+" to library "+toLib);                return false;            }            // add size text            NodeInst sizeni = NodeInst.makeInstance(pin, new EPoint(0,0),                    0, 0, iconcell);            sizeni.newVar(Artwork.ART_MESSAGE, new Double(size),                    TextDescriptor.getAnnotationTextDescriptor().withColorIndex(blueColorIndex));            // change all arcs to blue            for (Iterator<ArcInst> it = iconcell.getArcs(); it.hasNext(); ) {                ArcInst ai = it.next();                ai.newVar(Artwork.ART_COLOR, new Integer(blueColorIndex));            }            for (Iterator<NodeInst> it = iconcell.getNodes(); it.hasNext(); ) {                NodeInst ni = it.next();                ni.newVar(Artwork.ART_COLOR, new Integer(blueColorIndex));            }            // remove 'X' parameter            if (iconcell.isParam(sizeKey)) {                iconcell.getCellGroup().delParam((Variable.AttrKey)sizeKey);            }        }        return true;    }    private boolean copySchCell(String name, Library lib, String toName, Library toLib, double size) {        // check if sch already exists        Cell schcell = toLib.findNodeProto(toName+"{sch}");        Cell fromSchCell = lib.findNodeProto(name+"{sch}");        if (schcell == null && fromSchCell != null) {            schcell = Cell.copyNodeProto(fromSchCell, toLib, toName, false);            if (schcell == null) {                prErr("Unable to copy purple cell "+fromSchCell.describe(false)+" to library "+toLib);                return false;            }            // replace master icon cell in schematic            Cell iconcell = toLib.findNodeProto(toName+"{ic}");            Cell fromIconCell = lib.findNodeProto(name+"{ic}");            if (iconcell != null && fromIconCell != null) {                for (Iterator<NodeInst> it = schcell.getNodes(); it.hasNext(); ) {                    NodeInst ni = it.next();                    if (ni.isCellInstance()) {                        Cell np = (Cell)ni.getProto();                        if (np == fromIconCell) {                            ni.replace(iconcell, true, true);                        }                    }                }            }            // remove 'X' parameter            if (schcell.isParam(sizeKey)) {                schcell.getCellGroup().delParam((Variable.AttrKey)sizeKey);            }            // remove verilog template attribute            if (schcell.getVar(Verilog.VERILOG_TEMPLATE_KEY) != null) {                schcell.delVar(Verilog.VERILOG_TEMPLATE_KEY);            }            // change X value on red gate            for (Iterator<NodeInst> it = schcell.getNodes(); it.hasNext(); ) {                NodeInst ni = it.next();                if (ni.isCellInstance()) {                    Cell np = (Cell)ni.getProto();                    if (np.getLibrary() == redLibrary) {                        if (ni.isDefinedParameter(sizeKey)) {                            ni.updateParam(sizeKey, Double.valueOf(size));                        }                    }                    if (np.isIconOf(schcell)) {                        // remove size attribute                        ni.delParameter(sizeKey);                    }                }            }        }        return true;    }    /* =======================================================     * Utility     * ======================================================= */    /**

⌨️ 快捷键说明

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