?? hspiceout.java
字號:
/** * Method to find the ".sw" file and read DC data. * @param sd the Stimuli to add this DC data to. * @param fileURL the URL to the ".tr" file. * @throws IOException */ private void addDCData(Stimuli sd, List<PALine> paList, URL fileURL) throws IOException { // find the associated ".sw" name file URL swURL = null; try { swURL = new URL(fileURL.getProtocol(), fileURL.getHost(), fileURL.getPort(), fileBase + "." + swExtension); } catch (java.net.MalformedURLException e) {} if (swURL != null && TextUtils.URLExists(swURL)) { // process the DC data readTRDCACFile(sd, swURL, paList, Analysis.ANALYSIS_DC); return; } // no associated ".sw" file, look for an ".ic" name file URL icURL = null; try { icURL = new URL(fileURL.getProtocol(), fileURL.getHost(), fileURL.getPort(), fileBase + "." + icExtension); } catch (java.net.MalformedURLException e) {} if (icURL != null && TextUtils.URLExists(icURL)) { // can't process the DC data System.out.println("WARNING: Cannot read old DC format file (." + icExtension + ")...must provide new format (." + swExtension + "): " + fileBase + "." + icExtension); return; } } /** * Method to find the ".ac" file and read AC data. * @param sd the Stimuli to add this AC data to. * @param fileURL the URL to the ".tr" file. * @throws IOException */ private void addACData(Stimuli sd, List<PALine> paList, URL fileURL) throws IOException { // find the associated ".ac" name file URL acURL = null; try { acURL = new URL(fileURL.getProtocol(), fileURL.getHost(), fileURL.getPort(), fileBase + "." + acExtension); } catch (java.net.MalformedURLException e) {} if (acURL == null) return; if (!TextUtils.URLExists(acURL)) return; // process the AC data readTRDCACFile(sd, acURL, paList, Analysis.ANALYSIS_AC); } /** * Method to read the "pa" file with full symbol names. * These files can end in "0", "1", "2",... * @param fileURL the URL to the simulation output file * @return a list of PALine objects that describe the name mapping file entries. */ private List<PALine> readPAFile(URL fileURL) throws IOException { // find the associated ".pa" name file URL paURL = null; try { paURL = new URL(fileURL.getProtocol(), fileURL.getHost(), fileURL.getPort(), fileBase + "." + paExtension); } catch (java.net.MalformedURLException e) {} if (paURL == null) return null; if (!TextUtils.URLExists(paURL)) return null; if (openTextInput(paURL)) return null; List<PALine> paList = new ArrayList<PALine>(); for(;;) { // get line from file String nextLine = lineReader.readLine(); if (nextLine == null) break; // break into number and name String trimLine = nextLine.trim(); int spacePos = trimLine.indexOf(' '); if (spacePos > 0) { // save it in a PALine object PALine pl = new PALine(); pl.number = TextUtils.atoi(trimLine, 0, 10); pl.string = removeLeadingX(trimLine.substring(spacePos+1).trim()); paList.add(pl); } } closeInput(); return paList; } private void readTRDCACFile(Stimuli sd, URL fileURL, List<PALine> paList, Analysis.AnalysisType analysisType) throws IOException { if (openBinaryInput(fileURL)) return; eofReached = false; resetBinaryTRACDCReader(); SweepAnalysis an = new SweepAnalysis(sd, analysisType); startProgressDialog("HSpice " + analysisType.toString() + " analysis", fileURL.getFile()); System.out.println("Reading HSpice " + analysisType.toString() + " analysis '" + fileURL.getFile() + "'"); // get number of nodes int nodcnt = getHSpiceInt(); // get number of special items int numnoi = getHSpiceInt(); // get number of conditions int cndcnt = getHSpiceInt(); /* * Although this isn't documented anywhere, it appears that the 4th * number in the file is a multiplier for the first, which allows * there to be more than 10000 nodes. */ StringBuffer line = new StringBuffer(); for(int j=0; j<4; j++) line.append((char)getByteFromFile()); int multiplier = TextUtils.atoi(line.toString(), 0, 10); nodcnt += multiplier * 10000; int numSignals = numnoi + nodcnt - 1; if (numSignals <= 0) { System.out.println("Error reading " + fileURL.getFile()); closeInput(); stopProgressDialog(); return; } // get version number (known to work with 9007, 9601) int version = getHSpiceInt(); if (version != 9007 && version != 9601) System.out.println("Warning: may not be able to read HSpice files of type " + version); // ignore the unused/title information (4+72 characters over line break) line = new StringBuffer(); for(int j=0; j<76; j++) { int k = getByteFromFile(); line.append((char)k); if (!isTRACDCBinary && k == '\n') j--; } // ignore the date/time information (16 characters) line = new StringBuffer(); for(int j=0; j<16; j++) line.append((char)getByteFromFile()); // ignore the copywrite information (72 characters over line break) line = new StringBuffer(); for(int j=0; j<72; j++) { int k = getByteFromFile(); line.append((char)k); if (!isTRACDCBinary && k == '\n') j--; } // get number of sweeps int sweepcnt = getHSpiceInt(); if (DEBUGCONDITIONS) System.out.println("++++++++++++++++++++ VERSION="+version+" SWEEPCNT="+sweepcnt+" CNDCNT="+cndcnt+" NUMNOI="+numnoi+" MULTIPLIER="+multiplier); if (cndcnt == 0) sweepcnt = 0; // ignore the Monte Carlo information (76 characters over line break) line = new StringBuffer(); for(int j=0; j<76; j++) { int k = getByteFromFile(); line.append((char)k); if (!isTRACDCBinary && k == '\n') j--; } // get the type of each signal String [] signalNames = new String[numSignals]; int [] signalTypes = new int[numSignals]; for(int k=0; k<=numSignals; k++) { line = new StringBuffer(); for(int j=0; j<8; j++) { int l = getByteFromFile(); line.append((char)l); if (!isTRACDCBinary && l == '\n') j--; } if (k == 0) continue; int l = k - nodcnt; if (k < nodcnt) l = k + numnoi - 1; String lineStr = line.toString().trim(); signalTypes[l] = TextUtils.atoi(lineStr, 0, 10); } boolean paMissingWarned = false; for(int k=0; k<=numSignals; k++) { line = new StringBuffer(); for(;;) { int l = getByteFromFile(); if (l == '\n') continue; if (l == ' ') { if (line.length() != 0) break; // if name starts with blank, skip until non-blank for(;;) { l = getByteFromFile(); if (l != ' ') break; } } line.append((char)l); if (version == 9007 && line.length() >= 16) break; } int j = line.length(); int l = (j+16) / 16 * 16 - 1; if (version == 9007) { l = (j+15) / 16 * 16 - 1; } for(; j<l; j++) { int i = getByteFromFile(); if (!isTRACDCBinary && i == '\n') { j--; continue; } } if (k == 0) continue; // convert name if there is a colon in it int startPos = 0; int openPos = line.indexOf("("); if (openPos >= 0) startPos = openPos+1; for(j=startPos; j<line.length(); j++) { if (line.charAt(j) == ':') break; if (!TextUtils.isDigit(line.charAt(j))) break; } if (j < line.length() && line.charAt(j) == ':') { l = TextUtils.atoi(line.toString().substring(startPos), 0, 10); PALine foundPALine = null; if (paList == null) { if (!paMissingWarned) System.out.println("Warning: there should be a ." + paExtension + " file with extra signal names"); paMissingWarned = true; } else { for(PALine paLine : paList) { if (paLine.number == l) { foundPALine = paLine; break; } } } if (foundPALine != null) { StringBuffer newSB = new StringBuffer(); newSB.append(line.substring(0, startPos)); newSB.append(foundPALine.string); newSB.append(line.substring(j+1)); line = newSB; } } else { if (line.indexOf(".") >= 0) { String fixedLine = removeLeadingX(line.toString()); line = new StringBuffer(); line.append(fixedLine); } } // move parenthesis from the start to the last name openPos = line.indexOf("("); if (openPos >= 0) { String parenPrefix = line.substring(0, openPos+1); int lastDot = line.lastIndexOf("."); if (lastDot >= 0) { StringBuffer newSB = new StringBuffer(); if (parenPrefix.equalsIgnoreCase("v(")) { // just ignore the V() newSB.append(line.substring(openPos+1, lastDot+1)); newSB.append(line.substring(lastDot+1, line.length()-1)); } else { // move the parenthetical wrapper to the last dotted piece newSB.append(line.substring(openPos+1, lastDot+1)); newSB.append(parenPrefix); newSB.append(line.substring(lastDot+1)); } line = newSB; } else if (parenPrefix.equalsIgnoreCase("v(")) { StringBuffer newSB = new StringBuffer(); // just ignore the V() newSB.append(line.substring(openPos+1, line.length()-1)); line = newSB; } } if (k < nodcnt) l = k + numnoi - 1; else l = k - nodcnt; signalNames[l] = line.toString(); } // read (and ignore) condition information for(int c=0; c<cndcnt; c++) { int j = 0; line = new StringBuffer(); for(;;) { int l = getByteFromFile(); if (l == '\n') continue; if (l == ' ') break; line.append((char)l); j++; if (j >= 16) break; } int l = (j+15) / 16 * 16 - 1; for(; j<l; j++) { int i = getByteFromFile(); if (!isTRACDCBinary && i == '\n') { j--; continue; } } if (DEBUGCONDITIONS) System.out.println("CONDITION "+(c+1)+" IS "+line.toString()); } // read the end-of-header marker line = new StringBuffer(); if (!isTRACDCBinary) { // finish line, ensure the end-of-header for(int j=0; ; j++) { int l = getByteFromFile(); if (l == '\n') break; if (j < 4) line.append(l); } } else { // gather end-of-header string
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -