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

📄 netschem.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		if (np == Schematics.tech().globalNode) {			String globalName = ni.getVarValue(Schematics.SCHEM_GLOBAL_NAME, String.class);			if (globalName != null)                return Global.newGlobal(globalName);		}		return null;	}	void calcDrawnWidths() {		Arrays.fill(drawnNames, null);		Arrays.fill(drawnWidths, -1);		int numPorts = cell.getNumPorts();		int numNodes = cell.getNumNodes();		int numArcs = cell.getNumArcs();		for (int i = 0; i < numPorts; i++) {			int drawn = drawns[i];			Name name = cell.getPort(i).getNameKey();			int newWidth = name.busWidth();			int oldWidth = drawnWidths[drawn];			if (oldWidth < 0) {				drawnNames[drawn] = name;				drawnWidths[drawn] = newWidth;				continue;			}			if (oldWidth != newWidth) {                reportDrawnWidthError(cell.getPort(i), null, drawnNames[drawn].toString(), name.toString());                if (oldWidth < newWidth) {                    drawnNames[drawn] = name;                    drawnWidths[drawn] = newWidth;                }            }		}        int arcIndex = 0;		for (Iterator<ArcInst> it = cell.getArcs(); arcIndex < numArcs; arcIndex++) {			int drawn = drawns[arcsOffset + arcIndex];			if (drawn < 0) continue;			ArcInst ai = it.next();			Name name = ai.getNameKey();			if (name.isTempname()) continue;			int newWidth = name.busWidth();			int oldWidth = drawnWidths[drawn];			if (oldWidth < 0) {				drawnNames[drawn] = name;				drawnWidths[drawn] = newWidth;				continue;			}			if (oldWidth != newWidth) {                reportDrawnWidthError(null, ai, drawnNames[drawn].toString(), name.toString());                if (oldWidth < newWidth) {                    drawnNames[drawn] = name;                    drawnWidths[drawn] = newWidth;                }            }		}		ArcProto busArc = Schematics.tech().bus_arc;        arcIndex = 0;		for (Iterator<ArcInst> it = cell.getArcs(); arcIndex < numArcs; arcIndex++) {			int drawn = drawns[arcsOffset + arcIndex];			if (drawn < 0) continue;			ArcInst ai = it.next();			Name name = ai.getNameKey();			if (!name.isTempname()) continue;			int oldWidth = drawnWidths[drawn];			if (oldWidth < 0) {				drawnNames[drawn] = name;				if (ai.getProto() != busArc)					drawnWidths[drawn] = 1;			}		}		for (int i = 0; i < numNodes; i++) {			NodeInst ni = cell.getNode(i);			NodeProto np = ni.getProto();			if (!ni.isCellInstance()) {				if (np.getFunction() == PrimitiveNode.Function.PIN) continue;				if (np == Schematics.tech().offpageNode) continue;			}			int numPortInsts = np.getNumPorts();			for (int j = 0; j < numPortInsts; j++) {				PortInst pi = ni.getPortInst(j);				int drawn = drawns[getPortInstOffset(pi)];				if (drawn < 0) continue;				int oldWidth = drawnWidths[drawn];				int newWidth = 1;				if (ni.isCellInstance()) {					NetCell netCell = networkManager.getNetCell((Cell)np);					if (netCell instanceof NetSchem) {						int arraySize = ((Cell)np).isIcon() ? ni.getNameKey().busWidth() : 1;						int portWidth = pi.getPortProto().getNameKey().busWidth();						if (oldWidth == portWidth) continue;						newWidth = arraySize*portWidth;					}				}				if (oldWidth < 0) {					drawnWidths[drawn] = newWidth;					continue;				}				if (oldWidth != newWidth)  {					String msg = "Network: Schematic " + cell + " has net <" +						drawnNames[drawn] + "> with width conflict in connection " + pi.describe(true);                    System.out.println(msg);                    networkManager.pushHighlight(pi);                    networkManager.logError(msg, NetworkTool.errorSortNetworks);                }			}		}		for (int i = 0; i < drawnWidths.length; i++) {			if (drawnWidths[i] < 1)				drawnWidths[i] = 1;			if (NetworkTool.debug) System.out.println("Drawn "+i+" "+(drawnNames[i] != null ? drawnNames[i].toString() : "") +" has width " + drawnWidths[i]);		}	}    // this method will not be called often because user will fix error, so it's not    // very efficient.    void reportDrawnWidthError(Export pp, ArcInst ai, String firstname, String badname) {        // first occurrence is initial width which all subsequents are compared to        int numPorts = cell.getNumPorts();        int numArcs = cell.getNumArcs();        String msg = "Network: Schematic " + cell + " has net with conflict width of names <" +                           firstname + "> and <" + badname + ">";        System.out.println(msg);        boolean originalFound = false;        for (int i = 0; i < numPorts; i++) {            String name = cell.getPort(i).getName();            if (name.equals(firstname)) {                networkManager.pushHighlight(cell.getPort(i));                originalFound = true;                break;            }        }        if (!originalFound) {            for (Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); ) {                ArcInst oai = it.next();                String name = oai.getName();                if (name.equals(firstname)) {                    networkManager.pushHighlight(oai);                    break;                }            }        }        if (ai != null) networkManager.pushHighlight(ai);        if (pp != null) networkManager.pushHighlight(pp);        networkManager.logError(msg, NetworkTool.errorSortNetworks);    }	@Override	void addNetNames(Name name, Export e, ArcInst ai) { 		for (int i = 0; i < name.busWidth(); i++) 			addNetName(name.subname(i), e, ai);	}	private void localConnections(int netMap[]) {		// Exports		int numExports = cell.getNumPorts();		for (int k = 0; k < numExports; k++) {			Export e = cell.getPort(k);			int portOffset = portOffsets[k];			Name expNm = e.getNameKey();			int busWidth = expNm.busWidth();			int drawn = drawns[k];			int drawnOffset = drawnOffsets[drawn];			for (int i = 0; i < busWidth; i++) {                Netlist.connectMap(netMap, portOffset + i, drawnOffset + (busWidth == drawnWidths[drawn] ? i : i % drawnWidths[drawn]));				GenMath.MutableInteger nn = netNames.get(expNm.subname(i));				Netlist.connectMap(netMap, portOffset + i, netNamesOffset + nn.intValue());			}		}		// PortInsts		int numNodes = cell.getNumNodes();		for (int k = 0; k < numNodes; k++) {			NodeInst ni = cell.getNode(k);			if (ni.isIconOfParent()) continue;			NodeProto np = ni.getProto();			if (!ni.isCellInstance()) {				// Connect global primitives				Global g = globalInst(ni);				if (g != null) {					int drawn = drawns[ni_pi[k]];					Netlist.connectMap(netMap, globals.indexOf(g), drawnOffsets[drawn]);				}				if (np == Schematics.tech().wireConNode)					connectWireCon(netMap, ni);				continue;			}			if (nodeOffsets[k] >= 0) continue;			NetCell netCell = networkManager.getNetCell((Cell)np);			if (!(netCell instanceof NetSchem)) continue;			NetSchem icon = (NetSchem)netCell;			NetSchem schem = netCell.getSchem();			if (schem == null) continue;			Name nodeName = ni.getNameKey();			int arraySize = nodeName.busWidth();			int proxyOffset = nodeOffsets[k];			int numPorts = np.getNumPorts();			for (int m = 0; m < numPorts; m++) {				Export e = (Export) np.getPort(m);				int portIndex = m;				portIndex = icon.portImplementation[portIndex];				if (portIndex < 0) continue;				int portOffset = schem.portOffsets[portIndex];				int busWidth = e.getNameKey().busWidth();				int drawn = drawns[ni_pi[k] + m];				if (drawn < 0) continue;				int width = drawnWidths[drawn];				if (width != busWidth && width != busWidth*arraySize) continue;				for (int i = 0; i < arraySize; i++) {					Proxy proxy = nodeProxies[~proxyOffset + i];					if (proxy == null) continue;					int nodeOffset = proxy.nodeOffset + portOffset;					int busOffset = drawnOffsets[drawn];					if (width != busWidth) busOffset += busWidth*i;					for (int j = 0; j < busWidth; j++) {						Netlist.connectMap(netMap, busOffset + j, nodeOffset + j);					}				}			}		}		// Arcs		int numArcs = cell.getNumArcs(), arcIndex = 0;		for (Iterator<ArcInst> it = cell.getArcs(); arcIndex < numArcs; arcIndex++) {			ArcInst ai = it.next();			int drawn = drawns[arcsOffset + arcIndex];			if (drawn < 0) continue;			if (!ai.isUsernamed()) continue;			int busWidth = drawnWidths[drawn];			Name arcNm = ai.getNameKey();			if (arcNm.busWidth() != busWidth) continue;			int drawnOffset = drawnOffsets[drawn];			for (int i = 0; i < busWidth; i++) {				GenMath.MutableInteger nn = netNames.get(arcNm.subname(i));				Netlist.connectMap(netMap, drawnOffset + i, netNamesOffset + nn.intValue());			}		}		// Globals of proxies		for (int k = 0; k < nodeProxies.length; k++) {			Proxy proxy = nodeProxies[k];			if (proxy == null) continue;			NodeProto np = proxy.getProto();			NetSchem schem = (NetSchem)networkManager.getNetCell((Cell)np);			int numGlobals = schem.portOffsets[0];			if (numGlobals == 0) continue;			Set/*<Global>*/ excludeGlobals = null;			if (proxyExcludeGlobals != null)				excludeGlobals = proxyExcludeGlobals.get(proxy);			for (int i = 0; i < numGlobals; i++) {				Global g = schem.globals.get(i);				if (excludeGlobals != null && excludeGlobals.contains(g)) continue;				Netlist.connectMap(netMap, this.globals.indexOf(g), proxy.nodeOffset + i);			}		}        Netlist.closureMap(netMap);        HashMap<String,Name> canonicToName = new HashMap<String,Name>();        for (Map.Entry<Name,GenMath.MutableInteger> e: netNames.entrySet()) {            Name name = e.getKey();            int index = e.getValue().intValue();            assert index >= 0;            String canonicString = name.canonicString();            Name canonicName = canonicToName.get(canonicString);            if (canonicName == null) {                canonicName = name;                canonicToName.put(canonicString, canonicName);                continue;            }            int mapIndex0 = netNamesOffset + index;            int mapIndex1 = netNamesOffset + netNames.get(canonicName).intValue();            if (netMap[mapIndex0] != netMap[mapIndex1]) {                String msg = "Network: Schematic " + cell + " doesn't connect nets with names '" + name + "' and '" + canonicName + "'";                System.out.println(msg);                pushName(name);                pushName(canonicName);                networkManager.logWarning(msg, NetworkTool.errorSortNetworks);//                Netlist.connectMap(netMap, mapIndex0, mapIndex1);            }        }	}    private void pushName(Name name) {        for (Iterator<Export> it = cell.getExports(); it.hasNext(); ) {            Export e = it.next();            Name n = e.getNameKey();            for (int i = 0; i < n.busWidth(); i++) {                if (n.subname(i) == name) {                    networkManager.pushHighlight(e);                    return;                }            }        }        for (Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); ) {            ArcInst ai = it.next();            Name n = ai.getNameKey();            for (int i = 0; i < n.busWidth(); i++) {                if (n.subname(i) == name) {                    networkManager.pushHighlight(ai);                    return;                }            }        }    }	private void connectWireCon (int[] netMap, NodeInst ni) {		ArcInst ai1 = null;		ArcInst ai2 = null;		for (Iterator<Connection> it = ni.getConnections(); it.hasNext();) {			Connection con = it.next();			ArcInst ai = con.getArc();			if (ai1 == null) {				ai1 = ai;			} else if (ai2 == null) {				ai2 = ai;			} else {				String msg = "Network: Schematic " + cell + " has connector " + ni +					" which merges more than two arcs";

⌨️ 快捷键说明

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