KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SPICE_SIMULATOR Class Referenceabstract

#include <spice_simulator.h>

Inheritance diagram for SPICE_SIMULATOR:
SIMULATOR NGSPICE

Public Member Functions

 SPICE_SIMULATOR ()
 
virtual ~SPICE_SIMULATOR ()
 
virtual void Init (const SPICE_SETTINGS *aSettings=nullptr)=0
 
virtual bool LoadNetlist (const std::string &aNetlist)=0
 Load a netlist for the simulation. More...
 
virtual bool Command (const std::string &aCmd)=0
 Execute a Spice command as if it was typed into console. More...
 
virtual wxString GetXAxis (SIM_TYPE aType) const =0
 Set a SIMULATOR_REPORTER object to receive the simulation log. More...
 
virtual void SetReporter (SIMULATOR_REPORTER *aReporter)
 
virtual wxString CurrentPlotName () const =0
 
virtual std::vector< std::string > AllVectors () const =0
 
virtual std::vector< COMPLEXGetComplexVector (const std::string &aName, int aMaxLen=-1)=0
 Return a requested vector with complex values. More...
 
virtual std::vector< double > GetRealVector (const std::string &aName, int aMaxLen=-1)=0
 Return a requested vector with real values. More...
 
virtual std::vector< double > GetImaginaryVector (const std::string &aName, int aMaxLen=-1)=0
 Return a requested vector with imaginary values. More...
 
virtual std::vector< double > GetGainVector (const std::string &aName, int aMaxLen=-1)=0
 Return a requested vector with magnitude values. More...
 
virtual std::vector< double > GetPhaseVector (const std::string &aName, int aMaxLen=-1)=0
 Return a requested vector with phase values. More...
 
virtual const std::string GetNetlist () const =0
 Return current SPICE netlist used by the simulator. More...
 
virtual std::vector< std::string > GetSettingCommands () const =0
 
std::shared_ptr< SPICE_SETTINGS > & Settings ()
 Return the simulator configuration settings. More...
 
const std::shared_ptr< SPICE_SETTINGS > & Settings () const
 
std::mutex & GetMutex ()
 
virtual bool Attach (const std::shared_ptr< SIMULATION_MODEL > &aModel, const wxString &aSimCommand, unsigned aSimOptions, REPORTER &aReporter)
 Point out the model that will be used in future simulations. More...
 
virtual bool Run ()=0
 Execute the simulation with currently loaded netlist. More...
 
virtual bool Stop ()=0
 Halt the simulation. More...
 
virtual bool IsRunning ()=0
 Check if simulation is running at the moment. More...
 
virtual void Clean ()=0
 Cleans simulation data (i.e. More...
 

Static Public Member Functions

static wxString TypeToName (SIM_TYPE aType, bool aShortName)
 Return a string with simulation name based on enum. More...
 
static std::shared_ptr< SPICE_SIMULATORCreateInstance (const std::string &aName)
 

Protected Attributes

SIMULATOR_REPORTERm_reporter
 < Reporter object to receive simulation log. More...
 
std::shared_ptr< SPICE_SETTINGSm_settings
 
std::shared_ptr< SIMULATION_MODELm_simModel
 < Model that should be simulated. More...
 

Private Attributes

std::mutex m_mutex
 < For interprocess synchronisation. More...
 

Detailed Description

Definition at line 47 of file spice_simulator.h.

Constructor & Destructor Documentation

◆ SPICE_SIMULATOR()

SPICE_SIMULATOR::SPICE_SIMULATOR ( )
inline

Definition at line 50 of file spice_simulator.h.

◆ ~SPICE_SIMULATOR()

virtual SPICE_SIMULATOR::~SPICE_SIMULATOR ( )
inlinevirtual

Definition at line 56 of file spice_simulator.h.

Member Function Documentation

◆ AllVectors()

virtual std::vector< std::string > SPICE_SIMULATOR::AllVectors ( ) const
pure virtual
Returns
list of simulation vector (signal) names.

Implemented in NGSPICE.

◆ Attach()

virtual bool SIMULATOR::Attach ( const std::shared_ptr< SIMULATION_MODEL > &  aModel,
const wxString &  aSimCommand,
unsigned  aSimOptions,
REPORTER aReporter 
)
inlinevirtualinherited

Point out the model that will be used in future simulations.

Returns
True in case of success, false otherwise.

Reimplemented in NGSPICE.

Definition at line 61 of file simulator.h.

References SIMULATOR::m_simModel.

Referenced by NGSPICE::Attach().

◆ Clean()

virtual void SIMULATOR::Clean ( )
pure virtualinherited

Cleans simulation data (i.e.

all vectors)

Implemented in NGSPICE.

◆ Command()

virtual bool SPICE_SIMULATOR::Command ( const std::string &  aCmd)
pure virtual

Execute a Spice command as if it was typed into console.

Parameters
aCmdis the command to be issued. Return X axis name for a given simulation type

Implemented in NGSPICE.

◆ CreateInstance()

std::shared_ptr< SPICE_SIMULATOR > SIMULATOR::CreateInstance ( const std::string &  aName)
staticinherited

Definition at line 33 of file spice_simulator.cpp.

References DisplayError().

Referenced by KIBIS_PIN::getKuKdFromFile(), and SIMULATOR_FRAME::SIMULATOR_FRAME().

◆ CurrentPlotName()

virtual wxString SPICE_SIMULATOR::CurrentPlotName ( ) const
pure virtual
Returns
the current simulation plot name (tran1, tran2, etc.)

Implemented in NGSPICE.

◆ GetComplexVector()

virtual std::vector< COMPLEX > SPICE_SIMULATOR::GetComplexVector ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Return a requested vector with complex values.

If the vector is real, then the imaginary part is set to 0 in all values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

◆ GetGainVector()

virtual std::vector< double > SPICE_SIMULATOR::GetGainVector ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Return a requested vector with magnitude values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

◆ GetImaginaryVector()

virtual std::vector< double > SPICE_SIMULATOR::GetImaginaryVector ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

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.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

◆ GetMutex()

std::mutex & SIMULATOR::GetMutex ( )
inlineinherited

Definition at line 51 of file simulator.h.

References SIMULATOR::m_mutex.

◆ GetNetlist()

virtual const std::string SPICE_SIMULATOR::GetNetlist ( ) const
pure virtual

Return current SPICE netlist used by the simulator.

Returns
The netlist.

Implemented in NGSPICE.

◆ GetPhaseVector()

virtual std::vector< double > SPICE_SIMULATOR::GetPhaseVector ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Return a requested vector with phase values.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

◆ GetRealVector()

virtual std::vector< double > SPICE_SIMULATOR::GetRealVector ( const std::string &  aName,
int  aMaxLen = -1 
)
pure virtual

Return a requested vector with real values.

If the vector is complex, then the real part is returned.

Parameters
aNameis the vector named in Spice convention (e.g. V(3), I(R1)).
aMaxLenis max count of returned values. if -1 (default) all available values are returned.
Returns
Requested vector. It might be empty if there is no vector with requested name.

Implemented in NGSPICE.

◆ GetSettingCommands()

virtual std::vector< std::string > SPICE_SIMULATOR::GetSettingCommands ( ) const
pure virtual
Returns
a list of simulator setting command strings.

Implemented in NGSPICE.

◆ GetXAxis()

virtual wxString SPICE_SIMULATOR::GetXAxis ( SIM_TYPE  aType) const
pure virtual

Set a SIMULATOR_REPORTER object to receive the simulation log.

Implemented in NGSPICE.

◆ Init()

virtual void SPICE_SIMULATOR::Init ( const SPICE_SETTINGS aSettings = nullptr)
pure virtual

Implemented in NGSPICE.

◆ IsRunning()

virtual bool SIMULATOR::IsRunning ( )
pure virtualinherited

Check if simulation is running at the moment.

Returns
True if simulation is currently executed.

Implemented in NGSPICE.

◆ LoadNetlist()

virtual bool SPICE_SIMULATOR::LoadNetlist ( const std::string &  aNetlist)
pure virtual

Load a netlist for the simulation.

Returns
True in case of success, false otherwise.

Implemented in NGSPICE.

◆ Run()

virtual bool SIMULATOR::Run ( )
pure virtualinherited

Execute the simulation with currently loaded netlist.

Returns
True in case of success, false otherwise.

Implemented in NGSPICE.

◆ SetReporter()

virtual void SPICE_SIMULATOR::SetReporter ( SIMULATOR_REPORTER aReporter)
inlinevirtual

Definition at line 84 of file spice_simulator.h.

References m_reporter.

Referenced by TEST_NETLIST_EXPORTER_SPICE_FIXTURE::CompareNetlists().

◆ Settings() [1/2]

std::shared_ptr< SPICE_SETTINGS > & SPICE_SIMULATOR::Settings ( )
inline

Return the simulator configuration settings.

Returns
the simulator specific settings.

Definition at line 169 of file spice_simulator.h.

References m_settings.

Referenced by NGSPICE::GetSettingCommands().

◆ Settings() [2/2]

const std::shared_ptr< SPICE_SETTINGS > & SPICE_SIMULATOR::Settings ( ) const
inline

Definition at line 171 of file spice_simulator.h.

References m_settings.

◆ Stop()

virtual bool SIMULATOR::Stop ( )
pure virtualinherited

Halt the simulation.

Returns
True in case of success, false otherwise.

Implemented in NGSPICE.

◆ TypeToName()

wxString SPICE_SIMULATOR::TypeToName ( SIM_TYPE  aType,
bool  aShortName 
)
static

Return a string with simulation name based on enum.

Parameters
aTypeis the enum describing simulation type
aShortNameif true - return is in format "TRAN", "OP". if false - return is in format "Transient", "Operating Point".
Returns
String with requested name as described above.

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().

Member Data Documentation

◆ m_mutex

std::mutex SIMULATOR::m_mutex
privateinherited

< For interprocess synchronisation.

Definition at line 101 of file simulator.h.

Referenced by SIMULATOR::GetMutex().

◆ m_reporter

SIMULATOR_REPORTER* SPICE_SIMULATOR::m_reporter
protected

< 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 NGSPICE::cbBGThreadRunning(), NGSPICE::cbSendChar(), and SetReporter().

◆ m_settings

std::shared_ptr<SPICE_SETTINGS> SPICE_SIMULATOR::m_settings
protected

Definition at line 188 of file spice_simulator.h.

Referenced by Settings().

◆ m_simModel

std::shared_ptr<SIMULATION_MODEL> SIMULATOR::m_simModel
protectedinherited

< Model that should be simulated.

Definition at line 97 of file simulator.h.

Referenced by SIMULATOR::Attach().


The documentation for this class was generated from the following files: