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

#include <ibis_parser.h>

Inheritance diagram for IbisParser:
IBIS_INPUT IBIS_BASE

Public Member Functions

 IbisParser (REPORTER *aReporter)
 
bool ParseFile (const std::string &aFileName)
 Parse a file.
 
virtual bool Check ()
 Check if the data held by the object is valid.
 
void Report (const std::string &aMsg, SEVERITY aSeverity=RPT_SEVERITY_INFO) const
 Print a message.
 

Public Attributes

bool m_parrot = true
 
long m_lineCounter = 0
 
char m_commentChar = '|'
 
std::vector< char > m_buffer
 
int m_bufferIndex = 0
 
int m_lineOffset = 0
 
int m_lineIndex = 0
 
int m_lineLength = 0
 
IbisFile m_ibisFile
 
IbisComponentm_currentComponent = nullptr
 
IbisModelSelectorm_currentModelSelector = nullptr
 
IbisModelm_currentModel = nullptr
 
IbisSubmodelm_currentSubmodel = nullptr
 
IbisPackageModelm_currentPackageModel = nullptr
 
std::shared_ptr< IBIS_MATRIXm_currentMatrix = nullptr
 
int m_currentMatrixRow = 0
 
int m_currentMatrixCol = 0
 
IVtablem_currentIVtable = nullptr
 
VTtablem_currentVTtable = nullptr
 
IbisWaveformm_currentWaveform = nullptr
 
REPORTERm_Reporter
 

Static Protected Member Functions

static std::string doubleToString (double aNumber)
 Convert a double to string using scientific notation.
 

Private Member Functions

bool compareIbisWord (const std::string &a, const std::string &b)
 compare two strings without being case sensitive
 
bool parseHeader (std::string &aKeyword)
 Parse a single keyword in the header context.
 
bool parseComponent (std::string &aKeyword)
 Parse a single keyword in the component context.
 
bool parseModelSelector (std::string &aKeyword)
 Parse a single keyword in the model selector context.
 
bool parseModel (std::string &aKeyword)
 Parse a single keyword in the model context.
 
bool parseSubmodel (std::string &aKeyword)
 Parse a single keyword in the submodel context.
 
bool parsePackageModel (std::string &aKeyword)
 Parse a single keyword in the package model context.
 
bool parsePackageModelModelData (std::string &aKeyword)
 Parse a single keyword in the package model model data context.
 
bool parseAlgorithmicModel (std::string &aKeyword)
 Parse a single keyword in the algorithmic model context.
 
bool parseDouble (double &aDest, std::string &aStr, bool aAllowModifiers=false)
 Parse a double according to the ibis standard.
 
bool parseDvdt (dvdt &aDest, std::string &aStr)
 Parse a dV/dt value according to the ibis standard.
 
bool onNewLine ()
 Parse the current line.
 
bool getNextLine ()
 Load the next line.
 
void printLine ()
 Print the current line.
 
void skipWhitespaces ()
 
bool checkEndofLine ()
 
bool isLineEmptyFromCursor ()
 
std::string getKeyword ()
 
bool readInt (int &aDest)
 
bool readDouble (double &aDest)
 
bool readWord (std::string &aDest)
 
bool readDvdt (dvdt &aDest)
 
bool readMatrixPinIndex (int &aDest)
 
bool readMatrixType (std::shared_ptr< IBIS_MATRIX > &aDest)
 
bool readMatrixBandwidth ()
 
bool readMatrixRow ()
 
bool readMatrixBandedOrFull ()
 
bool readMatrixSparse ()
 
bool readMatrixData ()
 
bool readRampdvdt (dvdtTypMinMax &aDest)
 
bool readRamp ()
 
bool readModelSpec ()
 
bool readSubmodelSpec ()
 
bool readReceiverThresholds ()
 
bool readAlgorithmicModel ()
 
bool readAddSubmodel ()
 
bool readWaveform (IbisWaveform *aDest, IBIS_WAVEFORM_TYPE aType)
 
bool readString (std::string &aDest)
 
bool storeString (std::string &aDest, bool aMultiline)
 
bool readTableLine (std::vector< std::string > &aDest)
 
bool readNumericSubparam (const std::string &aSubparam, double &aDest)
 
bool readIVtableEntry (IVtable &aTable)
 
bool readVTtableEntry (VTtable &aTable)
 
bool readTypMinMaxValue (TypMinMaxValue &aDest)
 
bool readTypMinMaxValueSubparam (const std::string &aSubparam, TypMinMaxValue &aDest)
 
bool readPackage ()
 
bool readPin ()
 
bool readPinMapping ()
 
bool readDiffPin ()
 
bool readModelSelector ()
 
bool readModel ()
 
bool readSubmodel ()
 
bool readPackageModelPins ()
 
bool changeCommentChar ()
 Ibis can change the character used for comments.
 
bool changeContext (std::string &aKeyword)
 

Private Attributes

std::string * m_continuingString = nullptr
 
IBIS_PARSER_CONTINUE m_continue = IBIS_PARSER_CONTINUE::NONE
 
IBIS_PARSER_CONTEXT m_context = IBIS_PARSER_CONTEXT::HEADER
 

Detailed Description

Definition at line 750 of file ibis_parser.h.

Constructor & Destructor Documentation

◆ IbisParser()

IbisParser::IbisParser ( REPORTER * aReporter)
inline

Definition at line 753 of file ibis_parser.h.

References IBIS_INPUT::IBIS_INPUT(), and m_ibisFile.

Member Function Documentation

◆ changeCommentChar()

bool IbisParser::changeCommentChar ( )
private

Ibis can change the character used for comments.

Definition at line 1387 of file ibis_parser.cpp.

References _, m_buffer, m_commentChar, m_continue, m_lineIndex, m_lineOffset, NONE, IBIS_BASE::Report(), RPT_SEVERITY_ERROR, and skipWhitespaces().

Referenced by parseHeader().

◆ changeContext()

◆ Check()

virtual bool IBIS_INPUT::Check ( )
inlinevirtualinherited

Check if the data held by the object is valid.

Returns
true in case of success

Reimplemented in dvdtTypMinMax, IBIS_MATRIX, IbisComponent, IbisComponentPackage, IbisComponentPin, IbisHeader, IbisModel, IbisModelSelector, IbisPackageModel, IbisRamp, IbisSubmodel, IVtable, and TypMinMaxValue.

Definition at line 98 of file ibis_parser.h.

◆ checkEndofLine()

bool IbisParser::checkEndofLine ( )
private

Definition at line 1069 of file ibis_parser.cpp.

References _, m_lineIndex, m_lineLength, IBIS_BASE::Report(), RPT_SEVERITY_ERROR, and skipWhitespaces().

Referenced by storeString().

◆ compareIbisWord()

bool IbisParser::compareIbisWord ( const std::string & a,
const std::string & b )
private

compare two strings without being case sensitive

Ibis: "The content of the files is case sensitive, except for reserved words and keywords."

Parameters
astring to compare
bstring to compare
Returns
true if the string are equal

Definition at line 52 of file ibis_parser.cpp.

Referenced by changeContext(), parseAlgorithmicModel(), parseComponent(), parseHeader(), parseModel(), parsePackageModel(), parsePackageModelModelData(), parseSubmodel(), readMatrixType(), and readModel().

◆ doubleToString()

std::string IBIS_BASE::doubleToString ( double aNumber)
staticprotectedinherited

Convert a double to string using scientific notation.

Parameters
aNumberNumber
Returns
Output string

Definition at line 281 of file ibis_parser.cpp.

Referenced by KIBIS_MODEL::generateSquareWave(), KIBIS_PIN::getKuKdOneWaveform(), KIBIS_PIN::getKuKdTwoWaveforms(), KIBIS_PIN::KuKdDriver(), IVtable::Spice(), KIBIS_MODEL::SpiceDie(), KIBIS_PIN::writeSpiceDevice(), and KIBIS_PIN::writeSpiceDriver().

◆ getKeyword()

std::string IbisParser::getKeyword ( )
private

Definition at line 1437 of file ibis_parser.cpp.

References m_buffer, m_lineIndex, m_lineLength, and m_lineOffset.

Referenced by onNewLine().

◆ getNextLine()

bool IbisParser::getNextLine ( )
private

Load the next line.

Returns
True in case of success

Definition at line 1210 of file ibis_parser.cpp.

References _, IBIS_MAX_LINE_LENGTH, m_buffer, m_bufferIndex, m_commentChar, m_lineCounter, m_lineIndex, m_lineLength, m_lineOffset, IBIS_BASE::Report(), and RPT_SEVERITY_ERROR.

Referenced by ParseFile().

◆ isLineEmptyFromCursor()

bool IbisParser::isLineEmptyFromCursor ( )
private

Definition at line 1083 of file ibis_parser.cpp.

References cursor, m_buffer, m_lineIndex, m_lineLength, and m_lineOffset.

Referenced by readWaveform().

◆ onNewLine()

◆ parseAlgorithmicModel()

bool IbisParser::parseAlgorithmicModel ( std::string & aKeyword)
private

Parse a single keyword in the algorithmic model context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 1703 of file ibis_parser.cpp.

References changeContext(), compareIbisWord(), m_context, m_continue, MODEL, and NONE.

Referenced by onNewLine().

◆ parseComponent()

bool IbisParser::parseComponent ( std::string & aKeyword)
private

Parse a single keyword in the component context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 2515 of file ibis_parser.cpp.

References changeContext(), compareIbisWord(), m_currentComponent, readDiffPin(), readPackage(), readPin(), readPinMapping(), and storeString().

Referenced by onNewLine().

◆ parseDouble()

bool IbisParser::parseDouble ( double & aDest,
std::string & aStr,
bool aAllowModifiers = false )
private

Parse a double according to the ibis standard.

Parameters
aDestWhere the double should be stored
aStrThe string to parse
aAllowModifiersAllows modifiers ( p for pico, f for femto, k for kilo, ... )
Returns
True in case of success

Definition at line 1152 of file ibis_parser.cpp.

References NAN_INVALID, NAN_NA, result, and skipWhitespaces().

Referenced by parseDvdt(), readDouble(), readMatrixBandedOrFull(), readPackage(), and readPin().

◆ parseDvdt()

bool IbisParser::parseDvdt ( dvdt & aDest,
std::string & aStr )
private

Parse a dV/dt value according to the ibis standard.

Parameters
aDestWhere the dV/dt value should be stored
aStrThe string to parse
Returns
True in case of success

Definition at line 1094 of file ibis_parser.cpp.

References dvdt::m_dt, dvdt::m_dv, NAN_NA, and parseDouble().

Referenced by readDvdt().

◆ ParseFile()

bool IbisParser::ParseFile ( const std::string & aFileName)

Parse a file.

This is the entry point to parse a file

Parameters
aFileNameinput file name
Returns
True in case of success

Definition at line 987 of file ibis_parser.cpp.

References _, END, getNextLine(), m_buffer, m_bufferIndex, m_context, m_ibisFile, m_lineCounter, IbisSubmodelMode::m_name, m_parrot, model, onNewLine(), printLine(), IBIS_BASE::Report(), and RPT_SEVERITY_ERROR.

Referenced by KIBIS::KIBIS().

◆ parseHeader()

bool IbisParser::parseHeader ( std::string & aKeyword)
private

Parse a single keyword in the header context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 2466 of file ibis_parser.cpp.

References changeCommentChar(), changeContext(), compareIbisWord(), m_ibisFile, readDouble(), and storeString().

Referenced by onNewLine().

◆ parseModel()

bool IbisParser::parseModel ( std::string & aKeyword)
private

Parse a single keyword in the model context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 1772 of file ibis_parser.cpp.

References ALGORITHMIC_MODEL, changeContext(), compareIbisWord(), FALLING, m_context, m_continue, m_currentModel, readAddSubmodel(), readIVtableEntry(), readModelSpec(), readRamp(), readReceiverThresholds(), readTypMinMaxValue(), readWaveform(), and RISING.

Referenced by onNewLine().

◆ parseModelSelector()

bool IbisParser::parseModelSelector ( std::string & aKeyword)
private

Parse a single keyword in the model selector context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 1598 of file ibis_parser.cpp.

References changeContext().

Referenced by onNewLine().

◆ parsePackageModel()

bool IbisParser::parsePackageModel ( std::string & aKeyword)
private

Parse a single keyword in the package model context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 2144 of file ibis_parser.cpp.

References changeContext(), compareIbisWord(), m_context, m_continue, m_currentPackageModel, NONE, PACKAGEMODEL_MODELDATA, readInt(), readPackageModelPins(), and storeString().

Referenced by onNewLine().

◆ parsePackageModelModelData()

bool IbisParser::parsePackageModelModelData ( std::string & aKeyword)
private

Parse a single keyword in the package model model data context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 2107 of file ibis_parser.cpp.

References changeContext(), compareIbisWord(), m_context, m_continue, m_currentPackageModel, NONE, PACKAGEMODEL, readMatrixBandwidth(), readMatrixRow(), and readMatrixType().

Referenced by onNewLine().

◆ parseSubmodel()

bool IbisParser::parseSubmodel ( std::string & aKeyword)
private

Parse a single keyword in the submodel context.

Parameters
aKeywordKeyword
Returns
True in case of success

Definition at line 1866 of file ibis_parser.cpp.

References changeContext(), compareIbisWord(), FALLING, m_currentSubmodel, readIVtableEntry(), readRamp(), readSubmodelSpec(), readWaveform(), and RISING.

Referenced by onNewLine().

◆ printLine()

void IbisParser::printLine ( )
private

Print the current line.

Definition at line 1256 of file ibis_parser.cpp.

References m_buffer, m_lineLength, and m_lineOffset.

Referenced by ParseFile().

◆ readAddSubmodel()

bool IbisParser::readAddSubmodel ( )
private

◆ readAlgorithmicModel()

bool IbisParser::readAlgorithmicModel ( )
private

Definition at line 1693 of file ibis_parser.cpp.

Referenced by onNewLine().

◆ readDiffPin()

◆ readDouble()

bool IbisParser::readDouble ( double & aDest)
private

◆ readDvdt()

bool IbisParser::readDvdt ( dvdt & aDest)
private

Definition at line 1127 of file ibis_parser.cpp.

References _, parseDvdt(), readWord(), IBIS_BASE::Report(), and RPT_SEVERITY_WARNING.

Referenced by readRampdvdt().

◆ readInt()

bool IbisParser::readInt ( int & aDest)
private

◆ readIVtableEntry()

◆ readMatrixBandedOrFull()

bool IbisParser::readMatrixBandedOrFull ( )
private

◆ readMatrixBandwidth()

bool IbisParser::readMatrixBandwidth ( )
private

◆ readMatrixData()

bool IbisParser::readMatrixData ( )
private

Definition at line 2080 of file ibis_parser.cpp.

References BANDED, FULL, m_currentMatrix, readMatrixBandedOrFull(), readMatrixSparse(), SPARSE, and UNDEFINED.

Referenced by onNewLine().

◆ readMatrixPinIndex()

bool IbisParser::readMatrixPinIndex ( int & aDest)
private

Definition at line 1908 of file ibis_parser.cpp.

References _, m_currentPackageModel, pin, readWord(), and IBIS_BASE::Report().

Referenced by readMatrixRow(), and readMatrixSparse().

◆ readMatrixRow()

bool IbisParser::readMatrixRow ( )
private

◆ readMatrixSparse()

bool IbisParser::readMatrixSparse ( )
private

◆ readMatrixType()

◆ readModel()

◆ readModelSelector()

bool IbisParser::readModelSelector ( )
private

Definition at line 2171 of file ibis_parser.cpp.

References m_currentModelSelector, model, readString(), and readWord().

Referenced by onNewLine().

◆ readModelSpec()

bool IbisParser::readModelSpec ( )
private

Definition at line 1665 of file ibis_parser.cpp.

References m_continue, and MODEL_SPEC.

Referenced by onNewLine(), and parseModel().

◆ readNumericSubparam()

bool IbisParser::readNumericSubparam ( const std::string & aSubparam,
double & aDest )
private

◆ readPackage()

bool IbisParser::readPackage ( )
private

◆ readPackageModelPins()

bool IbisParser::readPackageModelPins ( )
private

Definition at line 1897 of file ibis_parser.cpp.

References m_continue, m_currentPackageModel, PACKAGEMODEL_PINS, and readWord().

Referenced by onNewLine(), and parsePackageModel().

◆ readPin()

bool IbisParser::readPin ( )
private

◆ readPinMapping()

◆ readRamp()

◆ readRampdvdt()

bool IbisParser::readRampdvdt ( dvdtTypMinMax & aDest)
private

Definition at line 1609 of file ibis_parser.cpp.

References MAX, MIN, readDvdt(), TYP, and dvdtTypMinMax::value.

Referenced by readRamp().

◆ readReceiverThresholds()

bool IbisParser::readReceiverThresholds ( )
private

Definition at line 1679 of file ibis_parser.cpp.

References m_continue, and RX_THRESHOLDS.

Referenced by onNewLine(), and parseModel().

◆ readString()

bool IbisParser::readString ( std::string & aDest)
private

Definition at line 1346 of file ibis_parser.cpp.

References m_buffer, m_lineIndex, m_lineLength, and m_lineOffset.

Referenced by onNewLine(), readModelSelector(), and storeString().

◆ readSubmodel()

bool IbisParser::readSubmodel ( )
private

◆ readSubmodelSpec()

bool IbisParser::readSubmodelSpec ( )
private

◆ readTableLine()

bool IbisParser::readTableLine ( std::vector< std::string > & aDest)
private

◆ readTypMinMaxValue()

◆ readTypMinMaxValueSubparam()

bool IbisParser::readTypMinMaxValueSubparam ( const std::string & aSubparam,
TypMinMaxValue & aDest )
private

Definition at line 2246 of file ibis_parser.cpp.

References m_buffer, m_lineIndex, m_lineLength, m_lineOffset, and readTypMinMaxValue().

Referenced by readModel().

◆ readVTtableEntry()

◆ readWaveform()

◆ readWord()

◆ Report()

void IBIS_BASE::Report ( const std::string & aMsg,
SEVERITY aSeverity = RPT_SEVERITY_INFO ) const
inlineinherited

Print a message.

Call m_Reporter->Report if m_Reporter exists.

Parameters
aMsgMessage
aSeverityMessage sevirity

Definition at line 68 of file ibis_parser.h.

References m_Reporter, and RPT_SEVERITY_INFO.

Referenced by BOOST_AUTO_TEST_CASE(), IbisParser::changeCommentChar(), IbisParser::changeContext(), IBIS_MATRIX::Check(), IbisComponent::Check(), IbisComponentPackage::Check(), IbisComponentPin::Check(), IbisHeader::Check(), IbisModel::Check(), IbisPackageModel::Check(), IbisRamp::Check(), IbisSubmodel::Check(), IVtable::Check(), KIBIS_WAVEFORM_PRBS::Check(), KIBIS_WAVEFORM_PRBS::Check(), KIBIS_WAVEFORM_RECTANGULAR::Check(), KIBIS_WAVEFORM_RECTANGULAR::Check(), IbisParser::checkEndofLine(), KIBIS_PIN::getKuKdFromFile(), KIBIS_PIN::getKuKdOneWaveform(), KIBIS_PIN::getKuKdTwoWaveforms(), IbisParser::getNextLine(), IVtable::InterpolatedI(), KIBIS_PIN::KuKdDriver(), IbisParser::onNewLine(), IbisParser::ParseFile(), IbisParser::readAddSubmodel(), IbisParser::readDiffPin(), IbisParser::readDouble(), IbisParser::readDvdt(), IbisParser::readInt(), IbisParser::readMatrixBandedOrFull(), IbisParser::readMatrixBandwidth(), IbisParser::readMatrixPinIndex(), IbisParser::readMatrixRow(), IbisParser::readMatrixSparse(), IbisParser::readMatrixType(), IbisParser::readModel(), IbisParser::readPackage(), IbisParser::readPin(), IbisParser::readPinMapping(), IbisParser::readRamp(), IbisParser::readSubmodel(), IbisParser::readSubmodelSpec(), IbisParser::readTypMinMaxValue(), IbisParser::readWaveform(), KIBIS_MODEL::TrimWaveform(), KIBIS_PIN::writeSpiceDevice(), and KIBIS_PIN::writeSpiceDriver().

◆ skipWhitespaces()

◆ storeString()

bool IbisParser::storeString ( std::string & aDest,
bool aMultiline )
private

Member Data Documentation

◆ m_buffer

◆ m_bufferIndex

int IbisParser::m_bufferIndex = 0

Definition at line 763 of file ibis_parser.h.

Referenced by getNextLine(), and ParseFile().

◆ m_commentChar

char IbisParser::m_commentChar = '|'

Definition at line 761 of file ibis_parser.h.

Referenced by changeCommentChar(), and getNextLine().

◆ m_context

◆ m_continue

◆ m_continuingString

std::string* IbisParser::m_continuingString = nullptr
private

Definition at line 791 of file ibis_parser.h.

Referenced by onNewLine(), and storeString().

◆ m_currentComponent

IbisComponent* IbisParser::m_currentComponent = nullptr

◆ m_currentIVtable

IVtable* IbisParser::m_currentIVtable = nullptr

Definition at line 777 of file ibis_parser.h.

Referenced by onNewLine(), and readIVtableEntry().

◆ m_currentMatrix

std::shared_ptr<IBIS_MATRIX> IbisParser::m_currentMatrix = nullptr

◆ m_currentMatrixCol

int IbisParser::m_currentMatrixCol = 0

Definition at line 776 of file ibis_parser.h.

Referenced by readMatrixBandedOrFull(), readMatrixRow(), and readMatrixType().

◆ m_currentMatrixRow

int IbisParser::m_currentMatrixRow = 0

◆ m_currentModel

IbisModel* IbisParser::m_currentModel = nullptr

◆ m_currentModelSelector

IbisModelSelector* IbisParser::m_currentModelSelector = nullptr

Definition at line 770 of file ibis_parser.h.

Referenced by changeContext(), and readModelSelector().

◆ m_currentPackageModel

◆ m_currentSubmodel

IbisSubmodel* IbisParser::m_currentSubmodel = nullptr

◆ m_currentVTtable

VTtable* IbisParser::m_currentVTtable = nullptr

Definition at line 778 of file ibis_parser.h.

Referenced by onNewLine(), and readVTtableEntry().

◆ m_currentWaveform

IbisWaveform* IbisParser::m_currentWaveform = nullptr

Definition at line 779 of file ibis_parser.h.

Referenced by onNewLine(), and readWaveform().

◆ m_ibisFile

◆ m_lineCounter

long IbisParser::m_lineCounter = 0

Definition at line 760 of file ibis_parser.h.

Referenced by getNextLine(), and ParseFile().

◆ m_lineIndex

◆ m_lineLength

◆ m_lineOffset

◆ m_parrot

bool IbisParser::m_parrot = true

Definition at line 758 of file ibis_parser.h.

Referenced by KIBIS::KIBIS(), and ParseFile().

◆ m_Reporter


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