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:
143 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
145 std::string paramValue =
"";
148 paramValue = dc->value;
150 if( paramValue ==
"hi-Z" )
154 else if( paramValue ==
"low" )
158 else if( paramValue ==
"high" )
170 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
195 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
218 wxFAIL_MSG(
"Unknown IBIS model type" );
228 m_enableDiff( false ),
229 m_sourceModel( nullptr )
231 static std::vector<PARAM::INFO> device =
makeParamInfos( TYPE::KIBIS_DEVICE );
232 static std::vector<PARAM::INFO> dcDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_DC );
233 static std::vector<PARAM::INFO> rectDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_RECT );
234 static std::vector<PARAM::INFO> prbsDriver =
makeParamInfos( TYPE::KIBIS_DRIVER_PRBS );
236 std::vector<PARAM::INFO>* paramInfos =
nullptr;
240 case SIM_MODEL::TYPE::KIBIS_DEVICE: paramInfos = &device;
break;
241 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC: paramInfos = &dcDriver;
break;
242 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT: paramInfos = &rectDriver;
break;
243 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS: paramInfos = &prbsDriver;
break;
270 AddPin( {
"IN/OUT",
"2" } );
283 if( param1.info.name == param2.
info.
name )
330 std::vector<PARAM::INFO> paramInfos;
333 paramInfo.
name =
"vcc";
340 paramInfo.
enumValues = {
"typ",
"min",
"max" };
341 paramInfos.push_back( paramInfo );
343 paramInfo.
name =
"rpin";
348 paramInfo.
description =
_(
"Parasitic pin resistance" );
350 paramInfo.
enumValues = {
"typ",
"min",
"max" };
351 paramInfos.push_back( paramInfo );
353 paramInfo.
name =
"lpin";
358 paramInfo.
description =
_(
"Parasitic pin inductance" );
360 paramInfo.
enumValues = {
"typ",
"min",
"max" };
361 paramInfos.push_back( paramInfo );
363 paramInfo.
name =
"cpin";
368 paramInfo.
description =
_(
"Parasitic pin capacitance" );
370 paramInfo.
enumValues = {
"typ",
"min",
"max" };
371 paramInfos.push_back( paramInfo );
379 case TYPE::KIBIS_DRIVER_DC:
381 paramInfos.push_back( param );
384 case TYPE::KIBIS_DRIVER_RECT:
386 paramInfos.push_back( param );
389 case TYPE::KIBIS_DRIVER_PRBS:
391 paramInfos.push_back( param );
404 std::vector<PARAM::INFO> paramInfos;
407 paramInfo.
name =
"dc";
413 paramInfo.
enumValues = {
"hi-Z",
"low",
"high" };
414 paramInfos.push_back( paramInfo );
422 std::vector<PARAM::INFO> paramInfos;
425 paramInfo.
name =
"ton";
427 paramInfo.
unit =
"s";
431 paramInfos.push_back( paramInfo );
433 paramInfo.
name =
"toff";
435 paramInfo.
unit =
"s";
439 paramInfos.push_back( paramInfo );
441 paramInfo.
name =
"td";
443 paramInfo.
unit =
"s";
447 paramInfos.push_back( paramInfo );
449 paramInfo.
name =
"n";
455 paramInfos.push_back( paramInfo );
463 std::vector<PARAM::INFO> paramInfos;
466 paramInfo.
name =
"f0";
468 paramInfo.
unit =
"Hz";
472 paramInfos.push_back( paramInfo );
474 paramInfo.
name =
"td";
476 paramInfo.
unit =
"s";
480 paramInfos.push_back( paramInfo );
482 paramInfo.
name =
"n";
488 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.
Holds all the data relating to one schematic.
PROJECT & Prj() 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
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
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::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.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
const wxString & GetMessages() const
#define THROW_IO_ERROR(msg)
wxString GetFieldValue(const std::vector< SCH_FIELD > *aFields, FIELD_T aFieldType)
std::string spiceModelName
std::vector< std::string > enumValues
std::vector< SCH_FIELD > fields
std::string baseModelName