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

📄 librarystatistics.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                System.out.println("    " + fc.getFileName() + " " + fc.fileLength + " " + fc.localCells.size() + " " + fc.externalCells.size());                for (String localName: fc.localCells)                    System.out.println("\t" + localName);                for (ExternalCell extCell: fc.externalCells)                    System.out.println("\t" + extCell.libPath + " " + extCell.libName + " " + extCell.cellName);			}		}    }//	public void reportMemoryUsage()//	{//		int elibCount = 0;//		int elibWithHeader = 0;//		int elibOk = 0;////		int toolCount = 0;//		int techCount = 0;//		int primNodeProtoCount = 0;//		int primPortProtoCount = 0;//		int arcProtoCount = 0;//		int nodeProtoCount = 0;//		int nodeInstCount = 0;//		int portProtoCount = 0;//		int arcInstCount = 0;//		int geomCount = 0;//		int cellCount = 0;//		int userBits = 0;//		int viewCount = 0;//		long nameLength = 0;////		int varNameCount = 0;//		long varNameLength = 0;////		long bytesRead = 0;//		long fileLength = 0;////		for (Iterator lit = getLibraryNames(); lit.hasNext(); )//		{//			LibraryName libraryName = (LibraryName)lit.next();//			for (Iterator it = libraryName.getVersions(); it.hasNext(); )//			{//				FileContents fc = (FileContents)it.next();//				if (!fc.isElib()) continue;//				elibCount++;//				if (fc.header == null) continue;//				elibWithHeader++;//				if (!fc.readOk) continue;//				elibOk++;//				toolCount += fc.toolCount;//				techCount += fc.techCount;//				primNodeProtoCount += fc.primNodeProtoCount;//				primPortProtoCount += fc.primPortProtoCount;//				arcProtoCount += fc.arcProtoCount;//				nodeProtoCount += fc.nodeProtoCount;//				nodeInstCount += fc.nodeInstCount;//				portProtoCount += fc.portProtoCount;//				arcInstCount += fc.arcInstCount;//				geomCount += fc.geomCount;//				cellCount += fc.cellCount;//				userBits |= fc.userBits;//				viewCount += fc.viewCount;//				nameLength += fc.nameLength;//				varNameCount += fc.varNameCount;//				varNameLength += fc.varNameLength;//				bytesRead += fc.bytesRead;//				fileLength += fc.fileLength;//			}//		}//		System.out.println("elibCount=" + elibCount);//		System.out.println("elibWithHeader=" + elibWithHeader);//		System.out.println("elibOk=" + elibOk);////		System.out.println("toolCount=" + toolCount);//		System.out.println("techCount=" + techCount);//		System.out.println("primNodeProtoCount=" + primNodeProtoCount);//		System.out.println("primPortProtoCount=" + primPortProtoCount);//		System.out.println("arcProtoCount=" + arcProtoCount);//		System.out.println("nodeProtoCount=" + nodeProtoCount);//		System.out.println("nodeInstCount=" + nodeInstCount);//		System.out.println("portProtoCount=" + portProtoCount);//		System.out.println("arcInstCount=" + arcInstCount);//		System.out.println("geomCount=" + geomCount);//		System.out.println("cellCount=" + cellCount);//		System.out.println("userBits=" + userBits);//		System.out.println("viewCount=" + viewCount);//		System.out.println("nameLength=" + nameLength);////		System.out.println("varNameCount=" + varNameCount);//		System.out.println("varNameLength=" + varNameLength);////		System.out.println("bytesRead=" + bytesRead);//		System.out.println("fileLength=" + fileLength);//	}////	public void reportJelib(String fileName)//	{//		if (totalLibraryContents == null) return;//		try//		{//			new StatisticsOutputJelib(fileName);//		} catch (IOException e)//		{//			System.out.println("Error storing LibraryStatisticsJelib to " + fileName + " " + e);//		}//	}////	public void reportVariableNames(String fileName)//	{//		if (totalLibraryContents == null) return;//		try//		{//			new StatisticsOutputVariableNames(fileName);//		} catch (IOException e)//		{//			System.out.println("Error storing LibraryStatisticsVariableNames to " + fileName + " " + e);//		}//	}	public static VarStat readVariableNames(String fileName)	{		URL fileURL = TextUtils.makeURLToFile(fileName);		try		{			StatisticsInputVariableNames in = new StatisticsInputVariableNames(fileURL);			long totalVars = 0;			long[] typeCounts = new long[32];			long[] typeTotals = new long[32];			TreeMap charCount = new TreeMap();			TreeMap charTotal = new TreeMap();			TreeMap bitsCount = new TreeMap();			TreeMap bitsTotal = new TreeMap();			for (Iterator it = in.vs.varBag.values().iterator(); it.hasNext(); )			{				VarDesc vd = (VarDesc)it.next();				Character character = new Character(vd.role.charAt(0));				GenMath.addToBag(charCount, character);				GenMath.addToBag(charTotal, character, vd.count);				VarDesc vd1 = new VarDesc();				vd1.role = "";				vd1.varName = "";				if (Character.isUpperCase(vd.role.charAt(0)))					vd1.varBits = vd.varBits & ~ELIBConstants.VLENGTH;				else					vd1.varBits = 0104;				vd1.td0 = vd.td0;				vd1.td1 = vd.td1;				GenMath.addToBag(bitsCount, vd1);				GenMath.addToBag(bitsTotal, vd1, vd.count);				totalVars += vd.count;				typeCounts[vd.varBits&0x1F] ++;				typeTotals[vd.varBits&0x1F] += vd.count;				if ((vd.varBits&0x1F) == 7) System.out.println("VNODEINST" + " " + vd.role + " " + vd.varName);				if ((vd.varBits&0x1F) == 8) System.out.println("VNODEPROTO" + " " + vd.role + " " + vd.varName);				if ((vd.varBits&(ELIBConstants.VCODE1|ELIBConstants.VCODE2)) != 0)					System.out.println(Integer.toOctalString(vd.varBits) + " " + vd.role + " " + vd.varName);			}			System.out.println(in.vs.varBag.size() + " bag: " + bagReport(charCount));			System.out.println(totalVars +  "bagTotal: " + bagReport(charTotal));			for (int i = 0; i < 32; i++)			{				System.out.println(Integer.toOctalString(i) + " " + typeCounts[i] + " "  + typeTotals[i]);			}			for (Iterator it = bitsCount.entrySet().iterator(); it.hasNext(); )			{				Map.Entry entry = (Map.Entry)it.next();				VarDesc vd = (VarDesc)entry.getKey();				System.out.println(vd.role + " " + Integer.toOctalString(vd.varBits) +								   " " + Integer.toOctalString(vd.td0) + " " + Integer.toOctalString(vd.td1) +								   " " + GenMath.countInBag(bitsCount, vd) + " "  + GenMath.countInBag(bitsTotal, vd));			}			System.out.println(bitsCount.size() + " variable descriptors");			return in.vs;		} catch (IOException e)		{			System.out.println("Error loading LibraryStatistics from " + fileName + " " + e);		}		return null;	}	private static String stripBackup(String libName)	{		int i = libName.length();		while (i > 0 && Character.isDigit(libName.charAt(i - 1))) i--;		if (i == libName.length()) return libName;		if (i > 3 && libName.charAt(i - 1) == '-' && libName.charAt(i - 2) == '-' &&			Character.isDigit(libName.charAt(i - 3)))		{			i -= 3;			while (i > 0 && Character.isDigit(libName.charAt(i - 1))) i--;		}		if (i < 2 || libName.charAt(i - 1) != '-' ||			!Character.isDigit(libName.charAt(i - 2))) return libName;		i -= 2;		while (i > 0 && Character.isDigit(libName.charAt(i - 1))) i--;		if (i < 2 || libName.charAt(i - 1) != '-' ||			!Character.isDigit(libName.charAt(i - 2))) return libName;		i -= 2;		while (i > 0 && Character.isDigit(libName.charAt(i - 1))) i--;		if (i < 1 || libName.charAt(i - 1) != '-') return libName;		return libName.substring(0, i - 1);	}	static <T> String bagReport(Map<T,GenMath.MutableInteger> bag)	{		String s = "";		for (Iterator<Map.Entry<T,GenMath.MutableInteger>> it = bag.entrySet().iterator(); it.hasNext(); )		{			Map.Entry<T,GenMath.MutableInteger> e = it.next();			GenMath.MutableInteger count = e.getValue();			s += " " + e.getKey() + ":" + count.intValue();		}		return s;	}	/**** Internal Classes */	private static class Directory implements Serializable	{		private static final long serialVersionUID = -8627329891776990655L;		private String dirName;		private TreeMap<String,FileInstance> files = new TreeMap<String,FileInstance>();		Directory(LibraryStatistics stat, String dirName)		{			this.dirName = dirName;			stat.directories.put(dirName, this);		}		String getName() { return dirName; }		Iterator<FileInstance> getFiles() { return files.values().iterator(); }	}	private static class LibraryName implements Serializable	{        final LibraryStatistics stat;		final String name;		final List<FileContents> versions = new ArrayList<FileContents>();		TreeMap<String,LibraryUse> references;		LibraryName(LibraryStatistics stat, String name)		{            this.stat = stat;			this.name = name;			stat.libraryNames.put(name, this);		}        LibId getLibId() {            String libName = name;            int indexOfColon = libName.indexOf(':');            if (indexOfColon >= 0)                libName = libName.substring(0, indexOfColon);            return stat.idManager.newLibId(LibId.legalLibraryName(libName));        }		String getName() { return name; }		Iterator<FileContents> getVersions() { return versions.iterator(); }	}	private static class LibraryUse implements Serializable	{		Directory dir;		LibraryName libName;		String fullName;		FileContents from;	}    static class ExternalCell implements Serializable {        final String libPath;        final String libName;        final String cellName;        ExternalCell(String libPath, String libName, String cellName) {            this.libPath = libPath;            this.libName = libName;            this.cellName = cellName;        }    }	static class FileContents implements Serializable	{        private static final long serialVersionUID = 8673043477742718970L;		LibraryName libraryName;		long fileLength;		long crc;		long lastModified;		List<FileInstance> instances = new ArrayList<FileInstance>();		TreeMap<String,LibraryUse> uses = new TreeMap<String,LibraryUse>();		ELIB.Header header;        Version version;        List<String> localCells = new ArrayList<String>();        List<ExternalCell> externalCells = new ArrayList<ExternalCell>();		boolean readOk;		int toolCount;		int techCount;		int primNodeProtoCount;		int primPortProtoCount;		int arcProtoCount;		int nodeProtoCount;		int nodeInstCount;		int portProtoCount;		int arcInstCount;		int geomCount;		int cellCount;		int userBits;		int viewCount;		int nameLength;		int varNameCount;		int varNameLength;		int bytesRead;		private FileContents(LibraryName libraryName, FileInstance f)		{			this.libraryName = libraryName;			libraryName.versions.add(this);			fileLength = f.fileLength;			crc = f.crc;			lastModified = f.lastModified;			f.contents = this;			instances.add(f);		}		void add(FileInstance f)		{			assert f.fileLength == fileLength && f.crc == crc;			f.contents = this;			instances.add(f);			if (f.lastModified < lastModified) lastModified = f.lastModified;		}		Iterator<URL> fileUrl() {            ArrayList<URL> urls = new ArrayList<URL>();            for (FileInstance instance: instances)                urls.add(instance.getUrl());            return urls.iterator();        }        IdManager idManager() { return libraryName.stat.idManager; }		boolean isElib() { return instances.get(0).fileName.endsWith(".elib"); }        String getFileName() { return instances.get(0).fileName; }	}	private static class FileInstance implements Comparable, Serializable	{		private static final long serialVersionUID = -5726569346410497467L;		private FileContents contents;		private String fileName;        private final File file;		private long fileLength;		private long crc;		private long lastModified;		transient String canonicalPath;		private FileInstance(LibraryStatistics stat, String fileName, long fileLength, long lastModified, long crc)            throws IOException        {			file = new File(fileName);			this.fileName = fileName;			this.fileLength = fileLength;			this.lastModified = lastModified;			this.crc = crc;//			File file = new File(fileName);			stat.getDirectory(file.getParent()).files.put(file.getName(), this);		}		FileInstance(LibraryStatistics stat, String fileName)			throws IOException		{			file = new File(fileName);			this.fileName = fileName;			canonicalPath = file.getCanonicalPath();			fileLength = file.length();			lastModified = file.lastModified();			Input in = new Input();			try

⌨️ 快捷键说明

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