KiCad PCB EDA Suite
Loading...
Searching...
No Matches
NETLIST_EXPORTER_ALLEGRO Class Reference

Generate a netlist compatible with Allegro. More...

#include <netlist_exporter_allegro.h>

Inheritance diagram for NETLIST_EXPORTER_ALLEGRO:
NETLIST_EXPORTER_BASE

Classes

struct  NET_NODE
 

Public Member Functions

 NETLIST_EXPORTER_ALLEGRO (SCHEMATIC *aSchematic)
 
bool writeNetlist (const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
 Write netlist to aOutFileName.
 
void SetKiway (KIWAY *aKiway)
 
bool WriteNetlist (const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
 Write to specified output file.
 

Static Public Member Functions

static bool CompareSymbolSheetpath (const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > &aItem1, const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > &aItem2)
 Compare two std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> variables.
 
static bool CompareSymbolRef (const wxString &aRefText1, const wxString &aRefText2)
 Compare two wxString variables.
 
static bool CompareLibPin (const SCH_PIN *aPin1, const SCH_PIN *aPin2)
 Compare two SCH_PIN* variables.
 
static wxString formatRoom (const SCH_SHEET_PATH &aSheetPath)
 Generate an Allegro room name from a sheet path.
 
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.
 

Protected Member Functions

void rebuildConnectivity ()
 
std::optional< wxString > itemNetName (const SCH_ITEM &aItem, const SCH_SHEET_PATH &aPath) const
 
std::vector< PIN_INFOCreatePinList (SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath)
 Find a symbol from the DrawList and builds its pin list.
 
SCH_SYMBOLfindNextSymbol (EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
 Check if the given symbol should be processed for netlisting.
 
void eraseDuplicatePins (std::vector< PIN_INFO > &pins)
 Erase duplicate pins.
 
void appendResolvedPins (std::vector< PIN_INFO > &aPins, const SCH_PIN *aPin, const SCH_SHEET_PATH &aSheetPath, const wxString &aNetName)
 Resolve aPin to its pad number(s) and append a PIN_INFO for each (issue #2282).
 
std::vector< wxString > resolvePadNumbers (const SCH_PIN *aPin, const SCH_SHEET_PATH &aSheetPath) const
 Resolve aPin to its effective pad number(s) for every netlist path (issue #2282).
 
const std::set< wxString > & footprintPads (const wxString &aFootprintId) const
 
void findAllUnitsOfSymbol (SCH_SYMBOL *aSchSymbol, const SCH_SHEET_PATH &aSheetPath, std::vector< PIN_INFO > &aPins)
 Find all units for symbols with multiple symbols per package.
 

Protected Attributes

SCH_SHEET_LIST m_exportSheets
 
std::vector< EXPORT_NETm_exportNets
 
std::map< SCH_SHEET_PATH, std::unordered_map< KIID, wxString > > m_exportItemNets
 
unsigned m_connectivityDepth = 0
 
UNIQUE_STRINGS m_referencesAlreadyFound
 Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
 
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THANm_libParts
 unique library symbols used. LIB_SYMBOL items are sorted by names
 
SCHEMATICm_schematic
 The schematic we're generating a netlist for.
 
KIWAYm_kiway = nullptr
 
std::map< wxString, std::set< wxString > > m_footprintPadCache
 

Private Member Functions

void extractComponentsInfo ()
 
void toAllegroPackages ()
 Write the $PACKAGES section.
 
void toAllegroNets ()
 Write the $NETS section.
 
void toAllegroPackageProperties ()
 Write $A_PROPERTIES section.
 
wxString formatDevice (wxString aString)
 Convert a string into one safe for a Telesis device name.
 
wxString formatText (wxString aString)
 Convert a string into Telesis-safe format.
 
wxString formatPin (const SCH_PIN &aPin)
 Generate a Telesis-compatible pin name from a pin node.
 
wxString formatFunction (wxString aName, std::vector< SCH_PIN * > aPinList)
 Generate the definition of a function in Telesis format, which consists of multiple declarations (PINORDER, PINSWAP, and FUNCTIONs).
 
wxString getGroupField (int aGroupIndex, const wxArrayString &aFieldArray, bool aSanitize=true)
 Look up a field for a component group, which may have mismatched case, or the component group may not have the field defined and instead the library entry has to be searched.
 

Static Private Member Functions

static wxString removeTailDigits (wxString aString)
 Remove the str's tailing digits.
 
static unsigned int extractTailNumber (wxString aString)
 Extract the str's tailing number.
 

Private Attributes

FILE * m_f
 File pointer for netlist file writing operation.
 
wxString m_exportPath
 Directory to store device files.
 
std::multimap< wxString, wxString > m_packageProperties
 
std::multimap< int, std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > > m_componentGroups
 Store the component group.
 
std::list< std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > > m_orderedSymbolsSheetpath
 Store the ordered symbols with sheetpath.
 
std::multimap< wxString, NET_NODEm_netNameNodes
 Store the NET_NODE with the net name.
 

Detailed Description

Generate a netlist compatible with Allegro.

Definition at line 33 of file netlist_exporter_allegro.h.

Constructor & Destructor Documentation

◆ NETLIST_EXPORTER_ALLEGRO()

NETLIST_EXPORTER_ALLEGRO::NETLIST_EXPORTER_ALLEGRO ( SCHEMATIC * aSchematic)
inline

Member Function Documentation

◆ appendResolvedPins()

void NETLIST_EXPORTER_BASE::appendResolvedPins ( std::vector< PIN_INFO > & aPins,
const SCH_PIN * aPin,
const SCH_SHEET_PATH & aSheetPath,
const wxString & aNetName )
protectedinherited

Resolve aPin to its pad number(s) and append a PIN_INFO for each (issue #2282).

Definition at line 339 of file netlist_exporter_base.cpp.

References SCH_PIN::GetNumber(), SCH_PIN::GetShownName(), and resolvePadNumbers().

Referenced by CreatePinList(), and findAllUnitsOfSymbol().

◆ CompareLibPin()

bool NETLIST_EXPORTER_ALLEGRO::CompareLibPin ( const SCH_PIN * aPin1,
const SCH_PIN * aPin2 )
static

Compare two SCH_PIN* variables.

Parameters
aPin1
aPin2
Returns
bool value

Definition at line 128 of file netlist_exporter_allegro.cpp.

References SCH_PIN::GetShownNumber(), and StrNumCmp().

Referenced by formatFunction(), and toAllegroPackages().

◆ CompareSymbolRef()

bool NETLIST_EXPORTER_ALLEGRO::CompareSymbolRef ( const wxString & aRefText1,
const wxString & aRefText2 )
static

Compare two wxString variables.

Parameters
aRefText1
aRefText2
Returns
bool value

Definition at line 116 of file netlist_exporter_allegro.cpp.

References extractTailNumber(), and removeTailDigits().

Referenced by CompareSymbolSheetpath(), NETLIST_EXPORTER_ALLEGRO::NET_NODE::operator<(), and toAllegroPackageProperties().

◆ CompareSymbolSheetpath()

bool NETLIST_EXPORTER_ALLEGRO::CompareSymbolSheetpath ( const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > & aItem1,
const std::pair< SCH_SYMBOL *, SCH_SHEET_PATH > & aItem2 )
static

Compare two std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> variables.

Parameters
aItem1comparing object 1
aItem2comparing object 2
Returns
true if aItem1 < aItem2

Definition at line 99 of file netlist_exporter_allegro.cpp.

References CompareSymbolRef().

Referenced by toAllegroPackages().

◆ CreatePinList()

std::vector< PIN_INFO > NETLIST_EXPORTER_BASE::CreatePinList ( SCH_SYMBOL * aSymbol,
const SCH_SHEET_PATH & aSheetPath )
protectedinherited

Find a symbol from the DrawList and builds its pin list.

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.

Definition at line 223 of file netlist_exporter_base.cpp.

References appendResolvedPins(), eraseDuplicatePins(), findAllUnitsOfSymbol(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetRef(), LIB_SYMBOL::GetUnitCount(), SCH_SYMBOL::IsPower(), itemNetName(), m_libParts, and pin.

Referenced by NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), and NETLIST_EXPORTER_ORCADPCB2::writeNetlist().

◆ eraseDuplicatePins()

void NETLIST_EXPORTER_BASE::eraseDuplicatePins ( std::vector< PIN_INFO > & pins)
protectedinherited

Erase duplicate pins.

(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 352 of file netlist_exporter_base.cpp.

References IsAutoGeneratedNetName().

Referenced by CreatePinList().

◆ extractComponentsInfo()

◆ extractTailNumber()

unsigned int NETLIST_EXPORTER_ALLEGRO::extractTailNumber ( wxString aString)
staticprivate

Extract the str's tailing number.

Parameters
aString
Returns
unsigned int

Definition at line 795 of file netlist_exporter_allegro.cpp.

Referenced by CompareSymbolRef().

◆ findAllUnitsOfSymbol()

void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol ( SCH_SYMBOL * aSchSymbol,
const SCH_SHEET_PATH & aSheetPath,
std::vector< PIN_INFO > & aPins )
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 sorted pin list.

Definition at line 405 of file netlist_exporter_base.cpp.

References appendResolvedPins(), SCH_SYMBOL::GetRef(), itemNetName(), m_exportSheets, pin, and SCH_SYMBOL_T.

Referenced by CreatePinList().

◆ findNextSymbol()

SCH_SYMBOL * NETLIST_EXPORTER_BASE::findNextSymbol ( EDA_ITEM * aItem,
const SCH_SHEET_PATH & aSheetPath )
protectedinherited

Check if the given symbol should be processed for netlisting.

Prevent processing multi-unit symbols more than once, etc.

Parameters
aItemis a symbol to check
aSheetPathis the sheet to check the symbol for
Returns
the symbol if it should be processed, or nullptr

Definition at line 177 of file netlist_exporter_base.cpp.

References SCH_SCREEN::GetLibSymbols(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetSchSymbolLibraryName(), LIB_SYMBOL::GetUnitCount(), SCH_SHEET_PATH::LastScreen(), m_libParts, m_referencesAlreadyFound, SCH_SYMBOL_T, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo(), NETLIST_EXPORTER_XML::makeSymbols(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), NETLIST_EXPORTER_CADSTAR::writeNetlist(), NETLIST_EXPORTER_ORCADPCB2::writeNetlist(), and NETLIST_EXPORTER_PADS::writeNetlist().

◆ footprintPads()

const std::set< wxString > & NETLIST_EXPORTER_BASE::footprintPads ( const wxString & aFootprintId) const
protectedinherited

◆ formatDevice()

wxString NETLIST_EXPORTER_ALLEGRO::formatDevice ( wxString aString)
private

Convert a string into one safe for a Telesis device name.

These are all lowercase and have a more restricted set of characters.

Bug
Replace unsupported characters with an encoding instead.
Parameters
aStringwxString to be formatted.
Returns
a formatted wxString.

Definition at line 696 of file netlist_exporter_allegro.cpp.

Referenced by toAllegroPackages().

◆ formatFunction()

wxString NETLIST_EXPORTER_ALLEGRO::formatFunction ( wxString aName,
std::vector< SCH_PIN * > aPinList )
private

Generate the definition of a function in Telesis format, which consists of multiple declarations (PINORDER, PINSWAP, and FUNCTIONs).

Parameters
aName
aPinList
Returns
wxString

Definition at line 567 of file netlist_exporter_allegro.cpp.

References CompareLibPin(), formatPin(), pin, and TO_UTF8.

Referenced by toAllegroPackages().

◆ formatPin()

wxString NETLIST_EXPORTER_ALLEGRO::formatPin ( const SCH_PIN & aPin)
private

Generate a Telesis-compatible pin name from a pin node.

( Telesis requires all pin names to be unique, and doesn't have separate fields for pin number and pin name/function, so we combine them together to make a unique name that still describes its function if you check pin info.

Bug
Replace unsupported characters with an encoding instead.
Parameters
aPin
Returns
wxString

Definition at line 559 of file netlist_exporter_allegro.cpp.

References SCH_PIN::GetName(), and SCH_PIN::GetNumber().

Referenced by formatFunction().

◆ formatRoom()

wxString NETLIST_EXPORTER_ALLEGRO::formatRoom ( const SCH_SHEET_PATH & aSheetPath)
static

Generate an Allegro room name from a sheet path.

Allegro doesn't accept '/' in a room name, so the hierarchy separators become dashes and any other character Allegro doesn't accept becomes an underscore: "/Power Supply/ Regulators/" turns into "Power_Supply-Regulators". The root sheet, which has no name of its own, is named after the root schematic file.

Parameters
aSheetPathsheet the room represents.
Returns
a room name safe to use as a ROOM property value.

Definition at line 656 of file netlist_exporter_allegro.cpp.

References path, and SCH_SHEET_PATH::PathHumanReadable().

Referenced by extractComponentsInfo().

◆ formatText()

wxString NETLIST_EXPORTER_ALLEGRO::formatText ( wxString aString)
private

Convert a string into Telesis-safe format.

Unsupported characters are replaced with ?'s, and the string is quoted if necessary.

Bug
Replace unsupported characters with an encoding to avoid having similar strings mapped to each other.
Parameters
aString
Returns
wxString

Definition at line 536 of file netlist_exporter_allegro.cpp.

Referenced by getGroupField(), and toAllegroNets().

◆ getGroupField()

wxString NETLIST_EXPORTER_ALLEGRO::getGroupField ( int aGroupIndex,
const wxArrayString & aFieldArray,
bool aSanitize = true )
private

Look up a field for a component group, which may have mismatched case, or the component group may not have the field defined and instead the library entry has to be searched.

Returns None if no fields exist.

Parameters
aGroupIndexthe component group index to query
aFieldArrayone or more (equivalent) fields to query, in the order specified. first field that exists is returned.
aSanitizeif true (default), will format/escape the field for Telesis output
Returns
return the found field, or return wxString("") if no field exist.

Definition at line 604 of file netlist_exporter_allegro.cpp.

References LIB_SYMBOL::FindFieldCaseInsensitive(), SCH_SYMBOL::FindFieldCaseInsensitive(), FOR_CANVAS, formatText(), SCH_SYMBOL::GetLibSymbolRef(), m_componentGroups, and RESOLVED.

Referenced by toAllegroPackages().

◆ itemNetName()

std::optional< wxString > NETLIST_EXPORTER_BASE::itemNetName ( const SCH_ITEM & aItem,
const SCH_SHEET_PATH & aPath ) const
protectedinherited

◆ MakeCommandLine()

wxString NETLIST_EXPORTER_BASE::MakeCommandLine ( const wxString & aFormatString,
const wxString & aNetlistFile,
const wxString & aFinalFile,
const wxString & aProjectDirectory )
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.

Parameters
aFormatStringholds:
  • the name of the external program
  • any options needed by that program
  • formatting sequences, see below.
aNetlistFileis the name of the input file for the external program, that is a intermediate netlist file in xml format.
aFinalFileis the name of the output file that the user expects.
aProjectDirectoryis used for P replacement, it should omit the trailing '/'.

Supported formatting sequences and their meaning:

  • B => base filename of selected output file, minus path and extension.
  • I => complete filename and path of the temporary input file.
  • O => complete filename and path of the user chosen output file.
  • P => project directory, without name and without trailing '/'

Definition at line 141 of file netlist_exporter_base.cpp.

Referenced by SCH_EDIT_FRAME::WriteNetListFile().

◆ rebuildConnectivity()

void NETLIST_EXPORTER_BASE::rebuildConnectivity ( )
protectedinherited

◆ removeTailDigits()

wxString NETLIST_EXPORTER_ALLEGRO::removeTailDigits ( wxString aString)
staticprivate

Remove the str's tailing digits.

Parameters
aString
Returns
wxString

Definition at line 783 of file netlist_exporter_allegro.cpp.

Referenced by CompareSymbolRef(), and toAllegroPackages().

◆ resolvePadNumbers()

std::vector< wxString > NETLIST_EXPORTER_BASE::resolvePadNumbers ( const SCH_PIN * aPin,
const SCH_SHEET_PATH & aSheetPath ) const
protectedinherited

◆ SetKiway()

void NETLIST_EXPORTER_BASE::SetKiway ( KIWAY * aKiway)
inlineinherited

Definition at line 106 of file netlist_exporter_base.h.

References m_kiway.

Referenced by SCH_EDIT_FRAME::KiwayMailIn().

◆ toAllegroNets()

void NETLIST_EXPORTER_ALLEGRO::toAllegroNets ( )
private

Write the $NETS section.

Definition at line 743 of file netlist_exporter_allegro.cpp.

References formatText(), m_f, m_netNameNodes, and TO_UTF8.

Referenced by writeNetlist().

◆ toAllegroPackageProperties()

void NETLIST_EXPORTER_ALLEGRO::toAllegroPackageProperties ( )
private

Write $A_PROPERTIES section.

Definition at line 704 of file netlist_exporter_allegro.cpp.

References CompareSymbolRef(), m_f, m_packageProperties, and TO_UTF8.

Referenced by writeNetlist().

◆ toAllegroPackages()

◆ WriteNetlist()

bool NETLIST_EXPORTER_BASE::WriteNetlist ( const wxString & aOutFileName,
unsigned aNetlistOptions,
REPORTER & aReporter )
inherited

◆ writeNetlist()

bool NETLIST_EXPORTER_ALLEGRO::writeNetlist ( const wxString & aOutFileName,
unsigned aNetlistOptions,
REPORTER & aReporter )
overridevirtual

Member Data Documentation

◆ m_componentGroups

std::multimap<int, std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > NETLIST_EXPORTER_ALLEGRO::m_componentGroups
private

Store the component group.

Definition at line 231 of file netlist_exporter_allegro.h.

Referenced by getGroupField(), toAllegroPackages(), and writeNetlist().

◆ m_connectivityDepth

unsigned NETLIST_EXPORTER_BASE::m_connectivityDepth = 0
protectedinherited

Definition at line 174 of file netlist_exporter_base.h.

◆ m_exportItemNets

std::map<SCH_SHEET_PATH, std::unordered_map<KIID, wxString> > NETLIST_EXPORTER_BASE::m_exportItemNets
protectedinherited

Definition at line 173 of file netlist_exporter_base.h.

Referenced by itemNetName(), and rebuildConnectivity().

◆ m_exportNets

◆ m_exportPath

wxString NETLIST_EXPORTER_ALLEGRO::m_exportPath
private

Directory to store device files.

Definition at line 227 of file netlist_exporter_allegro.h.

Referenced by toAllegroPackages(), and writeNetlist().

◆ m_exportSheets

◆ m_f

FILE* NETLIST_EXPORTER_ALLEGRO::m_f
private

File pointer for netlist file writing operation.

Definition at line 226 of file netlist_exporter_allegro.h.

Referenced by NETLIST_EXPORTER_ALLEGRO(), toAllegroNets(), toAllegroPackageProperties(), toAllegroPackages(), and writeNetlist().

◆ m_footprintPadCache

std::map<wxString, std::set<wxString> > NETLIST_EXPORTER_BASE::m_footprintPadCache
mutableprotectedinherited

Definition at line 238 of file netlist_exporter_base.h.

Referenced by footprintPads().

◆ m_kiway

KIWAY* NETLIST_EXPORTER_BASE::m_kiway = nullptr
protectedinherited

Definition at line 236 of file netlist_exporter_base.h.

Referenced by footprintPads(), resolvePadNumbers(), and SetKiway().

◆ m_libParts

std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> NETLIST_EXPORTER_BASE::m_libParts
protectedinherited

◆ m_netNameNodes

std::multimap<wxString, NET_NODE> NETLIST_EXPORTER_ALLEGRO::m_netNameNodes
private

Store the NET_NODE with the net name.

Definition at line 235 of file netlist_exporter_allegro.h.

Referenced by extractComponentsInfo(), toAllegroNets(), and writeNetlist().

◆ m_orderedSymbolsSheetpath

std::list<std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > NETLIST_EXPORTER_ALLEGRO::m_orderedSymbolsSheetpath
private

Store the ordered symbols with sheetpath.

Definition at line 234 of file netlist_exporter_allegro.h.

Referenced by extractComponentsInfo(), toAllegroPackages(), and writeNetlist().

◆ m_packageProperties

std::multimap<wxString, wxString> NETLIST_EXPORTER_ALLEGRO::m_packageProperties
private

◆ m_referencesAlreadyFound

UNIQUE_STRINGS NETLIST_EXPORTER_BASE::m_referencesAlreadyFound
protectedinherited

◆ m_schematic


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