28#include <wx/filename.h>
45 std::vector<std::reference_wrapper<const SIM_MODEL::PARAM>> vec;
52 std::vector<std::string> currentNames;
55 currentNames.push_back( fmt::format(
"I({}:{})",
ItemName( aItem ),
pin.modelPinName ) );
62 const wxString& aCacheDir,
78 KIBIS kibis( std::string(
path.c_str() ) );
79 kibis.
m_cacheDir = std::string( aCacheDir.c_str() );
83 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS file '%s'" ), ibisLibFilename ) );
88 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS component '%s'" ), ibisCompName ) );
94 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS component '%s'" ), ibisCompName ) );
98 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS pin '%s' in component '%s'" ),
105 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS pin '%s' in component '%s'" ),
113 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS model '%s'" ), ibisModelName ) );
116 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS model '%s'" ), ibisModelName ) );
138 case SIM_MODEL::TYPE::KIBIS_DEVICE:
145 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
147 std::string paramValue =
"";
150 paramValue = dc->value;
152 if( paramValue ==
"hi-Z" )
156 else if( paramValue ==
"low" )
160 else if( paramValue ==
"high" )
172 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
197 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
220 wxFAIL_MSG(
"Unknown IBIS model type" );
230 m_enableDiff( false ),
231 m_sourceModel( nullptr )
233 static std::vector<PARAM::INFO> device =
makeParamInfos( TYPE::KIBIS_DEVICE );
234 static std::vector<PARAM::INFO> dcDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_DC );
235 static std::vector<PARAM::INFO> rectDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_RECT );
236 static std::vector<PARAM::INFO> prbsDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_PRBS );
238 std::vector<PARAM::INFO>* paramInfos =
nullptr;
242 case SIM_MODEL::TYPE::KIBIS_DEVICE: paramInfos = &device;
break;
243 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC: paramInfos = &dcDriver;
break;
244 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT: paramInfos = &rectDriver;
break;
245 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS: paramInfos = &prbsDriver;
break;
272 AddPin( {
"IN/OUT",
"2" } );
281 for(
auto& param2refwrap : aSource.
GetParams() )
283 const PARAM& param2 = param2refwrap.get();
285 if( param1.info.name == param2.
info.
name )
332 std::vector<PARAM::INFO> paramInfos;
335 paramInfo.
name =
"vcc";
342 paramInfo.
enumValues = {
"typ",
"min",
"max" };
343 paramInfos.push_back( paramInfo );
345 paramInfo.
name =
"rpin";
350 paramInfo.
description =
_(
"Parasitic pin resistance" );
352 paramInfo.
enumValues = {
"typ",
"min",
"max" };
353 paramInfos.push_back( paramInfo );
355 paramInfo.
name =
"lpin";
360 paramInfo.
description =
_(
"Parasitic pin inductance" );
362 paramInfo.
enumValues = {
"typ",
"min",
"max" };
363 paramInfos.push_back( paramInfo );
365 paramInfo.
name =
"cpin";
370 paramInfo.
description =
_(
"Parasitic pin capacitance" );
372 paramInfo.
enumValues = {
"typ",
"min",
"max" };
373 paramInfos.push_back( paramInfo );
381 case TYPE::KIBIS_DRIVER_DC:
383 paramInfos.push_back( param );
386 case TYPE::KIBIS_DRIVER_RECT:
388 paramInfos.push_back( param );
391 case TYPE::KIBIS_DRIVER_PRBS:
393 paramInfos.push_back( param );
406 std::vector<PARAM::INFO> paramInfos;
409 paramInfo.
name =
"dc";
415 paramInfo.
enumValues = {
"hi-Z",
"low",
"high" };
416 paramInfos.push_back( paramInfo );
424 std::vector<PARAM::INFO> paramInfos;
427 paramInfo.
name =
"ton";
429 paramInfo.
unit =
"s";
433 paramInfos.push_back( paramInfo );
435 paramInfo.
name =
"toff";
437 paramInfo.
unit =
"s";
441 paramInfos.push_back( paramInfo );
443 paramInfo.
name =
"td";
445 paramInfo.
unit =
"s";
449 paramInfos.push_back( paramInfo );
451 paramInfo.
name =
"n";
457 paramInfos.push_back( paramInfo );
465 std::vector<PARAM::INFO> paramInfos;
468 paramInfo.
name =
"f0";
470 paramInfo.
unit =
"Hz";
474 paramInfos.push_back( paramInfo );
476 paramInfo.
name =
"td";
478 paramInfo.
unit =
"s";
482 paramInfos.push_back( paramInfo );
484 paramInfo.
name =
"n";
490 paramInfos.push_back( paramInfo );
KIBIS_PIN * GetPin(std::string aPinNumber)
Get a pin by its number ( 1, 2, A1, A2, ... )
void SetCornerFromString(IBIS_CORNER &aCorner, std::string aString)
KIBIS_WAVEFORM * m_waveform
bool writeSpiceDiffDriver(std::string *aDest, std::string aName, KIBIS_MODEL &aModel, KIBIS_PARAMETER &aParam)
bool writeSpiceDiffDevice(std::string *aDest, std::string aName, KIBIS_MODEL &aModel, KIBIS_PARAMETER &aParam)
std::vector< KIBIS_MODEL * > m_models
bool writeSpiceDriver(std::string *aDest, std::string aName, KIBIS_MODEL &aModel, KIBIS_PARAMETER &aParam)
bool writeSpiceDevice(std::string *aDest, std::string aName, KIBIS_MODEL &aModel, KIBIS_PARAMETER &aParam)
KIBIS_COMPONENT * GetComponent(std::string aName)
Return the component with name aName .
KIBIS_MODEL * GetModel(std::string aName)
Return the model 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()
static std::vector< PARAM::INFO > makePrbsWaveformParamInfos()
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void SwitchSingleEndedDiff(bool aDiff) override
bool ChangePin(const SIM_LIBRARY_IBIS &aLib, std::string aPinNumber)
update the list of available models based on the pin number.
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
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)
const PARAM * FindParam(const std::string &aParamName) const
std::vector< PARAM > m_params
std::vector< std::reference_wrapper< const PARAM > > GetParams() const
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::vector< std::reference_wrapper< const SIM_MODEL::PARAM > > GetInstanceParams() 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.
#define THROW_IO_ERROR(msg)
std::string spiceModelName
std::vector< std::string > enumValues
std::vector< SCH_FIELD > fields
std::string baseModelName