KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_ibis.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * https://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <sim/kibis/kibis.h>
25#include <sim/sim_model_ibis.h>
27#include <fmt/core.h>
28#include <wx/filename.h>
29#include <kiway.h>
30#include <schematic.h>
31#include "sim_lib_mgr.h"
32
33std::string SPICE_GENERATOR_IBIS::ModelName( const SPICE_ITEM& aItem ) const
34{
35 return fmt::format( "{}.{}", aItem.refName, aItem.baseModelName );
36}
37
38
39std::string SPICE_GENERATOR_IBIS::ModelLine( const SPICE_ITEM& aItem ) const
40{
41 return "";
42}
43
44std::vector<std::string> SPICE_GENERATOR_IBIS::CurrentNames( const SPICE_ITEM& aItem ) const
45{
46 std::vector<std::string> currentNames;
47
48 for( const SIM_MODEL_PIN& pin : GetPins() )
49 currentNames.push_back( fmt::format( "I({}:{})", ItemName( aItem ), pin.modelPinName ) );
50
51 return currentNames;
52}
53
54
55std::string SPICE_GENERATOR_IBIS::IbisDevice( const SPICE_ITEM& aItem, SCHEMATIC* aSchematic,
56 const wxString& aCacheDir, REPORTER& aReporter ) const
57{
58 std::string ibisLibFilename = GetFieldValue( &aItem.fields, SIM_LIBRARY::LIBRARY_FIELD, true, 0 );
59 std::string ibisCompName = GetFieldValue( &aItem.fields, SIM_LIBRARY::NAME_FIELD, true, 0 );
60 std::string ibisPinName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::PIN_FIELD, true, 0 );
61 std::string ibisModelName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::MODEL_FIELD, true, 0 );
62 bool diffMode = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::DIFF_FIELD, true, 0 ) == "1";
63
65 SIM_LIB_MGR mgr( &aSchematic->Project() );
66
67 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
68 embeddedFilesStack.push_back( aSchematic->GetEmbeddedFiles() );
69 mgr.SetFilesStack( std::move( embeddedFilesStack ) );
70
71 wxString path = mgr.ResolveLibraryPath( ibisLibFilename, reporter );
72
73 if( reporter.HasMessage() )
74 THROW_IO_ERROR( reporter.GetMessages() );
75
76 KIBIS kibis( std::string( path.c_str() ) );
77 kibis.m_cacheDir = std::string( aCacheDir.c_str() );
78 kibis.m_Reporter = &aReporter;
79
80 if( !kibis.m_valid )
81 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS file '%s'" ), ibisLibFilename ) );
82
83 KIBIS_COMPONENT* kcomp = kibis.GetComponent( std::string( ibisCompName ) );
84
85 if( !kcomp )
86 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS component '%s'" ), ibisCompName ) );
87
88 KIBIS_PIN* kpin = kcomp->GetPin( ibisPinName );
89
90
91 if( !kcomp->m_valid )
92 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS component '%s'" ), ibisCompName ) );
93
94 if( !kpin )
95 {
96 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS pin '%s' in component '%s'" ),
97 ibisPinName,
98 ibisCompName ) );
99 }
100
101 if( !kpin->m_valid )
102 {
103 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS pin '%s' in component '%s'" ),
104 ibisPinName,
105 ibisCompName ) );
106 }
107
108 KIBIS_MODEL* kmodel = kibis.GetModel( ibisModelName );
109
110 if( !kmodel )
111 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS model '%s'" ), ibisModelName ) );
112
113 if( !kmodel->m_valid )
114 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS model '%s'" ), ibisModelName ) );
115
117
118 if( const SIM_MODEL::PARAM* vcc = m_model.FindParam( "vcc" ) )
119 kparams.SetCornerFromString( kparams.m_supply, vcc->value );
120
121 if( const SIM_MODEL::PARAM* rpin = m_model.FindParam( "rpin" ) )
122 kparams.SetCornerFromString( kparams.m_Rpin, rpin->value );
123
124 if( const SIM_MODEL::PARAM* lpin = m_model.FindParam( "lpin" ) )
125 kparams.SetCornerFromString( kparams.m_Lpin, lpin->value );
126
127 if( const SIM_MODEL::PARAM* cpin = m_model.FindParam( "cpin" ) )
128 kparams.SetCornerFromString( kparams.m_Cpin, cpin->value );
129
130 //kparams.SetCornerFromString( kparams.m_Ccomp, FindParam( "ccomp" )->value );
131
132 std::string result;
133
134 switch( m_model.GetType() )
135 {
136 case SIM_MODEL::TYPE::KIBIS_DEVICE:
137 if( diffMode )
138 kpin->writeSpiceDiffDevice( result, aItem.modelName, *kmodel, kparams );
139 else
140 kpin->writeSpiceDevice( result, aItem.modelName, *kmodel, kparams );
141
142 break;
143
144 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
145 {
146 std::string paramValue = "";
147
148 if( const SIM_MODEL::PARAM* dc = m_model.FindParam( "dc" ) )
149 paramValue = dc->value;
150
151 if( paramValue == "hi-Z" )
152 kparams.m_waveform = new KIBIS_WAVEFORM_HIGH_Z( kibis );
153 else if( paramValue == "low" )
154 kparams.m_waveform = new KIBIS_WAVEFORM_STUCK_LOW( kibis );
155 else if( paramValue == "high" )
156 kparams.m_waveform = new KIBIS_WAVEFORM_STUCK_HIGH( kibis );
157
158 if( diffMode )
159 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
160 else
161 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
162
163 break;
164 }
165
166 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
167 {
169
170 if( const SIM_MODEL::PARAM* ton = m_model.FindParam( "ton" ) )
171 waveform->m_ton = SIM_VALUE::ToDouble( ton->value, 0 );
172
173 if( const SIM_MODEL::PARAM* toff = m_model.FindParam( "toff" ) )
174 waveform->m_toff = SIM_VALUE::ToDouble( toff->value, 0 );
175
176 if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
177 waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
178
179 if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
180 waveform->m_cycles = SIM_VALUE::ToInt( n->value, 1 );
181
182 kparams.m_waveform = waveform;
183
184 if( diffMode )
185 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
186 else
187 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
188
189 break;
190 }
191
192 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
193 {
194 KIBIS_WAVEFORM_PRBS* waveform = new KIBIS_WAVEFORM_PRBS( kibis );
195
196 if( const SIM_MODEL::PARAM* f0 = m_model.FindParam( "f0" ) )
197 waveform->m_bitrate = SIM_VALUE::ToDouble( f0->value, 0 );
198
199 if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
200 waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
201
202 if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
203 waveform->SetBits( SIM_VALUE::ToInt( n->value, 0 ) );
204
205 kparams.m_waveform = waveform;
206
207 if( diffMode )
208 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
209 else
210 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
211
212 break;
213 }
214
215 default:
216 wxFAIL_MSG( "Unknown IBIS model type" );
217 return "";
218 }
219
220 return result;
221}
222
223
225 SIM_MODEL( aType, std::make_unique<SPICE_GENERATOR_IBIS>( *this ) ),
226 m_enableDiff( false ),
227 m_sourceModel( nullptr )
228{
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 );
233
234 std::vector<PARAM::INFO>* paramInfos = nullptr;
235
236 switch( aType )
237 {
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;
243 }
244
245 for( const PARAM::INFO& paramInfo : *paramInfos )
246 AddParam( paramInfo );
247
248 SwitchSingleEndedDiff( false );
249}
250
251
256
257
259{
260 m_ioMode = aMode;
261 ClearPins();
262
263 switch( aMode )
264 {
266 AddPin( { "GND", "1" } );
267 AddPin( { "IN/OUT", "2" } );
269 break;
270
272 AddPin( { "GND", "1" } );
273 AddPin( { "+", "2" } );
274 AddPin( { "-", "3" } );
276 break;
277
279 AddPin( { "PIN_A", "1" } );
280 AddPin( { "PIN_B", "2" } );
281 break;
282 }
283}
284
285
287{
288 if( FindParam( "sw_state" ) )
289 return;
290
291 // INFO must outlive every PARAM that references it (PARAM stores const INFO&).
292 static const PARAM::INFO info = [&]
293 {
294 PARAM::INFO i;
295 i.name = "sw_state";
296 i.type = SIM_VALUE::TYPE_FLOAT;
297 i.unit = "";
298 i.category = PARAM::CATEGORY::PRINCIPAL;
299 i.defaultValue = "1";
300 i.description = _( "Switch state (1 = on, 0 = off)" ).ToStdString();
301 i.isSpiceInstanceParam = true;
302 i.spiceInstanceName = "SW_STATE";
303 return i;
304 }();
305
306 AddParam( info );
307}
308
309
311{
312 // PARAM is not assignable; erase-from-middle is illegal. sw_state is
313 // the only post-construction append, so back() is safe.
314 if( !m_params.empty() && m_params.back().info.name == "sw_state" )
315 m_params.pop_back();
316}
317
318
319bool SIM_MODEL_IBIS::SetIbisModel( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber,
320 const std::string& aModelName )
321{
323
324 if( !kcomp )
325 return false;
326
327 KIBIS_MODEL* kmodel = aLib.m_kibis.GetModel( aModelName );
328
329 if( !kmodel )
330 return false;
331
332 KIBIS_PIN* kpin = kcomp->GetPin( aPinNumber );
333
334 switch( kmodel->m_type )
335 {
338 {
340
341 m_partnerPin.clear();
342
343 if( kpin )
344 {
345 if( KIBIS_PIN* partner = kpin->SeriesPartner() )
346 m_partnerPin = partner->m_pinNumber;
347 }
348
351 else
353
354 break;
355 }
356
357 default:
358 m_partnerPin.clear();
360
363
364 break;
365 }
366
367 return true;
368}
369
371 SIM_MODEL_IBIS( aType )
372{
373 for( PARAM& param1 : m_params )
374 {
375 for( int ii = 0; ii < aSource.GetParamCount(); ++ii )
376 {
377 const PARAM& param2 = aSource.GetParam( ii );
378
379 if( param1.info.name == param2.info.name )
380 param1.value = param2.value;
381 }
382 }
383
385
386 m_ibisPins = aSource.GetIbisPins();
387 m_ibisModels = aSource.GetIbisModels();
388
389 m_enableDiff = aSource.CanDifferential();
390 m_partnerPin = aSource.m_partnerPin;
391
392 // SetIOMode does not touch sw_state; re-add it for SERIES_SWITCH sources.
393 SetIOMode( aSource.m_ioMode );
394
395 if( aSource.IsSeries() )
396 {
397 if( const PARAM* srcSwState = aSource.FindParam( "sw_state" ) )
398 {
400 SetParamValue( "sw_state", srcSwState->value );
401 }
402 }
403}
404
405
406bool SIM_MODEL_IBIS::ChangePin( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber )
407{
408 KIBIS_COMPONENT* kcomp = aLib.m_kibis.GetComponent( std::string( GetComponentName() ) );
409
410 if( !kcomp )
411 return false;
412
413 KIBIS_PIN* kpin = kcomp->GetPin( aPinNumber );
414
415 if( !kpin )
416 return false;
417
418 m_ibisModels.clear();
419
420 for( KIBIS_MODEL* kmodel : kpin->m_models )
421 m_ibisModels.push_back( kmodel->m_name );
422
423 return true;
424}
425
426
428{
429 // Actual base models can only be of the same type, which is not the case here, as in addition
430 // to IBIS device model type we have multiple types of drivers available for the same sourced
431 // model. And we don't want to inherit the default values anyway. So we just store these models
432 // and use the only for Spice code generation.
433 m_sourceModel = dynamic_cast<const SIM_MODEL_IBIS*>( &aBaseModel );
434}
435
436
437std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeParamInfos( TYPE aType )
438{
439 std::vector<PARAM::INFO> paramInfos;
440 PARAM::INFO paramInfo;
441
442 paramInfo.name = "vcc";
443 paramInfo.type = SIM_VALUE::TYPE_STRING;
444 paramInfo.unit = "";
445 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
446 paramInfo.defaultValue = "typ";
447 paramInfo.description = _( "Power supply" );
448 paramInfo.spiceModelName = "";
449 paramInfo.enumValues = { "typ", "min", "max" };
450 paramInfos.push_back( paramInfo );
451
452 paramInfo.name = "rpin";
453 paramInfo.type = SIM_VALUE::TYPE_STRING;
454 paramInfo.unit = "";
455 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
456 paramInfo.defaultValue = "typ";
457 paramInfo.description = _( "Parasitic pin resistance" );
458 paramInfo.spiceModelName = "";
459 paramInfo.enumValues = { "typ", "min", "max" };
460 paramInfos.push_back( paramInfo );
461
462 paramInfo.name = "lpin";
463 paramInfo.type = SIM_VALUE::TYPE_STRING;
464 paramInfo.unit = "";
465 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
466 paramInfo.defaultValue = "typ";
467 paramInfo.description = _( "Parasitic pin inductance" );
468 paramInfo.spiceModelName = "";
469 paramInfo.enumValues = { "typ", "min", "max" };
470 paramInfos.push_back( paramInfo );
471
472 paramInfo.name = "cpin";
473 paramInfo.type = SIM_VALUE::TYPE_STRING;
474 paramInfo.unit = "";
475 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
476 paramInfo.defaultValue = "typ";
477 paramInfo.description = _( "Parasitic pin capacitance" );
478 paramInfo.spiceModelName = "";
479 paramInfo.enumValues = { "typ", "min", "max" };
480 paramInfos.push_back( paramInfo );
481
482 std::vector<PARAM::INFO> dc = makeDcWaveformParamInfos();
483 std::vector<PARAM::INFO> rect = makeRectWaveformParamInfos();
484 std::vector<PARAM::INFO> prbs = makePrbsWaveformParamInfos();
485
486 switch( aType )
487 {
488 case TYPE::KIBIS_DRIVER_DC:
489 for( const PARAM::INFO& param : makeDcWaveformParamInfos() )
490 paramInfos.push_back( param );
491
492 break;
493
494 case TYPE::KIBIS_DRIVER_RECT:
495 for( const PARAM::INFO& param : makeRectWaveformParamInfos() )
496 paramInfos.push_back( param );
497
498 break;
499
500 case TYPE::KIBIS_DRIVER_PRBS:
501 for( const PARAM::INFO& param : makePrbsWaveformParamInfos() )
502 paramInfos.push_back( param );
503
504 break;
505
506 default:
507 break;
508 }
509
510 return paramInfos;
511}
512
513
514std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeDcWaveformParamInfos()
515{
516 std::vector<PARAM::INFO> paramInfos;
517 PARAM::INFO paramInfo;
518
519 paramInfo.name = "dc";
520 paramInfo.type = SIM_VALUE::TYPE_STRING;
521 paramInfo.unit = "";
522 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
523 paramInfo.defaultValue = "hi-Z";
524 paramInfo.description = _( "DC Value" );
525 paramInfo.enumValues = { "hi-Z", "low", "high" };
526 paramInfos.push_back( paramInfo );
527
528 return paramInfos;
529}
530
531
532std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeRectWaveformParamInfos()
533{
534 std::vector<PARAM::INFO> paramInfos;
535 PARAM::INFO paramInfo;
536
537 paramInfo.name = "ton";
538 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
539 paramInfo.unit = "s";
540 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
541 paramInfo.defaultValue = "";
542 paramInfo.description = _( "ON time" );
543 paramInfos.push_back( paramInfo );
544
545 paramInfo.name = "toff";
546 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
547 paramInfo.unit = "s";
548 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
549 paramInfo.defaultValue = "";
550 paramInfo.description = _( "OFF time" );
551 paramInfos.push_back( paramInfo );
552
553 paramInfo.name = "td";
554 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
555 paramInfo.unit = "s";
556 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
557 paramInfo.defaultValue = "0";
558 paramInfo.description = _( "Delay" );
559 paramInfos.push_back( paramInfo );
560
561 paramInfo.name = "n";
562 paramInfo.type = SIM_VALUE::TYPE_INT;
563 paramInfo.unit = "";
564 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
565 paramInfo.defaultValue = "1";
566 paramInfo.description = _( "Number of cycles" );
567 paramInfos.push_back( paramInfo );
568
569 return paramInfos;
570}
571
572
573std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makePrbsWaveformParamInfos()
574{
575 std::vector<PARAM::INFO> paramInfos;
576 PARAM::INFO paramInfo;
577
578 paramInfo.name = "f0";
579 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
580 paramInfo.unit = "Hz";
581 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
582 paramInfo.defaultValue = "";
583 paramInfo.description = _( "Bitrate" );
584 paramInfos.push_back( paramInfo );
585
586 paramInfo.name = "td";
587 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
588 paramInfo.unit = "s";
589 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
590 paramInfo.defaultValue = "";
591 paramInfo.description = _( "Delay" );
592 paramInfos.push_back( paramInfo );
593
594 paramInfo.name = "n";
595 paramInfo.type = SIM_VALUE::TYPE_INT;
596 paramInfo.unit = "";
597 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
598 paramInfo.defaultValue = "";
599 paramInfo.description = _( "Number of bits" );
600 paramInfos.push_back( paramInfo );
601
602 return paramInfos;
603}
604
REPORTER * m_Reporter
Definition ibis_parser.h:77
bool m_valid
Definition kibis.h:57
KIBIS_PIN * GetPin(const std::string &aPinNumber)
Get a pin by its number ( 1, 2, A1, A2, ... )
Definition kibis.cpp:432
std::string m_name
Definition kibis.h:269
IBIS_MODEL_TYPE m_type
Definition kibis.h:271
bool writeSpiceDiffDriver(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
Definition kibis.cpp:1614
bool writeSpiceDevice(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
Definition kibis.cpp:1507
std::vector< KIBIS_MODEL * > m_models
Definition kibis.h:397
bool writeSpiceDiffDevice(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
Definition kibis.cpp:1651
KIBIS_PIN * SeriesPartner(std::string *aModelName=nullptr, std::string *aGroupName=nullptr) const
Partner pin from [Series Pin Mapping], or nullptr.
Definition kibis.cpp:403
bool writeSpiceDriver(std::string &aDest, const std::string &aName, KIBIS_MODEL &aModel, const KIBIS_PARAMETER &aParam)
Definition kibis.cpp:1382
void SetBits(int aBits)
Definition kibis.h:146
Definition kibis.h:513
KIBIS_MODEL * GetModel(const std::string &aName)
Return the model with name aName .
Definition kibis.cpp:1681
KIBIS_COMPONENT * GetComponent(const std::string &aName)
Return the component with name aName .
Definition kibis.cpp:1693
std::string m_cacheDir
Absolute path of the directory that will be used for caching.
Definition kibis.h:528
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
Holds all the data relating to one schematic.
Definition schematic.h:89
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:104
EMBEDDED_FILES * GetEmbeddedFiles() override
static constexpr auto MODEL_FIELD
static constexpr auto PIN_FIELD
static constexpr auto DIFF_FIELD
static constexpr auto LIBRARY_FIELD
Definition sim_library.h:35
static constexpr auto NAME_FIELD
Definition sim_library.h:36
wxString ResolveLibraryPath(const wxString &aLibraryPath, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:48
SIM_MODEL_IBIS(TYPE aType)
static std::vector< PARAM::INFO > makeDcWaveformParamInfos()
void removeSwitchStateParam()
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()
IBIS_IO_MODE m_ioMode
bool SetIbisModel(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber, const std::string &aModelName)
Bind to a KIBIS model, set IO mode from its type, manage sw_state.
const PARAM & GetParam(unsigned aParamIndex) const override
static std::vector< PARAM::INFO > makePrbsWaveformParamInfos()
std::string m_partnerPin
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void SwitchSingleEndedDiff(bool aDiff) override
bool IsSeries() const
const SIM_MODEL_IBIS * m_sourceModel
bool CanDifferential() const
std::vector< std::string > GetIbisModels() const
void SetIOMode(IBIS_IO_MODE aMode)
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 ClearPins()
void AddPin(const SIM_MODEL_PIN &aPin)
SIM_MODEL()=delete
int GetParamCount() const
Definition sim_model.h:478
const PARAM * FindParam(const std::string &aParamName) const
std::vector< PARAM > m_params
Definition sim_model.h:535
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
@ TYPE_STRING
Definition sim_value.h:71
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.
Definition reporter.h:193
#define _(s)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
STL namespace.
wxString GetFieldValue(const std::vector< SCH_FIELD > *aFields, FIELD_T aFieldType)
Definition sch_field.h:419
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:58
IBIS_IO_MODE
std::string value
Definition sim_model.h:400
const INFO & info
Definition sim_model.h:401
std::string refName
std::vector< SCH_FIELD > fields
std::string modelName
std::string baseModelName
std::string path
IbisParser parser & reporter
KIBIS_PIN * partner
KIBIS_PARAMETER kparams
KIBIS_PIN * pin
wxString result
Test unit parsing edge cases and error handling.