28#include <wx/filename.h>
46 std::vector<std::string> currentNames;
49 currentNames.push_back( fmt::format(
"I({}:{})",
ItemName( aItem ),
pin.modelPinName ) );
56 const wxString& aCacheDir,
REPORTER& aReporter )
const
67 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
76 KIBIS kibis( std::string(
path.c_str() ) );
77 kibis.
m_cacheDir = std::string( aCacheDir.c_str() );
81 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS file '%s'" ), ibisLibFilename ) );
86 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS component '%s'" ), ibisCompName ) );
92 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS component '%s'" ), ibisCompName ) );
96 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS pin '%s' in component '%s'" ),
103 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS pin '%s' in component '%s'" ),
111 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS model '%s'" ), ibisModelName ) );
114 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS model '%s'" ), ibisModelName ) );
136 case SIM_MODEL::TYPE::KIBIS_DEVICE:
144 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
146 std::string paramValue =
"";
149 paramValue = dc->value;
151 if( paramValue ==
"hi-Z" )
153 else if( paramValue ==
"low" )
155 else if( paramValue ==
"high" )
166 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
192 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
216 wxFAIL_MSG(
"Unknown IBIS model type" );
229 static std::vector<PARAM::INFO> device =
makeParamInfos( TYPE::KIBIS_DEVICE );
230 static std::vector<PARAM::INFO> dcDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_DC );
231 static std::vector<PARAM::INFO> rectDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_RECT );
232 static std::vector<PARAM::INFO> prbsDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_PRBS );
234 std::vector<PARAM::INFO>* paramInfos =
nullptr;
238 case SIM_MODEL::TYPE::KIBIS_DEVICE: paramInfos = &device;
break;
239 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC: paramInfos = &dcDriver;
break;
240 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT: paramInfos = &rectDriver;
break;
241 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS: paramInfos = &prbsDriver;
break;
242 default: wxFAIL;
return;
245 for(
const PARAM::INFO& paramInfo : *paramInfos )
265 AddPin( {
"IN/OUT",
"2" } );
278 if( param1.info.name == param2.
info.
name )
325 std::vector<PARAM::INFO> paramInfos;
326 PARAM::INFO paramInfo;
328 paramInfo.name =
"vcc";
331 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
332 paramInfo.defaultValue =
"typ";
333 paramInfo.description =
_(
"Power supply" );
334 paramInfo.spiceModelName =
"";
335 paramInfo.enumValues = {
"typ",
"min",
"max" };
336 paramInfos.push_back( paramInfo );
338 paramInfo.name =
"rpin";
341 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
342 paramInfo.defaultValue =
"typ";
343 paramInfo.description =
_(
"Parasitic pin resistance" );
344 paramInfo.spiceModelName =
"";
345 paramInfo.enumValues = {
"typ",
"min",
"max" };
346 paramInfos.push_back( paramInfo );
348 paramInfo.name =
"lpin";
351 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
352 paramInfo.defaultValue =
"typ";
353 paramInfo.description =
_(
"Parasitic pin inductance" );
354 paramInfo.spiceModelName =
"";
355 paramInfo.enumValues = {
"typ",
"min",
"max" };
356 paramInfos.push_back( paramInfo );
358 paramInfo.name =
"cpin";
361 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
362 paramInfo.defaultValue =
"typ";
363 paramInfo.description =
_(
"Parasitic pin capacitance" );
364 paramInfo.spiceModelName =
"";
365 paramInfo.enumValues = {
"typ",
"min",
"max" };
366 paramInfos.push_back( paramInfo );
374 case TYPE::KIBIS_DRIVER_DC:
376 paramInfos.push_back( param );
380 case TYPE::KIBIS_DRIVER_RECT:
382 paramInfos.push_back( param );
386 case TYPE::KIBIS_DRIVER_PRBS:
388 paramInfos.push_back( param );
402 std::vector<PARAM::INFO> paramInfos;
403 PARAM::INFO paramInfo;
405 paramInfo.name =
"dc";
408 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
409 paramInfo.defaultValue =
"hi-Z";
410 paramInfo.description =
_(
"DC Value" );
411 paramInfo.enumValues = {
"hi-Z",
"low",
"high" };
412 paramInfos.push_back( paramInfo );
420 std::vector<PARAM::INFO> paramInfos;
421 PARAM::INFO paramInfo;
423 paramInfo.name =
"ton";
425 paramInfo.unit =
"s";
426 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
427 paramInfo.defaultValue =
"";
428 paramInfo.description =
_(
"ON time" );
429 paramInfos.push_back( paramInfo );
431 paramInfo.name =
"toff";
433 paramInfo.unit =
"s";
434 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
435 paramInfo.defaultValue =
"";
436 paramInfo.description =
_(
"OFF time" );
437 paramInfos.push_back( paramInfo );
439 paramInfo.name =
"td";
441 paramInfo.unit =
"s";
442 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
443 paramInfo.defaultValue =
"0";
444 paramInfo.description =
_(
"Delay" );
445 paramInfos.push_back( paramInfo );
447 paramInfo.name =
"n";
450 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
451 paramInfo.defaultValue =
"1";
452 paramInfo.description =
_(
"Number of cycles" );
453 paramInfos.push_back( paramInfo );
461 std::vector<PARAM::INFO> paramInfos;
462 PARAM::INFO paramInfo;
464 paramInfo.name =
"f0";
466 paramInfo.unit =
"Hz";
467 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
468 paramInfo.defaultValue =
"";
469 paramInfo.description =
_(
"Bitrate" );
470 paramInfos.push_back( paramInfo );
472 paramInfo.name =
"td";
474 paramInfo.unit =
"s";
475 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
476 paramInfo.defaultValue =
"";
477 paramInfo.description =
_(
"Delay" );
478 paramInfos.push_back( paramInfo );
480 paramInfo.name =
"n";
483 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
484 paramInfo.defaultValue =
"";
485 paramInfo.description =
_(
"Number of bits" );
486 paramInfos.push_back( paramInfo );
KIBIS_PIN * GetPin(const std::string &aPinNumber)
Get a pin by its number ( 1, 2, A1, A2, ... )
void SetCornerFromString(IBIS_CORNER &aCorner, const std::string &aString)
KIBIS_WAVEFORM * m_waveform
bool writeSpiceDiffDriver(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
bool writeSpiceDevice(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
std::vector< KIBIS_MODEL * > m_models
bool writeSpiceDiffDevice(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
bool writeSpiceDriver(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
KIBIS_MODEL * GetModel(const std::string &aName)
Return the model with name aName .
KIBIS_COMPONENT * GetComponent(const std::string &aName)
Return the component with name aName .
std::string m_cacheDir
Absolute path of the directory that will be used for caching.
A pure virtual class used to derive REPORTER objects from.
virtual bool HasMessage() const
Returns true if any messages were reported.
Holds all the data relating to one schematic.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
EMBEDDED_FILES * GetEmbeddedFiles() override
static constexpr auto MODEL_FIELD
static constexpr auto PIN_FIELD
static constexpr auto DIFF_FIELD
static constexpr auto LIBRARY_FIELD
static constexpr auto NAME_FIELD
wxString ResolveLibraryPath(const wxString &aLibraryPath, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
SIM_MODEL_IBIS(TYPE aType)
static std::vector< PARAM::INFO > makeDcWaveformParamInfos()
std::vector< std::pair< std::string, std::string > > m_ibisPins
friend class SIM_LIBRARY_IBIS
std::vector< std::string > m_ibisModels
static std::vector< PARAM::INFO > makeRectWaveformParamInfos()
const PARAM & GetParam(unsigned aParamIndex) const override
static std::vector< PARAM::INFO > makePrbsWaveformParamInfos()
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void SwitchSingleEndedDiff(bool aDiff) override
const SIM_MODEL_IBIS * m_sourceModel
bool CanDifferential() const
std::vector< std::string > GetIbisModels() const
std::string m_componentName
void SetBaseModel(const SIM_MODEL &aBaseModel) override
bool ChangePin(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber)
update the list of available models based on the pin number.
static std::vector< PARAM::INFO > makeParamInfos(TYPE aType)
std::string GetComponentName() const
void AddParam(const PARAM::INFO &aInfo)
void AddPin(const SIM_MODEL_PIN &aPin)
int GetParamCount() const
std::vector< PARAM > m_params
static double ToDouble(const std::string &aString, double aDefault=NAN)
static int ToInt(const std::string &aString, int aDefault=-1)
std::string IbisDevice(const SPICE_ITEM &aItem, SCHEMATIC *aSchematic, const wxString &aCacheDir, REPORTER &aReporter) const
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
std::string ModelLine(const SPICE_ITEM &aItem) const override
std::string ModelName(const SPICE_ITEM &aItem) const override
virtual std::string ItemName(const SPICE_ITEM &aItem) const
virtual std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
const SIM_MODEL & m_model
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
wxString GetFieldValue(const std::vector< SCH_FIELD > *aFields, FIELD_T aFieldType)
std::vector< SCH_FIELD > fields
std::string baseModelName
wxString result
Test unit parsing edge cases and error handling.