📄 spicetab.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: SpiceTab.java * * Copyright (c) 2004 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.user.dialogs.options;import com.sun.electric.database.text.TextUtils;import com.sun.electric.lib.LibFile;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.io.output.Spice;import com.sun.electric.tool.simulation.Simulation;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JOptionPane;import javax.swing.JPanel;/** * Class to handle the "Spice" tab of the Preferences dialog. */public class SpiceTab extends PreferencePanel{ private enum SpiceOutFormat { Standard, Raw, RawSmart, Epic; } /** Creates new form SpiceTab */ public SpiceTab(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(epicText); EDialog.makeTextFieldSelectAllOnTab(spiceRunProgram); EDialog.makeTextFieldSelectAllOnTab(spiceRunProgramArgs); EDialog.makeTextFieldSelectAllOnTab(useDir); EDialog.makeTextFieldSelectAllOnTab(spiceHeaderCardExtension); EDialog.makeTextFieldSelectAllOnTab(spiceHeaderCardFile); EDialog.makeTextFieldSelectAllOnTab(spiceTrailerCardExtension); EDialog.makeTextFieldSelectAllOnTab(spiceTrailerCardFile); EDialog.makeTextFieldSelectAllOnTab(spiceNetworkDelimiter); } /** return the panel to use for this preferences tab. */ public JPanel getPanel() { return spice; } /** return the name of this preferences tab. */ public String getName() { return "Spice"; } /** * Method called at the start of the dialog. * Caches current values and displays them in the Spice tab. */ public void init() { // the top section: writing spice decks spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_2); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_3); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_H); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_P); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_G); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_S); spiceEnginePopup.addItem(Simulation.SpiceEngine.SPICE_ENGINE_H_ASSURA); spiceEnginePopup.setSelectedItem(Simulation.getSpiceEngine()); spiceLevelPopup.addItem("1"); spiceLevelPopup.addItem("2"); spiceLevelPopup.addItem("3"); spiceLevelPopup.setSelectedItem(Simulation.getSpiceLevel()); spiceResistorShorting.addItem("None"); spiceResistorShorting.addItem("Normal only"); spiceResistorShorting.addItem("Normal and Poly"); spiceResistorShorting.setSelectedIndex(Simulation.getSpiceShortResistors()); spiceParasitics.addItem(Simulation.SpiceParasitics.SIMPLE); spiceParasitics.addItem(Simulation.SpiceParasitics.RC_CONSERVATIVE);// spiceParasitics.addItem(Simulation.SpiceParasitics.RC_PROXIMITY); spiceParasitics.setSelectedItem(Simulation.getSpiceParasiticsLevel()); spiceGlobalTreatment.addItem("No special treatment"); spiceGlobalTreatment.addItem("Use .GLOBAL block"); spiceGlobalTreatment.addItem("Create .SUBCKT ports"); spiceGlobalTreatment.setSelectedIndex(Simulation.getSpiceGlobalTreatment().getCode()); String [] libFiles = LibFile.getSpicePartsLibraries(); for(int i=0; i<libFiles.length; i++) spicePrimitivesetPopup.addItem(libFiles[i]); spicePrimitivesetPopup.setSelectedItem(Simulation.getSpicePartsLibrary()); spiceWritePwrGndSubcircuit.setSelected(Simulation.isSpiceWritePwrGndInTopCell()); spiceUseCellParameters.setSelected(Simulation.isSpiceUseCellParameters()); spiceWriteTransSizesInLambda.setSelected(Simulation.isSpiceWriteTransSizeInLambda()); spiceWriteSubcktTopCell.setSelected(Simulation.isSpiceWriteSubcktTopCell()); spiceWriteEndStatement.setSelected(Simulation.isSpiceWriteFinalDotEnd()); // bottom of the top section: header and trailer cards String spiceHeaderCardInitial = Simulation.getSpiceHeaderCardInfo(); boolean noHeader = false; if (spiceHeaderCardInitial.startsWith(Spice.SPICE_NOEXTENSION_PREFIX)) { noHeader = true; spiceHeaderCardInitial = spiceHeaderCardInitial.substring(Spice.SPICE_NOEXTENSION_PREFIX.length()); } if (spiceHeaderCardInitial.length() == 0) noHeader = true; if (spiceHeaderCardInitial.startsWith(Spice.SPICE_EXTENSION_PREFIX)) { spiceHeaderCardsWithExtension.setSelected(true); spiceHeaderCardExtension.setText(spiceHeaderCardInitial.substring(Spice.SPICE_EXTENSION_PREFIX.length())); } else { spiceHeaderCardsFromFile.setSelected(true); spiceHeaderCardFile.setText(spiceHeaderCardInitial); } if (noHeader) spiceNoHeaderCards.setSelected(true); String spiceTrailerCardInitial = Simulation.getSpiceTrailerCardInfo(); boolean noTrailer = false; if (spiceTrailerCardInitial.startsWith(Spice.SPICE_NOEXTENSION_PREFIX)) { noTrailer = true; spiceTrailerCardInitial = spiceTrailerCardInitial.substring(Spice.SPICE_NOEXTENSION_PREFIX.length()); } if (spiceTrailerCardInitial.length() == 0) noTrailer = true; if (spiceTrailerCardInitial.startsWith(Spice.SPICE_EXTENSION_PREFIX)) { spiceTrailerCardsWithExtension.setSelected(true); spiceTrailerCardExtension.setText(spiceTrailerCardInitial.substring(Spice.SPICE_EXTENSION_PREFIX.length())); } else { spiceTrailerCardsFromFile.setSelected(true); spiceTrailerCardFile.setText(spiceTrailerCardInitial); } if (noTrailer) spiceNoTrailerCards.setSelected(true); spiceBrowseHeaderFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { spiceBrowseHeaderFileActionPerformed(); } }); spiceBrowseTrailerFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { spiceBrowseTrailerFileActionPerformed(); } }); // the middle section: running Spice useDir.setText(Simulation.getSpiceRunDir()); useDirCheckBox.setSelected(Simulation.getSpiceUseRunDir()); overwriteOutputFile.setSelected(Simulation.getSpiceOutputOverwrite()); spiceRunProbe.setSelected(Simulation.getSpiceRunProbe()); spiceRunProgram.setText(Simulation.getSpiceRunProgram()); spiceRunProgramArgs.setText(Simulation.getSpiceRunProgramArgs()); String [] runChoices = Simulation.getSpiceRunChoiceValues(); for (int i=0; i<runChoices.length; i++) { spiceRunPopup.addItem(runChoices[i]); } spiceRunPopup.setSelectedItem(Simulation.getSpiceRunChoice()); if (spiceRunPopup.getSelectedIndex() == 0) setSpiceRunOptionsEnabled(false); else setSpiceRunOptionsEnabled(true); // the bottom section: reading spice output spiceOutputFormatPopup.addItem(SpiceOutFormat.Standard); spiceOutputFormatPopup.addItem(SpiceOutFormat.Raw); spiceOutputFormatPopup.addItem(SpiceOutFormat.RawSmart); spiceOutputFormatPopup.addItem(SpiceOutFormat.Epic); spiceOutputFormatPopup.setSelectedItem(SpiceOutFormat.valueOf(Simulation.getSpiceOutputFormat())); epicText.setText(String.valueOf(Simulation.getSpiceEpicMemorySize())); spiceNetworkDelimiter.setText(Simulation.getSpiceExtractedNetDelimiter()); } private void spiceBrowseTrailerFileActionPerformed() { String fileName = OpenFile.chooseInputFile(FileType.ANY, null); if (fileName == null) return; spiceTrailerCardFile.setText(fileName); spiceTrailerCardsFromFile.setSelected(true); } private void spiceBrowseHeaderFileActionPerformed() { String fileName = OpenFile.chooseInputFile(FileType.ANY, null); if (fileName == null) return; spiceHeaderCardFile.setText(fileName); spiceHeaderCardsFromFile.setSelected(true); } /** * Method called when the "OK" panel is hit. * Updates any changed fields in the Spice tab. */ public void term() { // the top section: writing spice deck Simulation.SpiceEngine engine = (Simulation.SpiceEngine)spiceEnginePopup.getSelectedItem(); if (Simulation.getSpiceEngine() != engine) Simulation.setSpiceEngine(engine); String stringNow = (String)spiceLevelPopup.getSelectedItem(); if (!Simulation.getSpiceLevel().equals(stringNow)) Simulation.setSpiceLevel(stringNow); int sr = spiceResistorShorting.getSelectedIndex(); if (sr != Simulation.getSpiceShortResistors()) Simulation.setSpiceShortResistors(sr); Simulation.SpiceParasitics sp = (Simulation.SpiceParasitics)spiceParasitics.getSelectedItem(); if (Simulation.getSpiceParasiticsLevel() != sp) Simulation.setSpiceParasiticsLevel(sp); Simulation.SpiceGlobal signal = Simulation.SpiceGlobal.find(spiceGlobalTreatment.getSelectedIndex()); if (Simulation.getSpiceGlobalTreatment() != signal) Simulation.setSpiceGlobalTreatment(signal); stringNow = (String)spicePrimitivesetPopup.getSelectedItem(); if (!Simulation.getSpicePartsLibrary().equals(stringNow)) Simulation.setSpicePartsLibrary(stringNow); boolean booleanNow = spiceWritePwrGndSubcircuit.isSelected(); if (Simulation.isSpiceWritePwrGndInTopCell() != booleanNow) Simulation.setSpiceWritePwrGndInTopCell(booleanNow); booleanNow = spiceUseCellParameters.isSelected(); if (Simulation.isSpiceUseCellParameters() != booleanNow) Simulation.setSpiceUseCellParameters(booleanNow); booleanNow = spiceWriteTransSizesInLambda.isSelected(); if (Simulation.isSpiceWriteTransSizeInLambda() != booleanNow) Simulation.setSpiceWriteTransSizeInLambda(booleanNow); booleanNow = spiceWriteSubcktTopCell.isSelected(); if (Simulation.isSpiceWriteSubcktTopCell() != booleanNow) Simulation.setSpiceWriteSubcktTopCell(booleanNow); booleanNow = spiceWriteEndStatement.isSelected(); if (Simulation.isSpiceWriteFinalDotEnd() != booleanNow) Simulation.setSpiceWriteFinalDotEnd(booleanNow); // bottom of the top section: header and trailer cards String header = Spice.SPICE_NOEXTENSION_PREFIX; if (spiceHeaderCardExtension.getText().length() > 0) header += Spice.SPICE_EXTENSION_PREFIX + spiceHeaderCardExtension.getText(); else header += spiceHeaderCardFile.getText(); if (spiceHeaderCardsWithExtension.isSelected()) { header = Spice.SPICE_EXTENSION_PREFIX + spiceHeaderCardExtension.getText(); } else if (spiceHeaderCardsFromFile.isSelected()) { header = spiceHeaderCardFile.getText(); } if (!Simulation.getSpiceHeaderCardInfo().equals(header)) Simulation.setSpiceHeaderCardInfo(header); String trailer = Spice.SPICE_NOEXTENSION_PREFIX; if (spiceTrailerCardExtension.getText().length() > 0) trailer += Spice.SPICE_EXTENSION_PREFIX + spiceTrailerCardExtension.getText(); else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -