📄 simulation.java
字号:
} catch (Exception e) { System.out.println("Unable to run the IRSIM simulator"); e.printStackTrace(System.out); } } /** * Method to tell whether the FLEET simulator is available. * This method dynamically figures out whether the FLEET module is present by using reflection. * @return true if the FLEET simulator is available. */ public static boolean hasFLEET() { if (!fleetChecked) { fleetChecked = true; // find the FLEET class try { fleetClass = Class.forName("com.sunlabs.fleetsim.electricPlugin.FleetSimElectricPlugin"); } catch (ClassNotFoundException e) { fleetClass = null; return false; } // find the necessary methods on the FLEET class try { Method fleetMenuMethod = fleetClass.getMethod("fleetSimMenu", new Class[] {}); fleetSimMenu= (EMenu)(fleetMenuMethod.invoke(fleetClass, new Object[]{})); } catch (NoSuchMethodException e) { fleetClass = null; return false; } catch (Exception e) { System.out.println("Unable to get FleetSimMenu"); e.printStackTrace(System.out); } } // if already initialized, return if (fleetClass == null) return false; return true; } public static EMenu FLEETMenu() { return fleetSimMenu; } /** * Method to update the simulation (because some stimuli have changed). */ public static void update() { Engine engine = findEngine(); if (engine == null) return; engine.update(); } /** * Method to set the currently-selected signal high at the current time. */ public static void setSignalHigh() { Engine engine = findEngine(); if (engine == null) return; engine.setSignalHigh(); } /** * Method to set the currently-selected signal low at the current time. */ public static void setSignalLow() { Engine engine = findEngine(); if (engine == null) return; engine.setSignalLow(); } /** * Method to set the currently-selected signal undefined at the current time. */ public static void setSignalX() { Engine engine = findEngine(); if (engine == null) return; engine.setSignalX(); } public static void setClock() { Engine engine = findEngine(); if (engine == null) return; // prompt for clock information double period = ClockSpec.getClockSpec(); if (period <= 0) return; engine.setClock(period); } /** * Method to show information about the currently-selected signal. */ public static void showSignalInfo() { Engine engine = findEngine(); if (engine == null) return; engine.showSignalInfo(); } /** * Method to remove all stimuli from the currently-selected signal. */ public static void removeStimuliFromSignal() { Engine engine = findEngine(); if (engine == null) return; engine.removeStimuliFromSignal(); } /** * Method to remove the selected stimuli. */ public static void removeSelectedStimuli() { Engine engine = findEngine(); if (engine == null) return; engine.removeSelectedStimuli(); } /** * Method to remove all stimuli from the simulation. */ public static void removeAllStimuli() { Engine engine = findEngine(); if (engine == null) return; engine.removeAllStimuli(); } /** * Method to save the current stimuli information to disk. */ public static void saveStimuli() { Engine engine = findEngine(); if (engine == null) return; engine.saveStimuli(); } /** * Method to restore the current stimuli information from disk. */ public static void restoreStimuli() { Engine engine = findEngine(); if (engine == null) return; engine.restoreStimuli(); } /** * Method to locate the running simulation engine. * @return the Engine that is running. * Prints an error and returns null if there is none. */ private static Engine findEngine() { // find a simulation engine to control Engine engine = null; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); if (wf.getContent() instanceof WaveformWindow) { WaveformWindow ww = (WaveformWindow)wf.getContent(); Engine e = ww.getSimData().getEngine(); if (e == null) continue; if (wf == WindowFrame.getCurrentWindowFrame()) return e; engine = e; } } if (engine == null) System.out.println("No simulator is ready to handle the command"); return engine; } /****************************** MISCELLANEOUS CONTROLS ******************************/ /** * Method to set a Spice model on the selected node. */ public static void setSpiceModel() { UserInterface ui = Job.getUserInterface(); EditWindow_ wnd = ui.getCurrentEditWindow_(); if (wnd == null) return; NodeInst ni = (NodeInst)wnd.getOneElectricObject(NodeInst.class); if (ni == null) return; new SetSpiceModel(ni); } /** * Class to set a Spice Model in a new thread. */ private static class SetSpiceModel extends Job { private NodeInst ni; protected SetSpiceModel(NodeInst ni) { super("Set Spice Model", tool, Job.Type.CHANGE, null, null, Job.Priority.USER); this.ni = ni; startJob(); } public boolean doIt() throws JobException { ni.newDisplayVar(Spice.SPICE_MODEL_KEY, "SPICE-Model"); return true; } } /** * Method to set the type of the currently selected wires. * This is used by the Verilog netlister. * @param type 0 for wire; 1 for trireg; 2 for default. */ public static void setVerilogWireCommand(int type) { UserInterface ui = Job.getUserInterface(); EditWindow_ wnd = ui.getCurrentEditWindow_(); if (wnd == null) return; List<Geometric> list = wnd.getHighlightedEObjs(false, true); if (list.size() == 0) { System.out.println("Must select arcs before setting their type"); return; } new SetWireType(list, type); } /** * Class to set Verilog wire types in a new thread. */ private static class SetWireType extends Job { private List<Geometric> list; private int type; protected SetWireType(List<Geometric> list, int type) { super("Change Verilog Wire Types", tool, Job.Type.CHANGE, null, null, Job.Priority.USER); this.list = list; this.type = type; startJob(); } public boolean doIt() throws JobException { for(Geometric geom : list) { ArcInst ai = (ArcInst)geom; switch (type) { case 0: // set to "wire" ai.newDisplayVar(Verilog.WIRE_TYPE_KEY, "wire"); break; case 1: // set to "trireg" ai.newDisplayVar(Verilog.WIRE_TYPE_KEY, "trireg"); break; case 2: // set to default if (ai.getVar(Verilog.WIRE_TYPE_KEY) != null) ai.delVar(Verilog.WIRE_TYPE_KEY); break; } } return true; } } /** * Method to set the strength of the currently selected transistor. * This is used by the Verilog netlister. * @param weak true to set the currently selected transistor to be weak. * false to make it normal strength. */ public static void setTransistorStrengthCommand(boolean weak) { UserInterface ui = Job.getUserInterface(); EditWindow_ wnd = ui.getCurrentEditWindow_(); if (wnd == null) return; NodeInst ni = (NodeInst)wnd.getOneElectricObject(NodeInst.class); if (ni == null) return; new SetTransistorStrength(ni, weak); } /** * Class to set transistor strengths in a new thread. */ private static class SetTransistorStrength extends Job { private NodeInst ni; private boolean weak; protected SetTransistorStrength(NodeInst ni, boolean weak) { super("Change Transistor Strength", tool, Job.Type.CHANGE, null, null, Job.Priority.USER); this.ni = ni; this.weak = weak; startJob(); } public boolean doIt() throws JobException { if (weak) { ni.newDisplayVar(WEAK_NODE_KEY, "Weak"); } else { if (ni.getVar(WEAK_NODE_KEY) != null) ni.delVar(WEAK_NODE_KEY); } return true; } } /** * Method to display simulation data in a waveform window. * @param sd the simulation data to display. * @param ww the waveform window to load. * If null, create a new waveform window. */ public static void showSimulationData(Stimuli sd, WaveformWindow ww)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -