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

📄 equivrecord.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public Iterator<Circuit> getCircuits() {return circuits.iterator();}	public int numCircuits() {return circuits.size();}	public void addCircuit(Circuit c) {		circuits.add(c);		c.setParent(this);	}	/** say whether this leaf record contains Parts, Wires, or Ports.	 * A leaf record can only hold one kind of NetObject. 	 * @return PART, WIRE, or PORT */	public NetObject.Type getNetObjType() {		for (Iterator<Circuit> ci=getCircuits(); ci.hasNext();) {			Circuit c = ci.next();			Iterator<NetObject> ni = c.getNetObjs();			if (ni.hasNext()) {				NetObject no = ni.next();				return no.getNetObjType();			}		}		error(true, "no NetObjects in a leaf EquivRecord?");		return null; 	}	/** Get total number of NetObjects in all Circuits of a leaf record	 * @return number of NetObjects */	public int numNetObjs() {		int sum = 0;		for (Iterator<Circuit> ci=getCircuits(); ci.hasNext();) {			Circuit c = ci.next();			sum += c.numNetObjs();		}		return sum;	}	/** generates a String indicating the size of the	 * Circuits in this leaf record	 * @return the String */	public String sizeString() {	    if(numCircuits() == 0) return "0";	    String s= "";	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit jc= it.next();	        s= s + " " + jc.numNetObjs() ;	    }	    return s;	}	/** maxSizeDiff computes the difference in the number of	 * NetObjects in the Circuits of this leaf record.	 * @return an int with the difference, zero is good */	public int maxSizeDiff() {	    int out= 0;	    int max= maxSize();	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit j= it.next();	        int diff= max-j.numNetObjs();	        if(diff > out)out= diff;	    }	    return out;	}	/** maxSize returns the number of NetObjects in the most populous	 * Circuit.	 * @return an int with the maximum size of any Circuit in this	 * leaf record */	public int maxSize() {	    int out= 0;	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit j= it.next();;	        out = Math.max(out, j.numNetObjs());	    }	    return out;	}	/** isActive indicates that this leaf record is neither matched	 * nor mismatched.	 * @return true if this leaf record is still in play, false otherwise */	public boolean isActive() {	    error(numCircuits()==0, "leaf record with no circuits?");	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit c = it.next();	        if (c.numNetObjs()==0) return false; // mismatched	        if (c.numNetObjs()>1)  return true;  // live	    }	    return false;	}	/** @return true if all Circuits have same number of NetObjects. */	public boolean isBalanced() {		boolean first = true;		int sz = 0;	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit c = it.next();	        if (first) {	        	sz = c.numNetObjs();	        	first = false;	        } else {				if (c.numNetObjs()!=sz) return false;	        }	    }	    return true;	}	/** isMatched is a special case of balanced.	 * @return true if every Circuit has one NetObject */	public boolean isMatched() {		for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {			Circuit c = it.next();			if (c.numNetObjs()!=1) return false;		}		return true;	}	/** isMismatched is a special case of unbalanced. 	 * @return true if some Circuit has no NetObject */	public boolean isMismatched() {		// It's impossible for all Circuits to be zero sized so we only		// need to find the first zero sized.	    for (Iterator<Circuit> it=getCircuits(); it.hasNext();) {	        Circuit c = it.next();			if (c.numNetObjs()==0) return true;	    }	    return false;	}	/** get offspring of internal record */	public Iterator<EquivRecord> getOffspring() {return offspring.iterator();}	public int numOffspring() {return offspring.size();}	/** The apply method applies a Strategy to this leaf EquivRecord.  If the 	 * divides this Record then this leaf record becomes an internal record.	 * @param js the Strategy to apply	 * @return a LeafList of the resulting offspring */	public LeafList apply(Strategy js) {		return isLeaf() ? applyToLeaf(js) : applyToInternal(js);	}	/** nameString returns a String of type and name for this parent. 	 * @return a String identifying this EquivRecord. */	public String nameString() {		String name = "";		if (isLeaf()) {			name = isMatched() ? "Matched" : isMismatched() ? "Mismatched" : "Active";			name += " leaf";		} else {			name = "Internal";		}		name += " Record randCode="+randCode+" value="+value;		name += isLeaf() ? (			" maxSize="+maxSize()		) : (			" #offspring="+numOffspring()		);		return name;	}	public boolean isLeaf() {return offspring==null;} 	/** The fixed strategies annotate EquivRecords with comments	 * describing what characteristic made this EquivRecord unique.	 * This information is useful for providing pre-analysis information	 * to the user. */	public void setPartitionReason(String s) {partitionReason=s;}	public String getPartitionReason() {return partitionReason;}	public List<String> getPartitionReasonsFromRootToMe() {		if (wireSignature!=null) {			return wireSignature.getReasons();		} else {			LinkedList<String> reasons = new LinkedList<String>();			for (EquivRecord r=this; r!=null; r=r.getParent()) {				String reason = r.getPartitionReason();				if (reason!=null) reasons.addFirst(reason);			}			return reasons;		}	}	public void setWireSignature(NewLocalPartitionWires.Signature sig) {		wireSignature = sig;	}	/** Construct a leaf EquivRecord that holds circuits	 * @param ckts Circuits belonging to Equivalence Record	 * @param globals used for generating random numbers	 * @return the new EquivRecord */	public static EquivRecord newLeafRecord(int key, List<Circuit> ckts, NccGlobals globals) {		EquivRecord r = new EquivRecord();		r.circuits = new ArrayList<Circuit>();		r.value = key;		r.randCode = globals.getRandom();		for (Circuit ckt : ckts) {			r.addCircuit(ckt);		}		error(r.maxSize()==0, 			  "invalid leaf EquivRecord: all Circuits are empty");		return r;	}	/** Construct an internal EquivRecord that will serve as the root of the 	 * EquivRecord tree	 * @param offspring 	 * @return the new EquivRecord or null if there are no offspring */	public static EquivRecord newRootRecord(List<EquivRecord> offspring) {		if (offspring.size()==0) return null;		EquivRecord r = new EquivRecord();		r.offspring = new RecordList();		for (EquivRecord er : offspring) {			r.addOffspring(er);		}		return r;			}	/** Get all NetObjects contained by an EquivRecord subtree.	 * @param matched list of list of NetObjects from matched EquivRecords	 * indexed as: [circuitIndex][netObjectIndex]. NetObjects at the same	 * index in each list match.	 * @param notMatched list of list of NetObjects from not matched	 * EquivRecords indexed as [circuitIndex][netObjectIndex] */	public void getNetObjsFromEntireTree(List<List<NetObject>> matched,			                             List<List<NetObject>> notMatched) {		GetNetObjs gno = new GetNetObjs(this);		matched.clear();		matched.addAll(gno.getMatchedNetObjs());		notMatched.clear();		notMatched.addAll(gno.getNotMatchedNetObjs());	}	private List<List<NetObjReportable>> coerceToReportable(List<List<NetObject>> no) {		List<List<NetObjReportable>> nor = new ArrayList<List<NetObjReportable>>();		for (List<NetObject> i : no) {			List<NetObjReportable> j = new ArrayList<NetObjReportable>();			j.addAll(i);			nor.add(j);		}		return nor;	}	public void getNetObjReportablesFromEntireTree(									List<List<NetObjReportable>> matched,						            List<List<NetObjReportable>> notMatched) {		List<List<NetObject>> m = new ArrayList<List<NetObject>>();		List<List<NetObject>> nm = new ArrayList<List<NetObject>>();		getNetObjsFromEntireTree(m, nm);		matched.clear();		matched.addAll(coerceToReportable(m));				notMatched.clear();		notMatched.addAll(coerceToReportable(nm));	}}

⌨️ 快捷键说明

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