![]() |
KiCad PCB EDA Suite
|
Generate a PSPICE compatible netlist. More...
#include <netlist_exporter_pspice.h>
Public Member Functions | |
NETLIST_EXPORTER_PSPICE (SCHEMATIC_IFACE *aSchematic) | |
virtual | ~NETLIST_EXPORTER_PSPICE () |
const std::list< SPICE_ITEM > & | GetSpiceItems () const |
Return list of items representing schematic components in the Spice world. More... | |
wxString | GetSpiceDevice (const wxString &aSymbol) const |
Return name of Spice device corresponding to a schematic symbol. More... | |
bool | WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions) override |
Write to specified output file. More... | |
bool | Format (OUTPUTFORMATTER *aFormatter, unsigned aCtl) |
bool | ProcessNetlist (unsigned aCtl) |
Process the netlist to create net mapping and a list of SPICE_ITEMs. More... | |
const std::map< wxString, int > & | GetNetIndexMap () const |
Return a map of circuit nodes to net names. More... | |
void | UpdateDirectives (unsigned aCtl) |
Update the vector of Spice directives placed in the schematics. More... | |
const std::vector< wxString > | GetDirectives () const |
Return a vector of Spice directives found in the schematics. More... | |
Static Public Member Functions | |
static void | ReplaceForbiddenChars (wxString &aNetName) |
Replace illegal spice net name characters with an underscore. More... | |
static const std::vector< wxString > & | GetSpiceFields () |
Return a vector of component field names related to Spice simulation. More... | |
static const wxString & | GetSpiceFieldName (SPICE_FIELD aField) |
Return a string used for a particular component field related to Spice simulation. More... | |
static wxString | GetSpiceField (SPICE_FIELD aField, SCH_SYMBOL *aSymbol, unsigned aCtl) |
Retrieve either the requested field value or the default value. More... | |
static wxString | GetSpiceFieldDefVal (SPICE_FIELD aField, SCH_SYMBOL *aSymbol, unsigned aCtl) |
Retrieve the default value for a given field. More... | |
static bool | StringToBool (const wxString &aStr) |
Convert typical boolean string values (no/yes, true/false, 1/0) to a boolean value. More... | |
static wxString | MakeCommandLine (const wxString &aFormatString, const wxString &aNetlistFile, const wxString &aFinalFile, const wxString &aProjectDirectory) |
Build up a string that describes a command line for executing a child process. More... | |
Protected Member Functions | |
virtual void | writeDirectives (OUTPUTFORMATTER *aFormatter, unsigned aCtl) const |
Save the Spice directives. More... | |
void | CreatePinList (SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, bool aKeepUnconnectedPins) |
Find a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList. More... | |
SCH_SYMBOL * | findNextSymbol (EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath) |
Check if the given symbol should be processed for netlisting. More... | |
void | eraseDuplicatePins () |
Erase duplicate pins from m_sortedSymbolPinList (i.e. More... | |
void | findAllUnitsOfSymbol (SCH_SYMBOL *aSchSymbol, LIB_SYMBOL *aLibSymbol, SCH_SHEET_PATH *aSheetPath, bool aKeepUnconnectedPins) |
Find all units for symbols with multiple symbols per package. More... | |
Protected Attributes | |
std::vector< PIN_INFO > | m_sortedSymbolPinList |
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic symbol data in netlist (comp section). More... | |
UNIQUE_STRINGS | m_referencesAlreadyFound |
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once. More... | |
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > | m_libParts |
unique library symbols used. LIB_SYMBOL items are sorted by names More... | |
SCHEMATIC_IFACE * | m_schematic |
The schematic we're generating a netlist for. More... | |
SCH_SHEET_PATH | m_savedCurrentSheet |
The schematic's CurrentSheet when we entered. Restore on exiting. More... | |
Private Attributes | |
wxString | m_title |
Spice simulation title found in the schematic sheet. More... | |
std::vector< wxString > | m_directives |
Spice directives found in the schematic sheet. More... | |
std::set< wxString > | m_libraries |
Spice libraries used by the simulated circuit. More... | |
std::map< wxString, int > | m_netMap |
Map spice nodes to net codes. More... | |
std::list< SPICE_ITEM > | m_spiceItems |
Items representing schematic symbols in Spice world. More... | |
Static Private Attributes | |
static const std::vector< wxString > | m_spiceFields |
Generate a PSPICE compatible netlist.
Definition at line 90 of file netlist_exporter_pspice.h.
|
inline |
Definition at line 93 of file netlist_exporter_pspice.h.
|
inlinevirtual |
Definition at line 98 of file netlist_exporter_pspice.h.
|
protectedinherited |
Find a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList.
This list is sorted by pin number. The symbol is the next actual symbol after aSymbol. Power symbols and virtual symbols that have their reference designators starting with '#' are skipped. if aKeepUnconnectedPins = false, unconnected pins will be removed from list but usually we need all pins in netlists.
Definition at line 124 of file netlist_exporter_base.cpp.
References SCHEMATIC_IFACE::ConnectionGraph(), NETLIST_EXPORTER_BASE::eraseDuplicatePins(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), CONNECTION_SUBGRAPH::m_items, NETLIST_EXPORTER_BASE::m_libParts, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_BASE::m_sortedSymbolPinList, pin, and sortPinsByNum().
Referenced by ProcessNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().
|
protectedinherited |
Erase duplicate pins from m_sortedSymbolPinList (i.e.
set pointer in this list to NULL).
(This is a list of pins found in the whole schematic, for a single symbol.) These duplicate pins were put in list because some pins (power pins...) are found more than once when in "multiple symbols per package" symbols. For instance, a 74ls00 has 4 symbols, and therefore the VCC pin and GND pin appears 4 times in the list. Note: this list MUST be sorted by pin number (.m_PinNum member value) Also set the m_Flag member of "removed" NETLIST_OBJECT pin item to 1
Definition at line 190 of file netlist_exporter_base.cpp.
References NETLIST_EXPORTER_BASE::m_sortedSymbolPinList.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList().
|
protectedinherited |
Find all units for symbols with multiple symbols per package.
Search the entire design for all units of aSymbol based on matching reference designator, and for each unit, add all its pins to the temporary sorted pin list, m_sortedSymbolPinList. if aKeepUnconnectedPins = false, unconnected pins will be removed from list but usually we need all pins in netlists.
Definition at line 223 of file netlist_exporter_base.cpp.
References SCHEMATIC_IFACE::ConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), SCHEMATIC_IFACE::GetSheets(), CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_no_connect, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_BASE::m_sortedSymbolPinList, pin, and SCH_SYMBOL_T.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList().
|
protectedinherited |
Check if the given symbol should be processed for netlisting.
Prevent processing multi-unit symbols more than once, etc.
aItem | is a symbol to check |
aSheetPath | is the sheet to check the symbol for |
Definition at line 73 of file netlist_exporter_base.cpp.
References SCH_SCREEN::GetLibSymbols(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetSchSymbolLibraryName(), LIB_SYMBOL::GetUnitCount(), SCH_SHEET_PATH::LastScreen(), UNIQUE_STRINGS::Lookup(), NETLIST_EXPORTER_BASE::m_libParts, NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, SCH_SYMBOL_T, and EDA_ITEM::Type().
Referenced by NETLIST_EXPORTER_XML::makeSymbols(), ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().
bool NETLIST_EXPORTER_PSPICE::Format | ( | OUTPUTFORMATTER * | aFormatter, |
unsigned | aCtl | ||
) |
Definition at line 95 of file netlist_exporter_pspice.cpp.
References _, DisplayError(), ExpandEnvVarSubstitutions(), Format(), GetSpiceDevice(), m_libraries, m_netMap, NETLIST_EXPORTER_BASE::m_schematic, m_spiceItems, m_title, NET_ADJUST_INCLUDE_PATHS, Pgm(), OUTPUTFORMATTER::Print(), SCHEMATIC_IFACE::Prj(), ProcessNetlist(), ReplaceForbiddenChars(), ResolveFile(), TO_UTF8, UnescapeString(), and writeDirectives().
Referenced by WriteNetlist().
|
inline |
Return a vector of Spice directives found in the schematics.
Definition at line 185 of file netlist_exporter_pspice.h.
References m_directives.
Referenced by NETLIST_EXPORTER_PSPICE_SIM::GetSheetSimCommand(), and NETLIST_EXPORTER_PSPICE_SIM::writeDirectives().
|
inline |
Return a map of circuit nodes to net names.
Definition at line 146 of file netlist_exporter_pspice.h.
References m_netMap.
Referenced by DIALOG_SIM_SETTINGS::ShowModal(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), and NETLIST_EXPORTER_PSPICE_SIM::writeDirectives().
wxString NETLIST_EXPORTER_PSPICE::GetSpiceDevice | ( | const wxString & | aSymbol | ) | const |
Return name of Spice device corresponding to a schematic symbol.
aSymbol | is the component reference. |
Definition at line 45 of file netlist_exporter_pspice.cpp.
References GetSpiceItems().
Referenced by NETLIST_EXPORTER_PSPICE_SIM::ComponentToVector(), DIALOG_SIM_SETTINGS::evaluateDCControls(), Format(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), and TUNER_SLIDER::TUNER_SLIDER().
|
static |
Retrieve either the requested field value or the default value.
Definition at line 198 of file netlist_exporter_pspice.cpp.
References SCH_SYMBOL::FindField(), SCH_FIELD::GetShownText(), GetSpiceFieldDefVal(), and GetSpiceFieldName().
Referenced by SIM_PLOT_FRAME::AddTuner(), and ProcessNetlist().
|
static |
Retrieve the default value for a given field.
Definition at line 206 of file netlist_exporter_pspice.cpp.
References SCH_SYMBOL::GetField(), SCH_SYMBOL::GetLibSymbolRef(), SCH_FIELD::GetShownText(), NET_ADJUST_PASSIVE_VALS, pin, REFERENCE_FIELD, SF_ENABLED, SF_LIB_FILE, SF_MODEL, SF_NODE_SEQUENCE, SF_PRIMITIVE, and VALUE_FIELD.
Referenced by GetSpiceField(), and DIALOG_SPICE_MODEL::TransferDataToWindow().
|
inlinestatic |
Return a string used for a particular component field related to Spice simulation.
Definition at line 162 of file netlist_exporter_pspice.h.
References m_spiceFields.
Referenced by DIALOG_SPICE_MODEL::getLibField(), DIALOG_SPICE_MODEL::getSchField(), GetSpiceField(), ProcessNetlist(), DIALOG_SPICE_MODEL::TransferDataFromWindow(), and TUNER_SLIDER::TUNER_SLIDER().
|
inlinestatic |
Return a vector of component field names related to Spice simulation.
Definition at line 154 of file netlist_exporter_pspice.h.
References m_spiceFields.
Referenced by DIALOG_SPICE_MODEL::TransferDataToWindow().
|
inline |
Return list of items representing schematic components in the Spice world.
Definition at line 105 of file netlist_exporter_pspice.h.
References m_spiceItems.
Referenced by GetSpiceDevice(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), DIALOG_SIM_SETTINGS::updateDCSources(), and NETLIST_EXPORTER_PSPICE_SIM::writeDirectives().
|
staticinherited |
Build up a string that describes a command line for executing a child process.
The input and output file names along with any options to the executable are all possibly in the returned string.
aFormatString | holds:
|
aNetlistFile | is the name of the input file for the external program, that is a intermediate netlist file in xml format. |
aFinalFile | is the name of the output file that the user expects. |
aProjectDirectory | is used for P replacement, it should omit the trailing '/'. |
Supported formatting sequences and their meaning:
Definition at line 37 of file netlist_exporter_base.cpp.
Referenced by SCH_EDIT_FRAME::WriteNetListFile().
bool NETLIST_EXPORTER_PSPICE::ProcessNetlist | ( | unsigned | aCtl | ) |
Process the netlist to create net mapping and a list of SPICE_ITEMs.
It is automatically called by WriteNetlist(), but might be used separately, if only net mapping and the list of SPICE_ITEMs are required.
Definition at line 281 of file netlist_exporter_pspice.cpp.
References _, UNIQUE_STRINGS::Clear(), NETLIST_EXPORTER_BASE::CreatePinList(), DisplayError(), SCH_SYMBOL::FindField(), NETLIST_EXPORTER_BASE::findNextSymbol(), SCH_SYMBOL::GetRef(), SCHEMATIC_IFACE::GetSheets(), SCH_FIELD::GetShownText(), GetSpiceField(), GetSpiceFieldName(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), SPICE_ITEM::m_enabled, NETLIST_EXPORTER_BASE::m_libParts, m_libraries, SPICE_ITEM::m_model, m_netMap, SPICE_ITEM::m_parent, SPICE_ITEM::m_pins, SPICE_ITEM::m_pinSequence, SPICE_ITEM::m_primitive, NETLIST_EXPORTER_BASE::m_referencesAlreadyFound, SPICE_ITEM::m_refName, NETLIST_EXPORTER_BASE::m_schematic, NETLIST_EXPORTER_BASE::m_sortedSymbolPinList, m_spiceItems, EE_RTREE::OfType(), pin, SCH_SYMBOL_T, SF_ENABLED, SF_LIB_FILE, SF_MODEL, SF_NODE_SEQUENCE, SF_PRIMITIVE, StringToBool(), and UpdateDirectives().
Referenced by Format().
|
static |
Replace illegal spice net name characters with an underscore.
Definition at line 83 of file netlist_exporter_pspice.cpp.
Referenced by NETLIST_EXPORTER_PSPICE_SIM::ComponentToVector(), and Format().
|
inlinestatic |
Convert typical boolean string values (no/yes, true/false, 1/0) to a boolean value.
Definition at line 193 of file netlist_exporter_pspice.h.
Referenced by ProcessNetlist(), and DIALOG_SPICE_MODEL::TransferDataToWindow().
void NETLIST_EXPORTER_PSPICE::UpdateDirectives | ( | unsigned | aCtl | ) |
Update the vector of Spice directives placed in the schematics.
Definition at line 384 of file netlist_exporter_pspice.cpp.
References SCHEMATIC_IFACE::GetSheets(), m_directives, m_libraries, NETLIST_EXPORTER_BASE::m_schematic, m_title, SCH_TEXT_T, and text.
Referenced by NETLIST_EXPORTER_PSPICE_SIM::GetSheetSimCommand(), and ProcessNetlist().
|
protectedvirtual |
Save the Spice directives.
Reimplemented in NETLIST_EXPORTER_PSPICE_SIM.
Definition at line 477 of file netlist_exporter_pspice.cpp.
References m_directives, OUTPUTFORMATTER::Print(), and TO_UTF8.
Referenced by Format(), and NETLIST_EXPORTER_PSPICE_SIM::writeDirectives().
|
overridevirtual |
Write to specified output file.
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Reimplemented from NETLIST_EXPORTER_BASE.
Definition at line 64 of file netlist_exporter_pspice.cpp.
References _, DisplayError(), and Format().
|
private |
Spice directives found in the schematic sheet.
Definition at line 213 of file netlist_exporter_pspice.h.
Referenced by GetDirectives(), UpdateDirectives(), and writeDirectives().
|
protectedinherited |
unique library symbols used. LIB_SYMBOL items are sorted by names
Definition at line 209 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findNextSymbol(), NETLIST_EXPORTER_XML::makeLibParts(), NETLIST_EXPORTER_XML::makeSymbols(), and ProcessNetlist().
|
private |
Spice libraries used by the simulated circuit.
Definition at line 214 of file netlist_exporter_pspice.h.
Referenced by Format(), ProcessNetlist(), and UpdateDirectives().
|
private |
Map spice nodes to net codes.
Definition at line 215 of file netlist_exporter_pspice.h.
Referenced by Format(), GetNetIndexMap(), and ProcessNetlist().
|
protectedinherited |
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
Definition at line 206 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::findNextSymbol(), NETLIST_EXPORTER_XML::makeSymbols(), ProcessNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().
|
protectedinherited |
The schematic's CurrentSheet when we entered. Restore on exiting.
Definition at line 215 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::NETLIST_EXPORTER_BASE(), and NETLIST_EXPORTER_BASE::~NETLIST_EXPORTER_BASE().
|
protectedinherited |
The schematic we're generating a netlist for.
Definition at line 212 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), Format(), NETLIST_EXPORTER_XML::makeDesignHeader(), NETLIST_EXPORTER_XML::makeLibraries(), NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_BASE::NETLIST_EXPORTER_BASE(), ProcessNetlist(), UpdateDirectives(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_BASE::~NETLIST_EXPORTER_BASE().
|
protectedinherited |
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic symbol data in netlist (comp section).
No ownership of members. TODO(snh): Descope this object
Definition at line 202 of file netlist_exporter_base.h.
Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::eraseDuplicatePins(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), ProcessNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().
|
staticprivate |
Definition at line 219 of file netlist_exporter_pspice.h.
Referenced by GetSpiceFieldName(), and GetSpiceFields().
|
private |
Items representing schematic symbols in Spice world.
Definition at line 216 of file netlist_exporter_pspice.h.
Referenced by Format(), GetSpiceItems(), and ProcessNetlist().
|
private |
Spice simulation title found in the schematic sheet.
Definition at line 212 of file netlist_exporter_pspice.h.
Referenced by Format(), and UpdateDirectives().