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

📄 lenetlister1.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: LENetlister1.java * Written by Jonathan Gainsley, Sun Microsystems. * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. * * Created on November 11, 2003, 3:56 PM */package com.sun.electric.tool.logicaleffort;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.hierarchy.HierarchyEnumerator;import com.sun.electric.database.hierarchy.Nodable;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.VarContext;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Schematics;import com.sun.electric.tool.Job;import com.sun.electric.tool.Tool;import com.sun.electric.tool.logicaleffort.LENetlister.NetlisterConstants;import com.sun.electric.tool.user.ErrorLogger;import java.io.OutputStream;import java.io.PrintStream;import java.util.ArrayList;import java.util.Collection;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import java.util.TreeMap;/** * Creates a logical effort netlist to be sized by LESizer. * This is so the LESizer is independent of Electric's Database, * and can match George Chen's C++ version being developed for * PNP. * * @author  gainsley */public class LENetlister1 extends LENetlister {    // ALL GATES SAME DELAY    /** Netlister constants */                  protected NetlisterConstants constants;    /** all networks */                         private HashMap<String,Net> allNets;    /** all instances (LEGATES, not loads) */   private Map<String,Instance> allInstances;    /** Sizer */                                private LESizer sizer;    /** Job we are part of */                   private Job job;    /** Where to direct output */               private PrintStream out;    /** Mapping between NodeInst and Instance */private List<Instance> instancesMap;    /** True if we got aborted */               private boolean aborted;    /** for logging errors */                   private ErrorLogger errorLogger;    /** record definition errors so no multiple warnings */ private HashMap<Export,Export> lePortError;    /** The top level cell netlisted */         private Cell topLevelCell;    private static final boolean DEBUG = false;    /** Creates a new instance of LENetlister */    public LENetlister1(Job job, Technology layoutTech) {        super(layoutTech);        // get preferences for this package        Tool leTool = Tool.findTool("logical effort");        constants = null;        topLevelCell = null;        allNets = new HashMap<String,Net>();        allInstances = new TreeMap/*HashMap*/<String,Instance>();        this.job = job;        this.instancesMap = new ArrayList<Instance>();        this.lePortError = new HashMap<Export,Export>();        this.out = new PrintStream((OutputStream)System.out);        errorLogger = null;        aborted = false;    }    // Entry point: This netlists the cell    @Override    public boolean netlist(Cell cell, VarContext context, boolean useCaching) {        //ArrayList connectedPorts = new ArrayList();        //connectedPorts.add(Schematics.tech.resistorNode.getPortsList());        assert errorLogger == null;//        if (errorLogger != null) errorLogger.delete();        errorLogger = ErrorLogger.newInstance("LE Netlister");//        Netlist netlist = cell.getNetlist(true);        // read schematic-specific sizing options        constants = getSettings(cell);        if (constants == null) {            constants = new NetlisterConstants(layoutTech);            if (!saveSettings(constants, cell)) {                // couldn't save settings to cell, abort                return false;            }        }        topLevelCell = cell;        HierarchyEnumerator.enumerateCell(cell, context, this, SHORT_RESISTORS);//        HierarchyEnumerator.enumerateCell(cell, context, netlist, this);        if (aborted) return false;        return true;    }    /**     * Size the netlist.     * @return true on success, false otherwise.     */    public boolean size(LESizer.Alg algorithm) {        //lesizer.printDesign();        boolean verbose = false;        // create a new sizer        sizer = new LESizer(algorithm, this, job, errorLogger);        boolean success = sizer.optimizeLoops(constants.epsilon, constants.maxIterations, verbose,                constants.alpha, constants.keeperRatio);        //out.println("---------After optimization:------------");        //lesizer.printDesign();        // get rid of the sizer        sizer = null;        return success;    }    public void getSizes(List<Float> sizes, List<String> varNames, List<NodeInst> nodes, List<VarContext> contexts) {        // iterator over all LEGATEs        Set<Map.Entry<String,Instance>> allEntries = allInstances.entrySet();        for (Map.Entry<String,Instance> entry : allEntries) {            Instance inst = (Instance)entry.getValue();            Nodable no = inst.getNodable();            NodeInst ni = no.getNodeInst();            if (ni != null) no = ni;            if (!inst.isLeGate()) continue;            String varName = "LEDRIVE_" + inst.getName();            //no.newVar(varName, new Float(inst.getLeX()));            //topLevelCell.newVar(varName, new Float(inst.getLeX()));            sizes.add(new Float(inst.getLeX()));            varNames.add(varName);            nodes.add(ni);            contexts.add(inst.getContext());        }    }    public void done() {        errorLogger.termLogging(true);        //errorLogger = null;    }    public ErrorLogger getErrorLogger() { return errorLogger; }    public void nullErrorLogger() { errorLogger = null; }    public NetlisterConstants getConstants() { return constants; }    /**	 * Add new instance to design	 * @param name name of the instance	 * param leGate true if this is an LEGate	 * @param leX size	 * @param pins list of pins on instance	 *	 * @return the new instance added, null if error	 */	protected Instance addInstance(String name, Instance.Type type, float leSU,		float leX, ArrayList<Pin> pins, Nodable no)	{		if (allInstances.containsKey(name)) {			out.println("Error: Instance "+name+" already exists.");			return null;		}		// create instance		Instance instance = new Instance(name, type, leSU, leX, no);		// create each net if necessary, from pin.		Iterator<Pin> iter = pins.iterator();		while (iter.hasNext()) {			Pin pin = iter.next();			String netname = pin.getNetName();			// check to see if net had already been added to the design			Net net = allNets.get(netname);			if (net != null) {				pin.setNet(net);				pin.setInstance(instance);				net.addPin(pin);			} else {				// create new net				net = new Net(netname);				allNets.put(netname, net);				pin.setNet(net);				pin.setInstance(instance);				net.addPin(pin);			}		}		instance.setPins(pins);		allInstances.put(name, instance);		return instance;	}    //public HashMap getInstancesMap() { return instancesMap; }    protected Map<String,Instance> getAllInstances() { return allInstances; }    protected HashMap<String,Net> getAllNets() { return allNets; }    /** return number of gates sized */    protected int getNumGates() { return allInstances.size(); }    protected LESizer getSizer() { return sizer; }    protected float getKeeperRatio() { return constants.keeperRatio; }    // ======================= Hierarchy Enumerator ==============================    /**     * Override the default Cell info to pass along logical effort specific information     * @return a LECellInfo     */    public HierarchyEnumerator.CellInfo newCellInfo() { return new LECellInfo(); }    /**     * Enter cell initializes the LECellInfo.     * @param info the LECellInfo     * @return true to process the cell, false to ignore.     */    public boolean enterCell(HierarchyEnumerator.CellInfo info) {        if (aborted) return false;        if (((LETool.AnalyzeCell)job).checkAbort(null)) {            aborted = true;            return false;        }        LECellInfo leinfo = (LECellInfo)info;        leinfo.leInit(constants);        // check if conflicting settings        if (topLevelCell != info.getCell()) {            if (isSettingsConflict(leinfo.getSettings(), topLevelCell, info.getContext(), info.getCell())) {                aborted = true;                return false;            }        }        return true;    }    /**     * Visit NodeInst creates a new Logical Effort instance from the     * parameters found on the Nodable, if that Nodable is an LEGATE.     * It also creates instances for wire models (LEWIREs).     * @param ni the Nodable being visited     * @param info the cell info     * @return true to push down into the Nodable, false to continue.     */    public boolean visitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) {        float leX = (float)0.0;        boolean wire = false;        boolean primitiveTransistor = false;        // Check if this NodeInst is tagged as a logical effort node        Instance.Type type = null;        Variable var = null;        if ((var = getVar(ni, ATTR_LEGATE)) != null) {            // assume it is LEGATE if can't resolve value            int gate = VarContext.objectToInt(info.getContext().evalVar(var), 1);            if (gate == 1)                type = Instance.Type.LEGATE;            else                return true;        }        else if ((var = getVar(ni, ATTR_LEKEEPER)) != null) {            // assume it is LEKEEPER if can't resolve value            int gate = VarContext.objectToInt(info.getContext().evalVar(var), 1);            if (gate == 1)                type = Instance.Type.LEKEEPER;            else                return true;        }        else if (getVar(ni, ATTR_LEWIRE) != null) {            type = Instance.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 = ni.getParameterOrVariable(ATTR_LEWIRECAP);            float cap = 0;            if (var != null) {                cap = VarContext.objectToFloat(info.getContext().evalVar(var), 0.0f);

⌨️ 快捷键说明

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