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

📄 scanchainxml.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            }            if (DEBUG) System.out.println("Completed Entity "+ent.name+".  inport: "+schInPort+", outport: "+ent.getOutExPort());        } else {            // definition found, just grab output port instance info            ExPort outEx = ent.getOutExPort();            if (outEx != null) {                outport = getPort(no, outEx.name.toString());            }        }        // wrap with instance info        return new SubChainInst(inport, outport, no, ent);    }    /**     * Append any scan chain elements to the chain.  Returns the number     * of elements appended     * @param chain     * @param ports     * @return the last instance added to the chain. May be null if nothing added     */    private SubChainInst appendChain(Chain chain, List<Port> ports) {        ArrayList<Chain> possibleChains = new ArrayList<Chain>();        ArrayList<SubChainInst> chainLastInstances = new ArrayList<SubChainInst>();        // each port may or may not lead to a chain of scan chain elements        for (Port p : ports) {            SubChainInst inst = getSubChain(p);            if (inst == null) continue;         // possible dead end            Chain tempChain = new Chain("temp", -1, -1);            SubChain sub = inst.content;            if (sub == endChain) {                tempChain.addSubChainInst(inst);                // store if found good chain                if (tempChain.getSubChainSize() > 0) {                    possibleChains.add(tempChain);                    chainLastInstances.add(inst);                }                continue;          // end of chain            }            if (sub != null) {                if (sub.getLength() > 0 || sub.getSubChainSize() > 0 || sub.isPassThrough()) {                    // add to chain if has any content, or if it's a pass through cell                    tempChain.addSubChainInst(inst);                }            }            // Note: Here we don't care if sub is null. Only the instance info is            // important from this point on to continue following the chain            // continue along chain            Port outport = inst.getOutport();            if (outport == null) continue;            SubChainInst last = inst;            if (DEBUG) System.out.println("Setting last to "+last);            List<Port> nextPorts = getOtherPorts(outport);            SubChainInst appendLast = appendChain(tempChain, nextPorts);            if (appendLast != null) {                if (DEBUG) System.out.println("Replacing last with "+appendLast);                last = appendLast;            }            // store if found good chain            if (tempChain.getSubChainSize() > 0) {                possibleChains.add(tempChain);                chainLastInstances.add(last);            }        }        // check if any chains found, or if too many found        if (possibleChains.size() == 0) return null;        if (possibleChains.size() > 1) {            System.out.print("Error! Found more than one chain branching from port set: ");            Port p = null;            for (Iterator<Port> it = ports.iterator(); it.hasNext(); ) {                p = it.next();                System.out.print(p.no.getName()+":"+p.name+", ");            }            System.out.println("in cell "+p.no.getParent().describe(false));        }        // append only chain, return last instance in chain        Chain temp = possibleChains.get(0);        for (Iterator<SubChainInst> it = temp.getSubChainInsts(); it.hasNext(); ) {            SubChainInst inst = it.next();            chain.addSubChainInst(inst);        }        return chainLastInstances.get(0);    }    private void postProcessEntitiesRemovePassThroughs() {        for (Entity ent : entities.values()) {            ent.removePassThroughs();        }    }    private void postProcessEntitiesPhase1() {        int reduced = 1;        while (reduced > 0) {            reduced = 0;            /* can't do this anymore with dataNet and dataNet2 attributes            for (Entity ent : entities.values()) {                // if lots of subchains with the same clears and access, consolidate them                if (ent.getSubChainSize() > 1) {                    SubChainInst consolidated = null;                    List newList = new ArrayList();                    // merge subchains with the same access and clears                    for (Iterator it2 = ent.getSubChainInsts(); it2.hasNext(); ) {                        SubChainInst inst = it2.next();                        SubChain sub = inst.getSubChain();                        if (sub.access == null || sub.clears == null ||                            sub.length <= 0 || sub.getSubChainSize() > 0) {                            // can't consolidate                            consolidated = null;                            newList.add(inst);                        } else {                            // consolidatable                            if (consolidated != null &&                                    consolidated.getSubChain().access.equals(sub.access) &&                                    consolidated.getSubChain().clears.equals(sub.clears) && isMergable(inst)) {                                // consolidate if they match                                consolidated.getSubChain().length += sub.length;                                consolidated.setOutport(inst.getOutport());                                reduced++;                            } else {                                consolidated = new SubChainInst(inst.getInport(), inst.getOutport(), inst.no, (SubChain)inst.getSubChain().clone());                                newList.add(consolidated);                            }                        }                    }                    ent.replaceSubChainInsts(newList);                }            }            */            for (Entity ent : entities.values()) {                // if only one sub chain that contains no other sub chains, fold into this                if (ent.length <= 0 && ent.getSubChainSize() == 1) {                    SubChainInst inst = ent.getSubChainInsts().next();                    SubChain sub = inst.getSubChain();                    if (sub.length > 0 && sub.getSubChainSize() == 0 && isFlattenable(inst)) {                        // fold into parent                        ent.length = sub.length;                        ent.access = sub.access;                        ent.clears = sub.clears;                        // on first iteration, do not add sub name, because net is not inside sub                        if (sub.dataNet != null)                            ent.dataNet = new DataNet("x" + inst.getName() + "." + sub.dataNet.net, sub.dataNet.options);                        else                            ent.dataNet = null;                        if (sub.dataNet2 != null)                            ent.dataNet2 = new DataNet("x" + inst.getName() + "." + sub.dataNet2.net, sub.dataNet2.options);                        else                            ent.dataNet2 = null;                        ent.remove(inst);                        reduced++;                    }                }                // flatten any specified sub chain cells                if (ent.length <= 0) {                    // see if any sub cells should be flattened                    for (int i=0; i<ent.getSubChainSize(); i++) {                        SubChain sub = ent.getSubChain(i);                        SubChainInst inst = ent.getSubChainInst(i);                        if (sub instanceof Entity) {                            Entity subEnt = (Entity)sub;                            if ((cellsToFlatten.get(subEnt.cell) != null) &&                                    isFlattenable(inst) && sub.length < 0 && sub.getSubChainSize() > 0) {                                // merge subchain's subchains into this entity                                ent.remove(ent.getSubChainInst(i));                                ent.addAllSubChainInsts(i, sub.getSubChainsInsts());                                reduced++;                            }                        }                    }                }            }        }    }//    private boolean isMergable(SubChainInst inst) {//        if (!inst.getName().matches(".*?@.*")) return false;//        return true;//    }    private boolean isFlattenable(SubChainInst inst) {        if (!inst.getName().matches(".*?@.*")) return false;        return true;    }    // -------------------------------------- Port Manipulation ---------------------------------    private ExPort getExportedPort(Port port) {        if (port == null) return null;        Cell cell = port.no.getParent();        // list of all portinsts on net        Netlist netlist = cell.getNetlist(SHORT_RESISTORS);        Network net = netlist.getNetwork(port.no, port.pp, port.index);        for (Iterator<PortProto> it = cell.getPorts(); it.hasNext(); ) {            Export ex = (Export)it.next();            Name name = ex.getNameKey();            for (int i=0; i<name.busWidth(); i++) {                if (netlist.getNetwork(ex, i) == net)                    return new ExPort(name.subname(i), ex, i);            }        }        return null;    }    /**     * Get a list of other Ports on the same network as the ExPort.     * The returned list does not include the Port corresponding to the ExPort     * @param inport the ExPort     * @return a list of Port objects     */    private ArrayList<Port> getOtherPorts(ExPort inport) {        // convert ExPort to Port        PortInst pi = inport.ex.getOriginalPort();        NodeInst ni = pi.getNodeInst();        Netlist netlist = ni.getParent().getNetlist(SHORT_RESISTORS);        Network net = netlist.getNetwork(inport.ex, inport.index);        Port port = null;        PortProto pp = pi.getPortProto();        if (pp instanceof Export) {            PortProto equiv = ((Export)pp).getEquivalent();            if (equiv != null)                pp = equiv;        }        for (Iterator<Nodable> it = netlist.getNodables(); it.hasNext(); ) {            Nodable no = it.next();            if (no.getNodeInst() == ni) {                if (net == netlist.getNetwork(no, pp, inport.index)) {                    port = new Port(inport.name, no, pp, inport.index);                    break;                }            }        }        if (port == null) {            port = new Port(inport.name, ni, pp, inport.index);            ArrayList<Port> list = new ArrayList<Port>();            list.add(port);            return list;            //System.out.println("Error: no other ports connected to export "+inport.ex.getName()+" (make sure the export is on an off-page node).");            //return null;        }        return getOtherPorts(port, false);    }    /**     * Get a list of other Ports on the same network as inport.  List     * does not include inport.     * @param inport     * @return a list of Port objects     */    private ArrayList<Port> getOtherPorts(Port inport) {        return getOtherPorts(inport, true);    }    /**     * Get a list of other Ports on the same network as inport.  List     * does not include inport.     * @param inport     * @param ignoreInport true to not include inport in the list     * @return a list of Port objects     */    private ArrayList<Port> getOtherPorts(Port inport, boolean ignoreInport) {        if (inport == null) return null;        ArrayList<Port> ports = new ArrayList<Port>();        Cell cell = inport.no.getParent();        Netlist netlist = cell.getNetlist(SHORT_RESISTORS);        Network net = netlist.getNetwork(inport.no, inport.pp, inport.index);        for (Iterator<Nodable> it = netlist.getNodables(); it.hasNext(); ) {            Nodable no = it.next();            for (Iterator<PortProto> it2 = no.getProto().getPorts(); it2.hasNext(); ) {                PortProto pp = it2.next();                Name name = pp.getNameKey();                for (int i=0; i<name.busWidth(); i++) {                    if (ignoreInport) {                        if ((no == inport.no) && (pp == inport.pp) && (i == inport.index))                            continue;                    }                    if (netlist.getNetwork(no, pp, i) == net) {                        // found matching port                        Name subname = name;                        if (name.busWidth() > 1) subname = name.subname(i);                        Port p = new Port(subname, no, pp, i);                        ports.add(p);                    }                }            }        }        if (ports.size() == 0) {            if (!ignoreInport) {                ports.add(inport);                return ports;            }            System.out.println("Warning: no other ports connected to port "+inport.name+" on node "+inport.no.getName()+" in cell "+inport.no.getParent().describe(false));        }        return ports;    }    /**     * Get a port from a port name on a Nodable     * @param no the nodable     * @param portName the port name including bus index, such as foo[1][2]     * @return a Port, or null if none found     */    private Port getPort(Nodable no, String portName) {        for (Iterator<PortProto> it = no.getProto().getPorts(); it.hasNext(); ) {            PortProto pp = it.next();            Name name = pp.getNameKey();            for (int i=0; i<name.busWidth(); i++) {                Name subname = name.subname(i);                if (subname.toString().equals(portName)) {                    return new Port(subname, no, pp, i);                }            }        }        System.out.println("Could not find "+portName+" on "+no.getName());        return null;    }    /**     * Get an export in a cell from a exportName. The export     * name may include a bus index, such as foo[1][2]     * @param cell the cell     * @param exportName the export name     * @return an ExPort     */    private ExPort getExPort(Cell cell, String exportName) {        for (Iterator<PortProto> it = cell.getPorts(); it.hasNext(); ) {            Export ex = (Export)it.next();            Name name = ex.getNameKey();            for (int i=0; i<name.busWidth(); i++) {                Name subname = name.subname(i);                if (subname.toString().equals(exportName)) {                    return new ExPort(subname, ex, i);                }            }        }        return null;    }}

⌨️ 快捷键说明

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