28#include <wx/filename.h>
45 std::vector<std::string> currentNames;
48 currentNames.push_back( fmt::format(
"I({}:{})",
ItemName( aItem ),
pin.modelPinName ) );
55 const wxString& aCacheDir,
70 KIBIS kibis( std::string(
path.c_str() ) );
71 kibis.
m_cacheDir = std::string( aCacheDir.c_str() );
75 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS file '%s'" ), ibisLibFilename ) );
80 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS component '%s'" ), ibisCompName ) );
86 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS component '%s'" ), ibisCompName ) );
90 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS pin '%s' in component '%s'" ),
97 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS pin '%s' in component '%s'" ),
105 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS model '%s'" ), ibisModelName ) );
108 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS model '%s'" ), ibisModelName ) );
130 case SIM_MODEL::TYPE::KIBIS_DEVICE:
137 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
139 std::string paramValue =
"";
142 paramValue = dc->value;
144 if( paramValue ==
"hi-Z" )
148 else if( paramValue ==
"low" )
152 else if( paramValue ==
"high" )
164 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
189 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
212 wxFAIL_MSG(
"Unknown IBIS model type" );
222 m_enableDiff( false ),
223 m_sourceModel( nullptr )
225 static std::vector<PARAM::INFO> device =
makeParamInfos( TYPE::KIBIS_DEVICE );
226 static std::vector<PARAM::INFO> dcDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_DC );
227 static std::vector<PARAM::INFO> rectDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_RECT );
228 static std::vector<PARAM::INFO> prbsDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_PRBS );
230 std::vector<PARAM::INFO>* paramInfos =
nullptr;
234 case SIM_MODEL::TYPE::KIBIS_DEVICE: paramInfos = &device;
break;
235 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC: paramInfos = &dcDriver;
break;
236 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT: paramInfos = &rectDriver;
break;
237 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS: paramInfos = &prbsDriver;
break;
264 AddPin( {
"IN/OUT",
"2" } );
277 if( param1.info.name == param2.
info.
name )
324 std::vector<PARAM::INFO> paramInfos;
327 paramInfo.
name =
"vcc";
334 paramInfo.
enumValues = {
"typ",
"min",
"max" };
335 paramInfos.push_back( paramInfo );
337 paramInfo.
name =
"rpin";
342 paramInfo.
description =
_(
"Parasitic pin resistance" );
344 paramInfo.
enumValues = {
"typ",
"min",
"max" };
345 paramInfos.push_back( paramInfo );
347 paramInfo.
name =
"lpin";
352 paramInfo.
description =
_(
"Parasitic pin inductance" );
354 paramInfo.
enumValues = {
"typ",
"min",
"max" };
355 paramInfos.push_back( paramInfo );
357 paramInfo.
name =
"cpin";
362 paramInfo.
description =
_(
"Parasitic pin capacitance" );
364 paramInfo.
enumValues = {
"typ",
"min",
"max" };
365 paramInfos.push_back( paramInfo );
373 case TYPE::KIBIS_DRIVER_DC:
375 paramInfos.push_back( param );
378 case TYPE::KIBIS_DRIVER_RECT:
380 paramInfos.push_back( param );
383 case TYPE::KIBIS_DRIVER_PRBS:
385 paramInfos.push_back( param );
398 std::vector<PARAM::INFO> paramInfos;
401 paramInfo.
name =
"dc";
407 paramInfo.
enumValues = {
"hi-Z",
"low",
"high" };
408 paramInfos.push_back( paramInfo );
416 std::vector<PARAM::INFO> paramInfos;
419 paramInfo.
name =
"ton";
421 paramInfo.
unit =
"s";
425 paramInfos.push_back( paramInfo );
427 paramInfo.
name =
"toff";
429 paramInfo.
unit =
"s";
433 paramInfos.push_back( paramInfo );
435 paramInfo.
name =
"td";
437 paramInfo.
unit =
"s";
441 paramInfos.push_back( paramInfo );
443 paramInfo.
name =
"n";
449 paramInfos.push_back( paramInfo );
457 std::vector<PARAM::INFO> paramInfos;
460 paramInfo.
name =
"f0";
462 paramInfo.
unit =
"Hz";
466 paramInfos.push_back( paramInfo );
468 paramInfo.
name =
"td";
470 paramInfo.
unit =
"s";
474 paramInfos.push_back( paramInfo );
476 paramInfo.
name =
"n";
482 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.
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
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
static wxString ResolveLibraryPath(const wxString &aLibraryPath, const PROJECT *aProject, REPORTER &aReporter)
SIM_MODEL_IBIS(TYPE aType)
static std::vector< PARAM::INFO > makeDcWaveformParamInfos()
std::vector< std::pair< std::string, std::string > > m_ibisPins
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)
static std::string GetFieldValue(const std::vector< SCH_FIELD > *aFields, const wxString &aFieldName, bool aResolve=true)
int GetParamCount() const
const PARAM * FindParam(const std::string &aParamName) 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::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
std::string IbisDevice(const SPICE_ITEM &aItem, const PROJECT &aProject, const wxString &aCacheDir, REPORTER &aReporter) const
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.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
const wxString & GetMessages() const
#define THROW_IO_ERROR(msg)
std::string spiceModelName
std::vector< std::string > enumValues
std::vector< SCH_FIELD > fields
std::string baseModelName