KiCad PCB EDA Suite
|
#include <ngspice.h>
Classes | |
class | NGSPICE_LOCK_REALLOC |
Execute commands from a file. More... | |
Public Member Functions | |
NGSPICE () | |
virtual | ~NGSPICE () |
void | Init (const SPICE_SETTINGS *aSettings=nullptr) override final |
Point out the model that will be used in future simulations. | |
bool | Attach (const std::shared_ptr< SIMULATION_MODEL > &aModel, const wxString &aSimCommand, unsigned aSimOptions, const wxString &aInputPath, REPORTER &aReporter) override final |
Load a netlist for the simulation. | |
bool | LoadNetlist (const std::string &aNetlist) override final |
Execute the simulation with currently loaded netlist. | |
bool | Run () override final |
Halt the simulation. | |
bool | Stop () override final |
Check if simulation is running at the moment. | |
bool | IsRunning () override final |
Execute a Spice command as if it was typed into console. | |
bool | Command (const std::string &aCmd) override final |
Set a SIMULATOR_REPORTER object to receive the simulation log. | |
wxString | GetXAxis (SIM_TYPE aType) const override final |
wxString | CurrentPlotName () const override final |
std::vector< std::string > | AllVectors () const override final |
Return a requested vector with complex values. | |
std::vector< COMPLEX > | GetComplexVector (const std::string &aName, int aMaxLen=-1) override final |
Return a requested vector with real values. | |
std::vector< double > | GetRealVector (const std::string &aName, int aMaxLen=-1) override final |
Return a requested vector with imaginary values. | |
std::vector< double > | GetImaginaryVector (const std::string &aName, int aMaxLen=-1) override final |
Return a requested vector with magnitude values. | |
std::vector< double > | GetGainVector (const std::string &aName, int aMaxLen=-1) override final |
Return a requested vector with phase values. | |
std::vector< double > | GetPhaseVector (const std::string &aName, int aMaxLen=-1) override final |
Return a requested vector with phase values. | |
std::vector< std::string > | GetSettingCommands () const override final |
Return current SPICE netlist used by the simulator. | |
virtual const std::string | GetNetlist () const override final |
Cleans simulation data (i.e. | |
void | Clean () override final |
Cleans simulation data (i.e. | |
virtual void | SetReporter (SIMULATOR_REPORTER *aReporter) |
std::shared_ptr< SPICE_SETTINGS > & | Settings () |
Return the simulator configuration settings. | |
const std::shared_ptr< SPICE_SETTINGS > & | Settings () const |
std::mutex & | GetMutex () |
Static Public Member Functions | |
static wxString | TypeToName (SIM_TYPE aType, bool aShortName) |
Return a string with simulation name based on enum. | |
static std::shared_ptr< SPICE_SIMULATOR > | CreateInstance (const std::string &aName) |
Protected Attributes | |
SIMULATOR_REPORTER * | m_reporter |
< Reporter object to receive simulation log. | |
std::shared_ptr< SPICE_SETTINGS > | m_settings |
std::shared_ptr< SIMULATION_MODEL > | m_simModel |
< Model that should be simulated. | |
Private Types | |
typedef void(* | ngSpice_Init) (SendChar *, SendStat *, ControlledExit *, SendData *, SendInitData *, BGThreadRunning *, void *) |
typedef int(* | ngSpice_Circ) (char **circarray) |
typedef int(* | ngSpice_Command) (char *command) |
typedef pvector_info(* | ngGet_Vec_Info) (char *vecname) |
typedef char *(* | ngCM_Input_Path) (const char *path) |
typedef char *(* | ngSpice_CurPlot) (void) |
typedef char **(* | ngSpice_AllPlots) (void) |
typedef char **(* | ngSpice_AllVecs) (char *plotname) |
typedef bool(* | ngSpice_Running) (void) |
typedef int(* | ngSpice_LockRealloc) (void) |
typedef int(* | ngSpice_UnlockRealloc) (void) |
Handle to DLL functions. | |
Private Member Functions | |
void | init_dll () |
bool | loadSpinit (const std::string &aFileName) |
void | updateNgspiceSettings () |
Check a few different locations for codemodel files and returns one if it exists. | |
std::string | findCmPath () const |
Send additional search path for codemodels to ngspice. | |
bool | setCodemodelsInputPath (const std::string &aPath) |
Load codemodel files from a directory. | |
bool | loadCodemodels (const std::string &aPath) |
void | validate () |
Static Private Member Functions | |
static int | cbSendChar (char *what, int aId, void *aUser) |
static int | cbSendStat (char *what, int aId, void *aUser) |
static int | cbBGThreadRunning (NG_BOOL aFinished, int aId, void *aUser) |
static int | cbControlledExit (int aStatus, NG_BOOL aImmediate, NG_BOOL aExitOnQuit, int aId, void *aUser) |
Private Attributes | |
ngSpice_Init | m_ngSpice_Init |
ngSpice_Circ | m_ngSpice_Circ |
ngSpice_Command | m_ngSpice_Command |
ngGet_Vec_Info | m_ngGet_Vec_Info |
ngCM_Input_Path | m_ngCM_Input_Path |
ngSpice_CurPlot | m_ngSpice_CurPlot |
ngSpice_AllPlots | m_ngSpice_AllPlots |
ngSpice_AllVecs | m_ngSpice_AllVecs |
ngSpice_Running | m_ngSpice_Running |
ngSpice_LockRealloc | m_ngSpice_LockRealloc |
ngSpice_UnlockRealloc | m_ngSpice_UnlockRealloc |
wxDynamicLibrary | m_dll |
bool | m_error |
Error flag indicating that ngspice needs to be reloaded. | |
std::string | m_netlist |
Current netlist. | |
std::mutex | m_mutex |
< For interprocess synchronisation. | |
Static Private Attributes | |
static bool | m_initialized = false |
Ngspice should be initialized only once. | |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
NGSPICE::NGSPICE | ( | ) |
Definition at line 58 of file ngspice.cpp.
References init_dll().
|
virtualdefault |
|
finaloverridevirtual |
Return a requested vector with complex values.
If the vector is real, then the imaginary part is set to 0 in all values.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 102 of file ngspice.cpp.
References m_ngSpice_AllVecs, m_ngSpice_CurPlot, and plot.
Referenced by GetXAxis().
|
finaloverridevirtual |
Load a netlist for the simulation.
Reimplemented from SIMULATOR.
Definition at line 278 of file ngspice.cpp.
References SIMULATOR::Attach(), Command(), SPICE_CIRCUIT_MODEL::GetNetlist(), STRING_FORMATTER::GetString(), LoadNetlist(), NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS, setCodemodelsInputPath(), and updateNgspiceSettings().
|
staticprivate |
Definition at line 699 of file ngspice.cpp.
References SPICE_SIMULATOR::m_reporter, SIMULATOR_REPORTER::OnSimStateChange(), SIM_IDLE, and SIM_RUNNING.
Referenced by init_dll().
|
staticprivate |
Definition at line 673 of file ngspice.cpp.
References SPICE_SIMULATOR::m_reporter, and REPORTER::Report().
Referenced by init_dll().
|
staticprivate |
Definition at line 693 of file ngspice.cpp.
Referenced by init_dll().
|
finaloverridevirtual |
Cleans simulation data (i.e.
all vectors)
Implements SIMULATOR.
Definition at line 731 of file ngspice.cpp.
References Command().
|
finaloverridevirtual |
Set a SIMULATOR_REPORTER object to receive the simulation log.
Implements SPICE_SIMULATOR.
Definition at line 356 of file ngspice.cpp.
References m_ngSpice_Command, and validate().
Referenced by Attach(), Clean(), TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists(), Init(), init_dll(), loadCodemodels(), LoadNetlist(), loadSpinit(), Run(), Stop(), and updateNgspiceSettings().
|
staticinherited |
Definition at line 33 of file spice_simulator.cpp.
References DisplayError().
Referenced by KIBIS_PIN::getKuKdFromFile(), and SIMULATOR_FRAME::SIMULATOR_FRAME().
|
finaloverridevirtual |
Implements SPICE_SIMULATOR.
Definition at line 96 of file ngspice.cpp.
References m_ngSpice_CurPlot.
|
private |
Send additional search path for codemodels to ngspice.
Definition at line 614 of file ngspice.cpp.
References path, and traceNgspice.
Referenced by init_dll().
|
finaloverridevirtual |
Return a requested vector with real values.
If the vector is complex, then the real part is returned.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 130 of file ngspice.cpp.
References m_ngGet_Vec_Info.
|
finaloverridevirtual |
Return a requested vector with phase values.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 218 of file ngspice.cpp.
References m_ngGet_Vec_Info.
Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::TestPoint().
|
finaloverridevirtual |
Return a requested vector with magnitude values.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 193 of file ngspice.cpp.
References m_ngGet_Vec_Info.
|
inlineinherited |
Definition at line 51 of file simulator.h.
References SIMULATOR::m_mutex.
|
finaloverridevirtual |
Cleans simulation data (i.e.
all vectors)
Implements SPICE_SIMULATOR.
Definition at line 417 of file ngspice.cpp.
References m_netlist.
|
finaloverridevirtual |
Return a requested vector with phase values.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 248 of file ngspice.cpp.
References m_ngGet_Vec_Info.
|
finaloverridevirtual |
Return a requested vector with imaginary values.
If the vector is complex, then the imaginary part is returned. If the vector is reql, then only zeroes are returned.
aName | is the vector named in Spice convention (e.g. V(3), I(R1)). |
aMaxLen | is max count of returned values. if -1 (default) all available values are returned. |
Implements SPICE_SIMULATOR.
Definition at line 160 of file ngspice.cpp.
References m_ngGet_Vec_Info.
Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::TestOpPoint(), and TEST_NETLIST_EXPORTER_SPICE_FIXTURE::TestPoint().
|
finaloverridevirtual |
Return current SPICE netlist used by the simulator.
Implements SPICE_SIMULATOR.
Definition at line 393 of file ngspice.cpp.
References NGSPICE_SETTINGS::GetCompatibilityMode(), and SPICE_SIMULATOR::Settings().
Referenced by updateNgspiceSettings().
|
finaloverridevirtual |
Implements SPICE_SIMULATOR.
Definition at line 364 of file ngspice.cpp.
References AllVectors(), ST_AC, ST_DC, ST_FFT, ST_NOISE, ST_SP, and ST_TRAN.
|
finaloverridevirtual |
Point out the model that will be used in future simulations.
Implements SPICE_SIMULATOR.
Definition at line 89 of file ngspice.cpp.
References Command(), and updateNgspiceSettings().
|
private |
Definition at line 423 of file ngspice.cpp.
References cbBGThreadRunning(), cbControlledExit(), cbSendChar(), cbSendStat(), Command(), findCmPath(), loadCodemodels(), loadSpinit(), m_dll, m_error, m_initialized, m_ngCM_Input_Path, m_ngGet_Vec_Info, m_ngSpice_AllPlots, m_ngSpice_AllVecs, m_ngSpice_Circ, m_ngSpice_Command, m_ngSpice_CurPlot, m_ngSpice_Init, m_ngSpice_LockRealloc, m_ngSpice_Running, m_ngSpice_UnlockRealloc, path, and traceNgspice.
Referenced by NGSPICE(), and validate().
|
finaloverridevirtual |
Execute a Spice command as if it was typed into console.
aCmd | is the command to be issued. Return X axis name for a given simulation type |
Implements SIMULATOR.
Definition at line 349 of file ngspice.cpp.
References m_ngSpice_Running.
Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists().
|
private |
|
finaloverridevirtual |
Execute the simulation with currently loaded netlist.
Implements SPICE_SIMULATOR.
Definition at line 308 of file ngspice.cpp.
References Command(), m_netlist, and m_ngSpice_Circ.
Referenced by Attach(), and TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists().
|
private |
|
finaloverridevirtual |
Halt the simulation.
Implements SIMULATOR.
Definition at line 335 of file ngspice.cpp.
References Command().
Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists().
|
private |
Load codemodel files from a directory.
Definition at line 648 of file ngspice.cpp.
References m_ngCM_Input_Path.
Referenced by Attach().
|
inlinevirtualinherited |
Definition at line 84 of file spice_simulator.h.
References SPICE_SIMULATOR::m_reporter.
Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists().
|
inlineinherited |
Return the simulator configuration settings.
Definition at line 169 of file spice_simulator.h.
References SPICE_SIMULATOR::m_settings.
Referenced by GetSettingCommands().
|
inlineinherited |
Definition at line 171 of file spice_simulator.h.
References SPICE_SIMULATOR::m_settings.
|
finaloverridevirtual |
Check if simulation is running at the moment.
Implements SIMULATOR.
Definition at line 342 of file ngspice.cpp.
References Command().
|
staticinherited |
Return a string with simulation name based on enum.
aType | is the enum describing simulation type |
aShortName | if true - return is in format "TRAN", "OP". if false - return is in format "Transient", "Operating Point". |
Definition at line 53 of file spice_simulator.cpp.
References _, ST_AC, ST_DC, ST_DISTO, ST_FFT, ST_NOISE, ST_OP, ST_PZ, ST_SENS, ST_SP, ST_TF, ST_TRAN, and ST_UNKNOWN.
Referenced by DIALOG_SIM_COMMAND::OnCommandType(), DIALOG_SIM_COMMAND::parseCommand(), and SIMULATOR_FRAME_UI::SaveWorkbook().
|
private |
Check a few different locations for codemodel files and returns one if it exists.
Definition at line 79 of file ngspice.cpp.
References Command(), GetSettingCommands(), and traceNgspice.
|
private |
Definition at line 721 of file ngspice.cpp.
References init_dll(), m_error, and m_initialized.
Referenced by Command().
|
private |
Definition at line 145 of file ngspice.h.
Referenced by init_dll().
|
private |
Error flag indicating that ngspice needs to be reloaded.
Definition at line 192 of file ngspice.h.
Referenced by cbControlledExit(), init_dll(), and validate().
|
staticprivate |
Ngspice should be initialized only once.
Definition at line 194 of file ngspice.h.
Referenced by init_dll(), and validate().
|
privateinherited |
< For interprocess synchronisation.
Definition at line 102 of file simulator.h.
Referenced by SIMULATOR::GetMutex().
|
private |
Current netlist.
Definition at line 196 of file ngspice.h.
Referenced by GetNetlist(), and LoadNetlist().
|
private |
Definition at line 137 of file ngspice.h.
Referenced by init_dll(), and setCodemodelsInputPath().
|
private |
Definition at line 136 of file ngspice.h.
Referenced by GetComplexVector(), GetGainVector(), GetImaginaryVector(), GetPhaseVector(), GetRealVector(), and init_dll().
|
private |
Definition at line 139 of file ngspice.h.
Referenced by init_dll().
|
private |
Definition at line 140 of file ngspice.h.
Referenced by AllVectors(), and init_dll().
|
private |
Definition at line 134 of file ngspice.h.
Referenced by init_dll(), and LoadNetlist().
|
private |
Definition at line 135 of file ngspice.h.
Referenced by Command(), and init_dll().
|
private |
Definition at line 138 of file ngspice.h.
Referenced by AllVectors(), CurrentPlotName(), and init_dll().
|
private |
Definition at line 133 of file ngspice.h.
Referenced by init_dll().
|
private |
Definition at line 142 of file ngspice.h.
Referenced by init_dll().
|
private |
Definition at line 141 of file ngspice.h.
Referenced by init_dll(), and IsRunning().
|
private |
Definition at line 143 of file ngspice.h.
Referenced by init_dll().
|
protectedinherited |
< Reporter object to receive simulation log.
We don't own this. We are just borrowing it from the SCHEMATIC_SETTINGS.
Definition at line 185 of file spice_simulator.h.
Referenced by cbBGThreadRunning(), cbSendChar(), and SPICE_SIMULATOR::SetReporter().
|
protectedinherited |
Definition at line 188 of file spice_simulator.h.
Referenced by SPICE_SIMULATOR::Settings().
|
protectedinherited |
< Model that should be simulated.
Definition at line 98 of file simulator.h.
Referenced by SIMULATOR::Attach().