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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <sim/kibis/kibis.h>
21#include <sim/sim_model_ibis.h>
23#include <fmt/core.h>
24#include <wx/filename.h>
25#include <kiway.h>
26#include <schematic.h>
27#include "sim_lib_mgr.h"
28
29std::string SPICE_GENERATOR_IBIS::ModelName( const SPICE_ITEM& aItem ) const
30{
31 return fmt::format( "{}.{}", aItem.refName, aItem.baseModelName );
32}
33
34
35std::string SPICE_GENERATOR_IBIS::ModelLine( const SPICE_ITEM& aItem ) const
36{
37 return "";
38}
39
40std::vector<std::string> SPICE_GENERATOR_IBIS::CurrentNames( const SPICE_ITEM& aItem ) const
41{
42 std::vector<std::string> currentNames;
43
44 for( const SIM_MODEL_PIN& pin : GetPins() )
45 currentNames.push_back( fmt::format( "I({}:{})", ItemName( aItem ), pin.modelPinName ) );
46
47 return currentNames;
48}
49
50
51std::string SPICE_GENERATOR_IBIS::IbisDevice( const SPICE_ITEM& aItem, SCHEMATIC* aSchematic,
52 const wxString& aCacheDir, REPORTER& aReporter ) const
53{
54 std::string ibisLibFilename = GetFieldValue( &aItem.fields, SIM_LIBRARY::LIBRARY_FIELD, true, 0 );
55 std::string ibisCompName = GetFieldValue( &aItem.fields, SIM_LIBRARY::NAME_FIELD, true, 0 );
56 std::string ibisPinName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::PIN_FIELD, true, 0 );
57 std::string ibisModelName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::MODEL_FIELD, true, 0 );
58 bool diffMode = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::DIFF_FIELD, true, 0 ) == "1";
59
61 SIM_LIB_MGR mgr( &aSchematic->Project() );
62
63 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
64 embeddedFilesStack.push_back( aSchematic->GetEmbeddedFiles() );
65 mgr.SetFilesStack( std::move( embeddedFilesStack ) );
66
67 wxString path = mgr.ResolveLibraryPath( ibisLibFilename, reporter );
68
69 if( reporter.HasMessage() )
70 THROW_IO_ERROR( reporter.GetMessages() );
71
72 KIBIS kibis( std::string( path.c_str() ) );
73 kibis.m_cacheDir = std::string( aCacheDir.c_str() );
74 kibis.m_Reporter = &aReporter;
75
76 if( !kibis.m_valid )
77 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS file '%s'" ), ibisLibFilename ) );
78
79 KIBIS_COMPONENT* kcomp = kibis.GetComponent( std::string( ibisCompName ) );
80
81 if( !kcomp )
82 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS component '%s'" ), ibisCompName ) );
83
84 KIBIS_PIN* kpin = kcomp->GetPin( ibisPinName );
85
86
87 if( !kcomp->m_valid )
88 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS component '%s'" ), ibisCompName ) );
89
90 if( !kpin )
91 {
92 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS pin '%s' in component '%s'" ),
93 ibisPinName,
94 ibisCompName ) );
95 }
96
97 if( !kpin->m_valid )
98 {
99 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS pin '%s' in component '%s'" ),
100 ibisPinName,
101 ibisCompName ) );
102 }
103
104 KIBIS_MODEL* kmodel = kibis.GetModel( ibisModelName );
105
106 if( !kmodel )
107 THROW_IO_ERROR( wxString::Format( _( "Could not find IBIS model '%s'" ), ibisModelName ) );
108
109 if( !kmodel->m_valid )
110 THROW_IO_ERROR( wxString::Format( _( "Invalid IBIS model '%s'" ), ibisModelName ) );
111
113
114 if( const SIM_MODEL::PARAM* vcc = m_model.FindParam( "vcc" ) )
115 kparams.SetCornerFromString( kparams.m_supply, vcc->value );
116
117 if( const SIM_MODEL::PARAM* rpin = m_model.FindParam( "rpin" ) )
118 kparams.SetCornerFromString( kparams.m_Rpin, rpin->value );
119
120 if( const SIM_MODEL::PARAM* lpin = m_model.FindParam( "lpin" ) )
121 kparams.SetCornerFromString( kparams.m_Lpin, lpin->value );
122
123 if( const SIM_MODEL::PARAM* cpin = m_model.FindParam( "cpin" ) )
124 kparams.SetCornerFromString( kparams.m_Cpin, cpin->value );
125
126 //kparams.SetCornerFromString( kparams.m_Ccomp, FindParam( "ccomp" )->value );
127
128 std::string result;
129
130 switch( m_model.GetType() )
131 {
132 case SIM_MODEL::TYPE::KIBIS_DEVICE:
133 if( diffMode )
134 kpin->writeSpiceDiffDevice( result, aItem.modelName, *kmodel, kparams );
135 else
136 kpin->writeSpiceDevice( result, aItem.modelName, *kmodel, kparams );
137
138 break;
139
140 case SIM_MODEL::TYPE::KIBIS_DRIVER_DC:
141 {
142 std::string paramValue = "";
143
144 if( const SIM_MODEL::PARAM* dc = m_model.FindParam( "dc" ) )
145 paramValue = dc->value;
146
147 if( paramValue == "hi-Z" )
148 kparams.m_waveform = new KIBIS_WAVEFORM_HIGH_Z( kibis );
149 else if( paramValue == "low" )
150 kparams.m_waveform = new KIBIS_WAVEFORM_STUCK_LOW( kibis );
151 else if( paramValue == "high" )
152 kparams.m_waveform = new KIBIS_WAVEFORM_STUCK_HIGH( kibis );
153
154 if( diffMode )
155 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
156 else
157 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
158
159 break;
160 }
161
162 case SIM_MODEL::TYPE::KIBIS_DRIVER_RECT:
163 {
165
166 if( const SIM_MODEL::PARAM* ton = m_model.FindParam( "ton" ) )
167 waveform->m_ton = SIM_VALUE::ToDouble( ton->value, 0 );
168
169 if( const SIM_MODEL::PARAM* toff = m_model.FindParam( "toff" ) )
170 waveform->m_toff = SIM_VALUE::ToDouble( toff->value, 0 );
171
172 if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
173 waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
174
175 if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
176 waveform->m_cycles = SIM_VALUE::ToInt( n->value, 1 );
177
178 kparams.m_waveform = waveform;
179
180 if( diffMode )
181 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
182 else
183 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
184
185 break;
186 }
187
188 case SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS:
189 {
190 KIBIS_WAVEFORM_PRBS* waveform = new KIBIS_WAVEFORM_PRBS( kibis );
191
192 if( const SIM_MODEL::PARAM* f0 = m_model.FindParam( "f0" ) )
193 waveform->m_bitrate = SIM_VALUE::ToDouble( f0->value, 0 );
194
195 if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
196 waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
197
198 if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
199 waveform->SetBits( SIM_VALUE::ToInt( n->value, 0 ) );
200
201 kparams.m_waveform = waveform;
202
203 if( diffMode )
204 kpin->writeSpiceDiffDriver( result, aItem.modelName, *kmodel, kparams );
205 else
206 kpin->writeSpiceDriver( result, aItem.modelName, *kmodel, kparams );
207
208 break;
209 }
210
211 default:
212 wxFAIL_MSG( "Unknown IBIS model type" );
213 return "";
214 }
215
216 return result;
217}
218
219
221 SIM_MODEL( aType, std::make_unique<SPICE_GENERATOR_IBIS>( *this ) ),
222 m_enableDiff( false ),
223 m_sourceModel( nullptr )
224{
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 );
229
230 std::vector<PARAM::INFO>* paramInfos = nullptr;
231
232 switch( aType )
233 {
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;
238 default: wxFAIL; return;
239 }
240
241 for( const PARAM::INFO& paramInfo : *paramInfos )
242 AddParam( paramInfo );
243
244 SwitchSingleEndedDiff( false );
245}
246
247
252
253
255{
256 m_ioMode = aMode;
257 ClearPins();
258
259 switch( aMode )
260 {
262 AddPin( { "GND", "1" } );
263 AddPin( { "IN/OUT", "2" } );
265 break;
266
268 AddPin( { "GND", "1" } );
269 AddPin( { "+", "2" } );
270 AddPin( { "-", "3" } );
272 break;
273
275 AddPin( { "PIN_A", "1" } );
276 AddPin( { "PIN_B", "2" } );
277 break;
278 }
279}
280
281
283{
284 if( FindParam( "sw_state" ) )
285 return;
286
287 // INFO must outlive every PARAM that references it (PARAM stores const INFO&).
288 static const PARAM::INFO info = [&]
289 {
290 PARAM::INFO i;
291 i.name = "sw_state";
292 i.type = SIM_VALUE::TYPE_FLOAT;
293 i.unit = "";
294 i.category = PARAM::CATEGORY::PRINCIPAL;
295 i.defaultValue = "1";
296 i.description = _( "Switch state (1 = on, 0 = off)" ).ToStdString();
297 i.isSpiceInstanceParam = true;
298 i.spiceInstanceName = "SW_STATE";
299 return i;
300 }();
301
302 AddParam( info );
303}
304
305
307{
308 // PARAM is not assignable; erase-from-middle is illegal. sw_state is
309 // the only post-construction append, so back() is safe.
310 if( !m_params.empty() && m_params.back().info.name == "sw_state" )
311 m_params.pop_back();
312}
313
314
315bool SIM_MODEL_IBIS::SetIbisModel( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber,
316 const std::string& aModelName )
317{
319
320 if( !kcomp )
321 return false;
322
323 KIBIS_MODEL* kmodel = aLib.m_kibis.GetModel( aModelName );
324
325 if( !kmodel )
326 return false;
327
328 KIBIS_PIN* kpin = kcomp->GetPin( aPinNumber );
329
330 switch( kmodel->m_type )
331 {
334 {
336
337 m_partnerPin.clear();
338
339 if( kpin )
340 {
341 if( KIBIS_PIN* partner = kpin->SeriesPartner() )
342 m_partnerPin = partner->m_pinNumber;
343 }
344
347 else
349
350 break;
351 }
352
353 default:
354 m_partnerPin.clear();
356
359
360 break;
361 }
362
363 return true;
364}
365
367 SIM_MODEL_IBIS( aType )
368{
369 for( PARAM& param1 : m_params )
370 {
371 for( int ii = 0; ii < aSource.GetParamCount(); ++ii )
372 {
373 const PARAM& param2 = aSource.GetParam( ii );
374
375 if( param1.info.name == param2.info.name )
376 param1.value = param2.value;
377 }
378 }
379
381
382 m_ibisPins = aSource.GetIbisPins();
383 m_ibisModels = aSource.GetIbisModels();
384
385 m_enableDiff = aSource.CanDifferential();
386 m_partnerPin = aSource.m_partnerPin;
387
388 // SetIOMode does not touch sw_state; re-add it for SERIES_SWITCH sources.
389 SetIOMode( aSource.m_ioMode );
390
391 if( aSource.IsSeries() )
392 {
393 if( const PARAM* srcSwState = aSource.FindParam( "sw_state" ) )
394 {
396 SetParamValue( "sw_state", srcSwState->value );
397 }
398 }
399}
400
401
402bool SIM_MODEL_IBIS::ChangePin( const SIM_LIBRARY_IBIS& aLib, const std::string& aPinNumber )
403{
404 KIBIS_COMPONENT* kcomp = aLib.m_kibis.GetComponent( std::string( GetComponentName() ) );
405
406 if( !kcomp )
407 return false;
408
409 KIBIS_PIN* kpin = kcomp->GetPin( aPinNumber );
410
411 if( !kpin )
412 return false;
413
414 m_ibisModels.clear();
415
416 for( KIBIS_MODEL* kmodel : kpin->m_models )
417 m_ibisModels.push_back( kmodel->m_name );
418
419 return true;
420}
421
422
424{
425 // Actual base models can only be of the same type, which is not the case here, as in addition
426 // to IBIS device model type we have multiple types of drivers available for the same sourced
427 // model. And we don't want to inherit the default values anyway. So we just store these models
428 // and use the only for Spice code generation.
429 m_sourceModel = dynamic_cast<const SIM_MODEL_IBIS*>( &aBaseModel );
430}
431
432
433std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeParamInfos( TYPE aType )
434{
435 std::vector<PARAM::INFO> paramInfos;
436 PARAM::INFO paramInfo;
437
438 paramInfo.name = "vcc";
439 paramInfo.type = SIM_VALUE::TYPE_STRING;
440 paramInfo.unit = "";
441 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
442 paramInfo.defaultValue = "typ";
443 paramInfo.description = _( "Power supply" );
444 paramInfo.spiceModelName = "";
445 paramInfo.enumValues = { "typ", "min", "max" };
446 paramInfos.push_back( paramInfo );
447
448 paramInfo.name = "rpin";
449 paramInfo.type = SIM_VALUE::TYPE_STRING;
450 paramInfo.unit = "";
451 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
452 paramInfo.defaultValue = "typ";
453 paramInfo.description = _( "Parasitic pin resistance" );
454 paramInfo.spiceModelName = "";
455 paramInfo.enumValues = { "typ", "min", "max" };
456 paramInfos.push_back( paramInfo );
457
458 paramInfo.name = "lpin";
459 paramInfo.type = SIM_VALUE::TYPE_STRING;
460 paramInfo.unit = "";
461 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
462 paramInfo.defaultValue = "typ";
463 paramInfo.description = _( "Parasitic pin inductance" );
464 paramInfo.spiceModelName = "";
465 paramInfo.enumValues = { "typ", "min", "max" };
466 paramInfos.push_back( paramInfo );
467
468 paramInfo.name = "cpin";
469 paramInfo.type = SIM_VALUE::TYPE_STRING;
470 paramInfo.unit = "";
471 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
472 paramInfo.defaultValue = "typ";
473 paramInfo.description = _( "Parasitic pin capacitance" );
474 paramInfo.spiceModelName = "";
475 paramInfo.enumValues = { "typ", "min", "max" };
476 paramInfos.push_back( paramInfo );
477
478 std::vector<PARAM::INFO> dc = makeDcWaveformParamInfos();
479 std::vector<PARAM::INFO> rect = makeRectWaveformParamInfos();
480 std::vector<PARAM::INFO> prbs = makePrbsWaveformParamInfos();
481
482 switch( aType )
483 {
484 case TYPE::KIBIS_DRIVER_DC:
485 for( const PARAM::INFO& param : makeDcWaveformParamInfos() )
486 paramInfos.push_back( param );
487
488 break;
489
490 case TYPE::KIBIS_DRIVER_RECT:
491 for( const PARAM::INFO& param : makeRectWaveformParamInfos() )
492 paramInfos.push_back( param );
493
494 break;
495
496 case TYPE::KIBIS_DRIVER_PRBS:
497 for( const PARAM::INFO& param : makePrbsWaveformParamInfos() )
498 paramInfos.push_back( param );
499
500 break;
501
502 default:
503 break;
504 }
505
506 return paramInfos;
507}
508
509
510std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeDcWaveformParamInfos()
511{
512 std::vector<PARAM::INFO> paramInfos;
513 PARAM::INFO paramInfo;
514
515 paramInfo.name = "dc";
516 paramInfo.type = SIM_VALUE::TYPE_STRING;
517 paramInfo.unit = "";
518 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
519 paramInfo.defaultValue = "hi-Z";
520 paramInfo.description = _( "DC Value" );
521 paramInfo.enumValues = { "hi-Z", "low", "high" };
522 paramInfos.push_back( paramInfo );
523
524 return paramInfos;
525}
526
527
528std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makeRectWaveformParamInfos()
529{
530 std::vector<PARAM::INFO> paramInfos;
531 PARAM::INFO paramInfo;
532
533 paramInfo.name = "ton";
534 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
535 paramInfo.unit = "s";
536 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
537 paramInfo.defaultValue = "";
538 paramInfo.description = _( "ON time" );
539 paramInfos.push_back( paramInfo );
540
541 paramInfo.name = "toff";
542 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
543 paramInfo.unit = "s";
544 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
545 paramInfo.defaultValue = "";
546 paramInfo.description = _( "OFF time" );
547 paramInfos.push_back( paramInfo );
548
549 paramInfo.name = "td";
550 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
551 paramInfo.unit = "s";
552 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
553 paramInfo.defaultValue = "0";
554 paramInfo.description = _( "Delay" );
555 paramInfos.push_back( paramInfo );
556
557 paramInfo.name = "n";
558 paramInfo.type = SIM_VALUE::TYPE_INT;
559 paramInfo.unit = "";
560 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
561 paramInfo.defaultValue = "1";
562 paramInfo.description = _( "Number of cycles" );
563 paramInfos.push_back( paramInfo );
564
565 return paramInfos;
566}
567
568
569std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_IBIS::makePrbsWaveformParamInfos()
570{
571 std::vector<PARAM::INFO> paramInfos;
572 PARAM::INFO paramInfo;
573
574 paramInfo.name = "f0";
575 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
576 paramInfo.unit = "Hz";
577 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
578 paramInfo.defaultValue = "";
579 paramInfo.description = _( "Bitrate" );
580 paramInfos.push_back( paramInfo );
581
582 paramInfo.name = "td";
583 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
584 paramInfo.unit = "s";
585 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
586 paramInfo.defaultValue = "";
587 paramInfo.description = _( "Delay" );
588 paramInfos.push_back( paramInfo );
589
590 paramInfo.name = "n";
591 paramInfo.type = SIM_VALUE::TYPE_INT;
592 paramInfo.unit = "";
593 paramInfo.category = PARAM::CATEGORY::WAVEFORM;
594 paramInfo.defaultValue = "";
595 paramInfo.description = _( "Number of bits" );
596 paramInfos.push_back( paramInfo );
597
598 return paramInfos;
599}
600
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:71
Holds all the data relating to one schematic.
Definition schematic.h:90
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:105
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:31
static constexpr auto NAME_FIELD
Definition sim_library.h:32
wxString ResolveLibraryPath(const wxString &aLibraryPath, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:44
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:475
const PARAM * FindParam(const std::string &aParamName) const
std::vector< PARAM > m_params
Definition sim_model.h:532
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
@ TYPE_STRING
Definition sim_value.h:67
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:189
#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:421
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:54
IBIS_IO_MODE
std::string value
Definition sim_model.h:397
const INFO & info
Definition sim_model.h:398
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.