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

📄 silos.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			{				CellSignal oCs = outerSignalList[k-lowIndex];				if (cs == oCs) break;			}			if (k < j) break;		}		if (j <= highIndex)		{			breakBus = true;		} else		{			// bus entries must have the same root name and go in order			String lastnetname = null;			for(j=lowIndex; j<=highIndex; j++)			{				CellSignal wl = outerSignalList[j-lowIndex];				String thisnetname = wl.getName();				if (wl.getExport() != null)				{					if (wl.isDescending())					{						if (!descending) break;					} else					{						if (descending) break;					}				}				int openSquare = thisnetname.indexOf('[');				if (openSquare < 0) break;				if (j > lowIndex)				{					int li = 0;					for( ; li < lastnetname.length(); li++)					{						if (thisnetname.charAt(li) != lastnetname.charAt(li)) break;						if (lastnetname.charAt(li) == '[') break;					}					if (lastnetname.charAt(li) != '[' || thisnetname.charAt(li) != '[') break;					int thisIndex = TextUtils.atoi(thisnetname.substring(li+1));					int lastIndex = TextUtils.atoi(lastnetname.substring(li+1));					if (thisIndex != lastIndex + 1) break;				}				lastnetname = thisnetname;			}			if (j <= highIndex) breakBus = true;		}		writeWidthLimited(" ");		if (breakBus)		{			int start = lowIndex, end = highIndex;			int order = 1;			if (descending)			{				start = highIndex;				end = lowIndex;				order = -1;			}			for(int k=start; ; k += order)			{				if (k != start)					writeWidthLimited("-");				CellSignal cs = outerSignalList[k-lowIndex];				writeWidthLimited(cs.getName());				if (k == end) break;			}		} else		{			CellSignal lastCs = outerSignalList[0];			String lastNetName = lastCs.getName();			int openSquare = lastNetName.indexOf('[');			CellSignal cs = outerSignalList[highIndex-lowIndex];			String netName = cs.getName();			int i = netName.indexOf('[');			if (i < 0) writeWidthLimited(netName); else			{				writeWidthLimited(netName.substring(0, i));				if (descending)				{					int first = TextUtils.atoi(netName.substring(i+1));					int second = TextUtils.atoi(lastNetName.substring(openSquare+1));					writeWidthLimited("[" + first + ":" + second + "]");				} else				{					int first = TextUtils.atoi(netName.substring(i+1));					int second = TextUtils.atoi(lastNetName.substring(openSquare+1));					writeWidthLimited("[" + second + ":" + first + "]");				}			}		}	}	/**	 * Method to return a string describing the SILOS type of nodeinst "ni"	 * if 'neg' is true, then the negated version is needed	 */	private String getPrimitiveName(NodeInst ni, boolean neg)	{			PrimitiveNode.Function f = getPrimitiveType(ni);		if (f.isNTypeTransistor()) return ".NMOS";		if (f.isPTypeTransistor()) return ".PMOS";		if (f == PrimitiveNode.Function.BUFFER)		{			if (neg) return ".INV";			return ".BUF";		}		if (f == PrimitiveNode.Function.GATEXOR)		{			if (neg) return ".XNOR";			return ".XOR";		}		if (f == PrimitiveNode.Function.GATEAND)		{			if (neg) return ".NAND";			return ".NAND";		}		if (f == PrimitiveNode.Function.GATEOR)		{			if (neg) return ".NOR";			return ".OR";		}		if (f == PrimitiveNode.Function.RESIST) return ".RES";		if (f == PrimitiveNode.Function.CAPAC) return ".CAP";		if (f == PrimitiveNode.Function.FLIPFLOPRSMS || f == PrimitiveNode.Function.FLIPFLOPRSP) return ".SRPEFF";		if (f == PrimitiveNode.Function.FLIPFLOPRSN) return ".SRNEFF";		if (f == PrimitiveNode.Function.FLIPFLOPJKMS || f == PrimitiveNode.Function.FLIPFLOPJKP) return ".JKPEFF";		if (f == PrimitiveNode.Function.FLIPFLOPJKN) return ".JKNEFF";		if (f == PrimitiveNode.Function.FLIPFLOPDMS || f == PrimitiveNode.Function.FLIPFLOPDP) return ".DPEFF";		if (f == PrimitiveNode.Function.FLIPFLOPDN) return ".DNEFF";		if (f == PrimitiveNode.Function.FLIPFLOPTMS || f == PrimitiveNode.Function.FLIPFLOPTP) return ".TPEFF";		if (f == PrimitiveNode.Function.FLIPFLOPTN) return ".TNEFF";		return convertName(ni.getProto().getName());	}	/**	 * Method to return the SILOS type of a node	 * Read the contents of the added string, make it available to	 * the caller	 */	private PrimitiveNode.Function getPrimitiveType(NodeInst ni)	{		if (ni.isCellInstance()) return null;		PrimitiveNode.Function func = ni.getFunction();		if (func.isPTypeTransistor()) return PrimitiveNode.Function.TRAPMOS;		if (func.isNTypeTransistor()) return PrimitiveNode.Function.TRANMOS;		if (func == PrimitiveNode.Function.GATEAND || func == PrimitiveNode.Function.GATEOR ||			func == PrimitiveNode.Function.GATEXOR || func == PrimitiveNode.Function.BUFFER ||			func == PrimitiveNode.Function.RESIST || func == PrimitiveNode.Function.CAPAC ||			func == PrimitiveNode.Function.SOURCE || func == PrimitiveNode.Function.METER ||			func == PrimitiveNode.Function.FLIPFLOPRSMS || func == PrimitiveNode.Function.FLIPFLOPRSP || func == PrimitiveNode.Function.FLIPFLOPRSN ||			func == PrimitiveNode.Function.FLIPFLOPJKMS || func == PrimitiveNode.Function.FLIPFLOPJKP || func == PrimitiveNode.Function.FLIPFLOPJKN ||			func == PrimitiveNode.Function.FLIPFLOPDMS || func == PrimitiveNode.Function.FLIPFLOPDP || func == PrimitiveNode.Function.FLIPFLOPDN ||			func == PrimitiveNode.Function.FLIPFLOPTMS || func == PrimitiveNode.Function.FLIPFLOPTP || func == PrimitiveNode.Function.FLIPFLOPTN)				return func;		return(PrimitiveNode.Function.UNKNOWN);	}	/**	 * Method to return a string describing the SILOS part name of nodeinst	 * "ni"	 */	private String getNodeInstName(NodeInst ni)	{		Variable var = ni.getVar(SILOS_NODE_NAME_KEY);		if (var != null) return var.describe(-1);		String name = ni.getName();		if (name.length() > 0)		{			if (Character.isLetter(name.charAt(0))) return name;			if (name.charAt(0) == '[') return convertSubscripts(name);		}		return "U" + name;	}	/**	 * Find a name to write for the port prototype, pp, on the node instance, ni	 * The node instance is located within the prototype, np	 * If there is an arc connected to the port, use the net name, or NETn.	 * If there are more than one arc (that are not electrically connected)	 * on the port, concatenate the names (with spaces between them).	 * If there is no arc, but the port is an export, use the exported name.	 * If the port is a power or ground port, ignore it	 * If this is not the top level cell (ie. a .macro) remove [] notation.	 */	private String getPortProtoName(boolean top, Connection con, NodeInst ni, PortProto pp, Cell np, Netlist netList, CellNetInfo cni)	{		if (pp.isPower() || pp.isGround()) return "";		if (con == null)		{			for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); )			{				Connection c = it.next();				PortInst pi = c.getPortInst();				if (pi.getPortProto() != pp) continue;				con = c;			}		}		boolean negated = false;		if (con != null && con.isNegated() && pp.getCharacteristic() == PortCharacteristic.IN) negated = true;		Network net = null;		if (con != null)		{			net = netList.getNetwork(con.getArc(), 0);		} else		{			PortInst pi = ni.findPortInstFromProto(pp);			net = netList.getNetwork(pi);		}		if (net != null)		{			CellSignal cs = cni.getCellSignal(net);			StringBuffer infstr = new StringBuffer();			infstr.append(" ");			if (negated) infstr.append("-");			infstr.append(cs.getName());			return infstr.toString();		}		// nothing connected to this port...leave a position		return " .SKIP";	}//	/**//	 * Method to check if a port of an instance is connected to one of//	 * the ports of the containing instance. If so, get rid of the '[]' format;//	 * replace '[' with '__', ignore ']'.//	 *///	private String adjustPortName(Cell np, String portName)//	{//		if (portName.indexOf('[') < 0) return portName;//		PortProto pp = np.findPortProto(portName);//		if (pp != null) return convertSubscripts(portName);//		return portName;//	}	/**	 * Method returns a string containing the rise time, as stored in	 * the variable SIM_rise_delay on node instance ni.	 * SIM_rise_delay can be multiple numbers (e.g. "rise_time,fanout")	 * This function returns a string.	 * A space is inserted as the first character in the string.	 * Returns an empty string if no variable found.	 */	private String getRiseTime(NodeInst ni)	{		Variable var = ni.getVar(Simulation.RISE_DELAY_KEY);		if (var != null) return var.describe(-1);		return "";	}	/**	 * Method returns a string containing the fall time, as stored in	 * the variable SIM_fall_delay on node instance ni.	 * SIM_fall_delay can be either an integer or a string	 * (e.g. "fall_time,fanout")	 * This function returns a string.	 * A space is inserted as the first character in the string.	 * Returns an empty string if no variable found.	 */	private String getFallTime(NodeInst ni)	{		Variable var = ni.getVar(Simulation.FALL_DELAY_KEY);		if (var != null) return var.describe(-1);		return "";	}	/**	 * Method to return an integer as the capacitance defined	 * by "SCHEM_capacitance" variable on an instance of a capacitor.	 * The returned units are in microfarads (is this right?).	 * Return -1 if nothing found.	 */	private double getCapacitanceInMicroFarads(NodeInst ni, VarContext context)	{		Variable var = ni.getVar(Schematics.SCHEM_CAPACITANCE);		if (var != null)		{			String cap = context.evalVar(var).toString();			char lastChar = 0;			int len = cap.length();			if (len > 0) lastChar = cap.charAt(len-1);			if (lastChar == 'f' || lastChar == 'F') cap = cap.substring(0, len-1);			double farads = VarContext.objectToDouble(cap, 0.0);			double microFarads = farads * 1000000.0;			return microFarads;		}		return -1;	}	/**	 * Method to write the ports of a flip-flop;	 * get them in the Electric order, then rewrite them	 * 'ni' is the current NODEINST, found in 'np' cell	 */	private static final int JORD = 0;	private static final int K	  = 1;	private static final int Q	  = 2;	private static final int QB   = 3;	private static final int CK	  = 4;	private static final int PRE  = 5;	private static final int CLR  = 6;	private void writeFlipFlop(boolean top, NodeInst ni, Cell np, PrimitiveNode.Function type, Netlist netList, CellNetInfo cni)	{		String [] portNames = new String[7];		Iterator<PortProto> it = ni.getProto().getPorts();		for(int i=0; i<7; i++)		{			if (!it.hasNext()) break;			PortProto pp = it.next();			portNames[i] = getPortProtoName(top, null, ni, pp, np, netList, cni);		}		if (portNames[PRE].equals(" .SKIP") && portNames[CLR].equals(" .SKIP"))		{			portNames[CLR] = "";		// If neither on, don't print			portNames[PRE] = "";		}		if (type == PrimitiveNode.Function.FLIPFLOPDMS)		{			writeWidthLimited(portNames[CK] + portNames[JORD] + portNames[PRE] + portNames[CLR] + " /" + portNames[Q]+ portNames[QB]);		} else		{			writeWidthLimited(portNames[CK] + portNames[JORD] + portNames[K] + portNames[PRE] + portNames[CLR] + " /" + portNames[Q] + portNames[QB]);		}	}	/**	 * Method to convert special names to SILOS format	 */	private String convertSpecialNames(String str)	{		if (str.equals("vdd")) return ".VDD";		if (str.equals("vss")) return ".VSS";		if (str.equals("vcc")) return ".VCC";		if (str.equals("gnd")) return ".GND";		if (str.equals("low")) return ".GND";		if (str.equals("hig")) return ".VDD";		return str;	}	/**	 * replace subscripted name with __ format	 */	private String convertSubscripts(String string)	{		StringBuffer sb = new StringBuffer();		for(int i=0; i<string.length(); i++)		{			char chr = string.charAt(i);			if (chr == '[') { sb.append("__"); continue; }			if (chr == ']') continue;			sb.append(chr);		}		return sb.toString();	}	/**	 * routine to replace all non-printing characters	 * in the string "p" with the letter "X" and return the string	 * We will not permit a digit in the first location; replace it	 * with '_'	 */	private String convertName(String p)	{		int len = p.length();		if (len <= 0) return p;		boolean defined = true;		for(int i=0; i<len; i++) if (!Character.isDefined(p.charAt(i))) { defined = false;   break; }		if (defined && !TextUtils.isDigit(p.charAt(0))) return p;		StringBuffer sb = new StringBuffer();		if (TextUtils.isDigit(p.charAt(0))) sb.append("_");		for(int i=0; i<len; i++)		{			char t = p.charAt(i);			if (Character.isDefined(t)) sb.append(t); else				sb.append("_");		}		return sb.toString();	}	/****************************** SUBCLASSED METHODS FOR THE TOPOLOGY ANALYZER ******************************/	/**	 * Method to adjust a cell name to be safe for Silos output.	 * @param name the cell name.	 * @return the name, adjusted for Silos output.	 */	protected String getSafeCellName(String name) { return name; }	/** Method to return the proper name of Power */	protected String getPowerName(Network net) { return ".VDD"; }	/** Method to return the proper name of Ground */	protected String getGroundName(Network net) { return ".GND"; }	/** Method to return the proper name of a Global signal */	protected String getGlobalName(Global glob) { return glob.getName(); }	/** Method to report that export names DO take precedence over	 * arc names when determining the name of the network. */	protected boolean isNetworksUseExportedNames() { return true; }	/** Method to report that library names ARE always prepended to cell names. */	protected boolean isLibraryNameAlwaysAddedToCellName() { return false; }	/** Method to report that aggregate names (busses) ARE used. */	protected boolean isAggregateNamesSupported() { return true; }	/** Abstract method to decide whether aggregate names (busses) can have gaps in their ranges. */	protected boolean isAggregateNameGapsSupported() { return false; }	/** Method to report whether input and output names are separated. */	protected boolean isSeparateInputAndOutput() { return true; }	/** Abstract method to decide whether netlister is case-sensitive (Verilog) or not (Spice). */	protected boolean isCaseSensitive() { return true; }	/**	 * Method to adjust a network name to be safe for Silos output.	 */	protected String getSafeNetName(String name, boolean bus) { return name; }    /** Tell the Hierarchy enumerator how to short resistors */    @Override    protected Netlist.ShortResistors getShortResistors() { return Netlist.ShortResistors.ALL; }	/**	 * Method to tell whether the topological analysis should mangle cell names that are parameterized.	 */	protected boolean canParameterizeNames() { return true; }}

⌨️ 快捷键说明

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