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.name ) );
62 const wxString& aCacheDir )
const
72 KIBIS kibis( std::string(
path.c_str() ) );
73 kibis.
m_cacheDir = std::string( aCacheDir.c_str() );
76 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS file '%s'" ), ibisLibFilename ) );
81 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS component '%s'" ), ibisCompName ) );
87 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS component '%s'" ), ibisCompName ) );
91 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS pin '%s' in component '%s'" ),
98 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS pin '%s' in component '%s'" ),
106 THROW_IO_ERROR( wxString::Format(
_(
"Could not find IBIS model '%s'" ), ibisModelName ) );
109 THROW_IO_ERROR( wxString::Format(
_(
"Invalid IBIS model '%s'" ), ibisModelName ) );
131 case SIM_MODEL::TYPE::KIBIS_DEVICE:
138 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
140 std::string paramValue =
"";
143 paramValue = dc->value;
145 if( paramValue ==
"hi-Z" )
149 else if( paramValue ==
"low" )
153 else if( paramValue ==
"high" )
165 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
190 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
213 wxFAIL_MSG(
"Unknown IBIS model type" );
223 m_enableDiff( false ),
224 m_sourceModel( nullptr )
226 static std::vector<PARAM::INFO> device =
makeParamInfos( TYPE::KIBIS_DEVICE );
227 static std::vector<PARAM::INFO> dcDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_DC );
228 static std::vector<PARAM::INFO> rectDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_RECT );
229 static std::vector<PARAM::INFO> prbsDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_PRBS );
231 std::vector<PARAM::INFO>* paramInfos =
nullptr;
235 case SIM_MODEL::TYPE::KIBIS_DEVICE: paramInfos = &device;
break;
236 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC: paramInfos = &dcDriver;
break;
237 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT: paramInfos = &rectDriver;
break;
238 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS: paramInfos = &prbsDriver;
break;
265 AddPin( {
"IN/OUT",
"2" } );
274 for(
auto& param2refwrap : aSource.
GetParams() )
276 const PARAM& param2 = param2refwrap.get();
278 if( param1.info.name == param2.
info.
name )
325 std::vector<PARAM::INFO> paramInfos;
328 paramInfo.
name =
"vcc";
335 paramInfo.
enumValues = {
"typ",
"min",
"max" };
336 paramInfos.push_back( paramInfo );
338 paramInfo.
name =
"rpin";
343 paramInfo.
description =
_(
"Parasitic pin resistance" );
345 paramInfo.
enumValues = {
"typ",
"min",
"max" };
346 paramInfos.push_back( paramInfo );
348 paramInfo.
name =
"lpin";
353 paramInfo.
description =
_(
"Parasitic pin inductance" );
355 paramInfo.
enumValues = {
"typ",
"min",
"max" };
356 paramInfos.push_back( paramInfo );
358 paramInfo.
name =
"cpin";
363 paramInfo.
description =
_(
"Parasitic pin capacitance" );
365 paramInfo.
enumValues = {
"typ",
"min",
"max" };
366 paramInfos.push_back( paramInfo );
374 case TYPE::KIBIS_DRIVER_DC:
376 paramInfos.push_back( param );
379 case TYPE::KIBIS_DRIVER_RECT:
381 paramInfos.push_back( param );
384 case TYPE::KIBIS_DRIVER_PRBS:
386 paramInfos.push_back( param );
399 std::vector<PARAM::INFO> paramInfos;
402 paramInfo.
name =
"dc";
408 paramInfo.
enumValues = {
"hi-Z",
"low",
"high" };
409 paramInfos.push_back( paramInfo );
417 std::vector<PARAM::INFO> paramInfos;
420 paramInfo.
name =
"ton";
422 paramInfo.
unit =
"s";
426 paramInfos.push_back( paramInfo );
428 paramInfo.
name =
"toff";
430 paramInfo.
unit =
"s";
434 paramInfos.push_back( paramInfo );
436 paramInfo.
name =
"td";
438 paramInfo.
unit =
"s";
442 paramInfos.push_back( paramInfo );
444 paramInfo.
name =
"n";
450 paramInfos.push_back( paramInfo );
458 std::vector<PARAM::INFO> paramInfos;
461 paramInfo.
name =
"f0";
463 paramInfo.
unit =
"Hz";
467 paramInfos.push_back( paramInfo );
469 paramInfo.
name =
"td";
471 paramInfo.
unit =
"s";
475 paramInfos.push_back( paramInfo );
477 paramInfo.
name =
"n";
483 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.
static constexpr auto DIFF_FIELD
static constexpr auto MODEL_FIELD
static constexpr auto PIN_FIELD
static constexpr auto LIBRARY_FIELD
static constexpr auto NAME_FIELD
static wxString ResolveLibraryPath(const wxString &aLibraryPath, const PROJECT *aProject)
SIM_MODEL_KIBIS(TYPE aType)
bool ChangePin(const SIM_LIBRARY_KIBIS &aLib, std::string aPinNumber)
update the list of available models based on the pin number.
void SetBaseModel(const SIM_MODEL &aBaseModel) override
const SIM_MODEL_KIBIS * m_sourceModel
static std::vector< PARAM::INFO > makeRectWaveformParamInfos()
std::vector< std::string > GetIbisModels() const
static std::vector< PARAM::INFO > makeParamInfos(TYPE aType)
static std::vector< PARAM::INFO > makePrbsWaveformParamInfos()
std::string m_componentName
std::vector< std::pair< std::string, std::string > > m_ibisPins
static std::vector< PARAM::INFO > makeDcWaveformParamInfos()
std::vector< std::string > m_ibisModels
std::string GetComponentName() const
bool CanDifferential() const
void SwitchSingleEndedDiff(bool aDiff) override
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void AddParam(const PARAM::INFO &aInfo)
static std::string GetFieldValue(const std::vector< T > *aFields, const wxString &aFieldName, bool aResolve=true)
void AddPin(const PIN &aPin)
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::string ModelLine(const SPICE_ITEM &aItem) const override
std::vector< std::reference_wrapper< const SIM_MODEL::PARAM > > GetInstanceParams() const override
std::string IbisDevice(const SPICE_ITEM &aItem, const PROJECT &aProject, const wxString &aCacheDir) const
std::string ModelName(const SPICE_ITEM &aItem) const override
std::vector< std::string > CurrentNames(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
#define THROW_IO_ERROR(msg)
std::string spiceModelName
std::vector< std::string > enumValues
std::vector< SCH_FIELD > fields
std::string baseModelName