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

📄 lenetlister2.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: LENetlister2.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.network.Network;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.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStream;import java.io.PrintStream;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;/** * 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 LENetlister2 extends LENetlister {    /** Netlister constants */                  protected NetlisterConstants constants;    /** Map of Cells to CachedCells */          private Map<Cell,CachedCell> cellMap;    /** Map of globalID's to LENetworks */      private Map<Integer,LENetwork> globalNetworks;    /** List of sizeable unique LENodables */   private List<LENodable> sizableLENodables;    /** List of all unique LENodables */        private List<LENodable> allLENodables;    /** Map of Nodables to LENodable definitions */     private Map<Nodable,LENodable> nodablesDefinitions;    /** Sizer */                                private LESizer2 sizer;    /** Job we are part of */                   private Job job;    /** Where to direct output */               private PrintStream out;    /** 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;    /** whether or not to disable caching */    private boolean disableCaching = true;    private static final boolean DEBUG = false;    private static final boolean DEBUG_FIRSTPASS = false;    private static final boolean DEBUG_PRINTCACHEDCELLS = false;    /** Creates a new instance of LENetlister */    public LENetlister2(Job job, Technology layoutTech) {        super(layoutTech);        // get preferences for this package        Tool leTool = Tool.findTool("logical effort");        constants = null;        topLevelCell = null;        this.job = job;        this.cellMap = new HashMap<Cell,CachedCell>();        this.globalNetworks = new HashMap<Integer,LENetwork>();        this.sizableLENodables = new ArrayList<LENodable>();        this.allLENodables = new ArrayList<LENodable>();        this.nodablesDefinitions = new HashMap<Nodable,LENodable>();        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) {        disableCaching = !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;        FirstPassEnum firstPass = new FirstPassEnum(this);        HierarchyEnumerator.enumerateCell(cell, context, firstPass, SHORT_RESISTORS);//        HierarchyEnumerator.enumerateCell(cell, context, netlist, firstPass);        firstPass.cleanup(disableCaching);        System.out.println("Cached "+cellMap.size()+" cells");        if (DEBUG_FIRSTPASS) {            for (Map.Entry<Cell,CachedCell> entry : cellMap.entrySet()) {                Cell acell = (Cell)entry.getKey();                CachedCell cc = (CachedCell)entry.getValue();                System.out.println("Cached "+acell);            }        }        if (DEBUG_PRINTCACHEDCELLS) {            String outputFile = System.getProperty("user.dir") + File.separator + "PrintCachedCells.txt";            try {                FileOutputStream fos = new FileOutputStream(outputFile, false);                BufferedOutputStream bout = new BufferedOutputStream(fos);                PrintStream out2 = new PrintStream(bout);                // redirect stderr to the log file                //System.setErr(new PrintStream(bout, true));                for (Map.Entry<Cell,CachedCell> entry : cellMap.entrySet()) {                    Cell acell = (Cell)entry.getKey();                    CachedCell cc = (CachedCell)entry.getValue();                    cc.printContents("  ", out2);                }                out2.close();                System.out.println("Wrote debug to "+outputFile);            } catch (IOException e) {                System.out.println("Cannot write CachedCells debug: "+e.getMessage());            }        }        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 LESizer2(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;    }    /**     * Updates the size of all Logical Effort gates     */    public void getSizes(List<Float> sizes, List<String> varNames,                         List<NodeInst> nodes, List<VarContext> contexts) {        // iterator over all LEGATEs        for (Iterator<LENodable> cit = getSizeableNodables(); cit.hasNext(); ) {            LENodable leno = cit.next();            Nodable no = leno.getNodable();            NodeInst ni = no.getNodeInst();            if (ni != null) no = ni;            // ignore it if not a sizeable gate            if (!leno.isLeGate()) continue;            String varName = "LEDRIVE_" + leno.getName();            //no.newVar(varName, new Float(leno.leX));            //topLevelCell.newVar(varName, new Float(leno.leX));            sizes.add(new Float(leno.leX));            varNames.add(varName);            nodes.add(ni);            contexts.add(leno.context);        }    }    /**     * Updates the size of all Logical Effort gates     */    public void updateSizes() {        // iterator over all LEGATEs        for (Iterator<LENodable> cit = getSizeableNodables(); cit.hasNext(); ) {            LENodable leno = cit.next();            Nodable no = leno.getNodable();            NodeInst ni = no.getNodeInst();            if (ni != null) no = ni;            // ignore it if not a sizeable gate            if (!leno.isLeGate()) continue;            String varName = "LEDRIVE_" + leno.getName();            //no.newVar(varName, new Float(leno.leX));            topLevelCell.newVar(varName, new Float(leno.leX));            if (leno.leX < 1.0f) {                String msg = "WARNING: Instance "+ni+" has size "+TextUtils.formatDouble(leno.leX, 3)+" less than 1 ("+leno.getName()+")";                System.out.println(msg);                if (ni != null) {                    errorLogger.logWarning(msg, ni, ni.getParent(), leno.context, 2);                }            }        }    }    public void done() {        errorLogger.termLogging(true);        //errorLogger = null;    }    public ErrorLogger getErrorLogger() { return errorLogger; }    public void nullErrorLogger() { errorLogger = null; }    public NetlisterConstants getConstants() { return constants; }

⌨️ 快捷键说明

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