KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_source.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 (C) 2022 Mikolaj Wielgus
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * https://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
26
27#include <fmt/core.h>
28#include <pegtl.hpp>
29#include <pegtl/contrib/parse_tree.hpp>
30
31
33{
34 using namespace SIM_MODEL_SOURCE_GRAMMAR;
35
36 template <typename Rule> struct pwlValuesSelector : std::false_type {};
37 template <> struct pwlValuesSelector<number<SIM_VALUE::TYPE_FLOAT, NOTATION::SI>>
38 : std::true_type {};
39}
40
41
42std::string SPICE_GENERATOR_SOURCE::ModelLine( const SPICE_ITEM& aItem ) const
43{
44 return "";
45}
46
47std::string SPICE_GENERATOR_SOURCE::TunerCommand( const SPICE_ITEM& aItem, double aValue ) const
48{
49 std::string result = "";
50
51 switch( aItem.model->GetType() )
52 {
53 case SIM_MODEL::TYPE::V: // VDC/IDC: it is clear which parameter should be used
54 case SIM_MODEL::TYPE::I:
55 result = fmt::format( "alter @{}={:g}",
56 aItem.model->SpiceGenerator().ItemName( aItem ),
57 aValue );
58 break;
59
60 default:
61 break; // other sources: unclear which parameter the user wants
62 }
63 return result;
64}
65
66std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
67{
68 SPICE_ITEM item = aItem;
69
70 std::string ac = "";
71 std::string dc = "";
72
73 if( const SIM_MODEL::PARAM* ac_param = m_model.FindParam( "ac" ) )
74 ac = SIM_VALUE::ToSpice( ac_param->value );
75 if( const SIM_MODEL::PARAM* dc_param = m_model.FindParam( "dc" ) )
76 dc = SIM_VALUE::ToSpice( dc_param->value );
77
78 bool emptyLine = true;
79 item.modelName = "";
80
81 // @FIXME
82 // the keyword "DC" refers to both offset of a sine source, and value for DC analysis
83 // Because of this, both values are always equal in a sine source.
84 //
85 // suggestion: rename the sine parameter from "DC" to "offset"
86
87 if( dc != "" )
88 {
89 emptyLine = false;
90 item.modelName += fmt::format( "DC {} ", dc );
91 }
92
93 if( m_model.GetSpiceInfo().functionName != ""
94 && m_model.GetType() != SIM_MODEL::TYPE::V // DC-only sources are already processed
95 && m_model.GetType() != SIM_MODEL::TYPE::I )
96 {
97 std::string args = "";
98
99 switch( m_model.GetType() )
100 {
101 case SIM_MODEL::TYPE::V_PWL:
102 case SIM_MODEL::TYPE::I_PWL:
103 {
104 tao::pegtl::string_input<> in( m_model.GetParam( 0 ).value, "from_content" );
105 std::unique_ptr<tao::pegtl::parse_tree::node> root;
106
107 try
108 {
109 root = tao::pegtl::parse_tree::parse<SIM_MODEL_SOURCE_PARSER::pwlValuesGrammar,
111 }
112 catch( const tao::pegtl::parse_error& )
113 {
114 break;
115 }
116
117 if( root )
118 {
119 for( const auto& node : root->children )
120 {
122 SIM_VALUE::NOTATION::SI>>() )
123 {
124 args.append( SIM_VALUE::ToSpice( node->string() ) + " " );
125 }
126 }
127 }
128
129 break;
130 }
131
132 case SIM_MODEL::TYPE::V_WHITENOISE:
133 case SIM_MODEL::TYPE::I_WHITENOISE:
134 args.append( getParamValueString( "rms", "0" ) + " " );
135 args.append( getParamValueString( "dt", "0" ) + " " );
136 args.append( "0 0 0 0 0 " );
137 break;
138
139 case SIM_MODEL::TYPE::V_PINKNOISE:
140 case SIM_MODEL::TYPE::I_PINKNOISE:
141 args.append( "0 " );
142 args.append( getParamValueString( "dt", "0" ) + " " );
143 args.append( getParamValueString( "slope", "0" ) + " " );
144 args.append( getParamValueString( "rms", "0" ) + " " );
145 args.append( "0 0 0 " );
146 break;
147
148 case SIM_MODEL::TYPE::V_BURSTNOISE:
149 case SIM_MODEL::TYPE::I_BURSTNOISE:
150 args.append( "0 0 0 0 " );
151 args.append( getParamValueString( "ampl", "0" ) + " " );
152 args.append( getParamValueString( "tcapt", "0" ) + " " );
153 args.append( getParamValueString( "temit", "0" ) + " " );
154 break;
155
156 case SIM_MODEL::TYPE::V_RANDUNIFORM:
157 case SIM_MODEL::TYPE::I_RANDUNIFORM:
158 {
159 args.append( "1 " );
160 args.append( getParamValueString( "ts", "0" ) + " " );
161 args.append( getParamValueString( "td", "0" ) + " " );
162 args.append( getParamValueString( "range", "1" ) + " " );
163 args.append( getParamValueString( "offset", "0" ) + " " );
164 break;
165 }
166
167 case SIM_MODEL::TYPE::V_RANDGAUSSIAN:
168 case SIM_MODEL::TYPE::I_RANDGAUSSIAN:
169 args.append( "2 " );
170 args.append( getParamValueString( "ts", "0" ) + " " );
171 args.append( getParamValueString( "td", "0" ) + " " );
172 args.append( getParamValueString( "stddev", "1" ) + " " );
173 args.append( getParamValueString( "mean", "0" ) + " " );
174 break;
175
176 case SIM_MODEL::TYPE::V_RANDEXP:
177 case SIM_MODEL::TYPE::I_RANDEXP:
178 args.append( "3 " );
179 args.append( getParamValueString( "ts", "0" ) + " " );
180 args.append( getParamValueString( "td", "0" ) + " " );
181 args.append( getParamValueString( "mean", "1" ) + " " );
182 args.append( getParamValueString( "offset", "0" ) + " " );
183 break;
184
185 case SIM_MODEL::TYPE::V_RANDPOISSON:
186 case SIM_MODEL::TYPE::I_RANDPOISSON:
187 args.append( "4 " );
188 args.append( getParamValueString( "ts", "0" ) + " " );
189 args.append( getParamValueString( "td", "0" ) + " " );
190 args.append( getParamValueString( "lambda", "1" ) + " " );
191 args.append( getParamValueString( "offset", "0" ) + " " );
192 break;
193
194 default:
195 for( int ii = 0; ii < m_model.GetParamCount(); ++ii )
196 {
197 const SIM_MODEL::PARAM& param = m_model.GetParam( ii );
198
199 if( ac != "" && ( param.Matches( "ac" ) || param.Matches( "ph" ) ) )
200 continue;
201
202 std::string argStr = SIM_VALUE::ToSpice( param.value );
203
204 if( argStr != "" )
205 args.append( argStr + " " );
206 }
207
208 break;
209 }
210
211 emptyLine = false;
212 item.modelName += fmt::format( "{}( {}) ", m_model.GetSpiceInfo().functionName, args );
213 }
214 else
215 {
216 switch( m_model.GetType() )
217 case SIM_MODEL::TYPE::V_VCL:
218 case SIM_MODEL::TYPE::I_VCL:
219 {
220 item.modelName += fmt::format( "{} ", getParamValueString( "gain", "1.0" ) );
221 emptyLine = false;
222
223 break;
224
225 case SIM_MODEL::TYPE::V_CCL:
226 case SIM_MODEL::TYPE::I_CCL:
227 item.modelName += fmt::format( "{} {} ",
228 getParamValueString( "control", "V?" ),
229 getParamValueString( "gain", "1.0" ) );
230 emptyLine = false;
231 break;
232
233 default:
234 break;
235 }
236 }
237
238 if( ac != "" )
239 {
240 std::string ph = "";
241
242 if( const SIM_MODEL::PARAM* ph_param = m_model.FindParam( "ph" ) )
243 ph = SIM_VALUE::ToSpice( ph_param->value );
244
245 emptyLine = false;
246 item.modelName += fmt::format( "AC {} {} ", ac, ph );
247 }
248
249 std::string portnum = "";
250
251 if( const SIM_MODEL::PARAM* portnum_param = m_model.FindParam( "portnum" ) )
252 portnum = SIM_VALUE::ToSpice( portnum_param->value );
253
254 if( portnum != "" )
255 {
256 item.modelName += fmt::format( "portnum {} ", portnum );
257
258 std::string z0 = "";
259
260 if( const SIM_MODEL::PARAM* z0_param = m_model.FindParam( "z0" ) )
261 z0 = SIM_VALUE::ToSpice( z0_param->value );
262
263 if( z0 != "" )
264 item.modelName += fmt::format( "z0 {} ", z0 );
265 }
266
267 if( emptyLine )
268 {
269 item.modelName = SIM_VALUE::ToSpice( m_model.GetParam( 0 ).value );
270 }
271
272 return SPICE_GENERATOR::ItemLine( item );
273}
274
275
276std::string SPICE_GENERATOR_SOURCE::getParamValueString( const std::string& aParamName,
277 const std::string& aDefaultValue ) const
278{
279 std::string result = "";
280
281 if ( m_model.FindParam( aParamName ) )
282 result = SIM_VALUE::ToSpice( m_model.FindParam( aParamName )->value );
283
284 if( result == "" )
285 result = aDefaultValue;
286
287 return result;
288}
289
290
292 SIM_MODEL( aType, std::make_unique<SPICE_GENERATOR_SOURCE>( *this ),
293 std::make_unique<SIM_MODEL_SOURCE_SERIALIZER>( *this ) )
294{
295 for( const SIM_MODEL::PARAM::INFO& paramInfo : makeParamInfos( aType ) )
296 AddParam( paramInfo );
297}
298
299
300void SIM_MODEL_SOURCE::doSetParamValue( int aParamIndex, const std::string& aValue )
301{
302 // Sources are special. All preceding parameter values must be filled. If they are not, fill
303 // them out automatically. If a value is nulled, delete everything after it.
304 if( aValue.empty() )
305 {
306 for( int paramIndex = aParamIndex; paramIndex < GetParamCount(); ++paramIndex )
307 {
308 m_params.at( aParamIndex ).value = "";
309 }
310 }
311 else
312 {
313 for( int paramIndex = 0; paramIndex < aParamIndex; ++paramIndex )
314 {
315 if( GetParam( paramIndex ).value == "" )
316 {
317 double dummy;
318 wxString defaultValue = m_params.at( aParamIndex ).info.defaultValue;
319
320 if( !defaultValue.ToDouble( &dummy ) )
321 defaultValue = wxT( "0" );
322
323 m_params.at( aParamIndex ).value = defaultValue;
324 SIM_MODEL::SetParamValue( paramIndex, defaultValue.ToStdString() );
325 }
326 }
327 }
328
329 return SIM_MODEL::doSetParamValue( aParamIndex, aValue );
330}
331
332
333const std::vector<SIM_MODEL::PARAM::INFO>& SIM_MODEL_SOURCE::makeParamInfos( TYPE aType )
334{
335 static std::vector<PARAM::INFO> vdc = makeDcParamInfos( "y", "V" );
336 static std::vector<PARAM::INFO> idc = makeDcParamInfos( "y", "A" );
337
338 static std::vector<PARAM::INFO> vsin = makeSinParamInfos( "y", "V" );
339 static std::vector<PARAM::INFO> isin = makeSinParamInfos( "y", "A" );
340
341 static std::vector<PARAM::INFO> vpulse = makePulseParamInfos( "y", "V" );
342 static std::vector<PARAM::INFO> ipulse = makePulseParamInfos( "y", "A" );
343
344 static std::vector<PARAM::INFO> vexp = makeExpParamInfos( "y", "V" );
345 static std::vector<PARAM::INFO> iexp = makeExpParamInfos( "y", "A" );
346
347 static std::vector<PARAM::INFO> vam = makeAMParamInfos( "y", "V" );
348 static std::vector<PARAM::INFO> iam = makeAMParamInfos( "y", "A" );
349
350 static std::vector<PARAM::INFO> vsffm = makeSFFMParamInfos( "y", "V" );
351 static std::vector<PARAM::INFO> isffm = makeSFFMParamInfos( "y", "A" );
352
353 static std::vector<PARAM::INFO> vcvs = makeVcParamInfos( "" );
354 static std::vector<PARAM::INFO> ccvs = makeCcParamInfos( "ohm" );
355 static std::vector<PARAM::INFO> vpwl = makePwlParamInfos( "y", "Voltage", "V" );
356
357 static std::vector<PARAM::INFO> vccs = makeVcParamInfos( "S" );
358 static std::vector<PARAM::INFO> cccs = makeCcParamInfos( "" );
359 static std::vector<PARAM::INFO> ipwl = makePwlParamInfos( "y", "Current", "A" );
360
361 static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoiseParamInfos( "y", "V" );
362 static std::vector<PARAM::INFO> iwhitenoise = makeWhiteNoiseParamInfos( "y", "A" );
363
364 static std::vector<PARAM::INFO> vpinknoise = makePinkNoiseParamInfos( "y", "V" );
365 static std::vector<PARAM::INFO> ipinknoise = makePinkNoiseParamInfos( "y", "A" );
366
367 static std::vector<PARAM::INFO> vburstnoise = makeBurstNoiseParamInfos( "y", "V" );
368 static std::vector<PARAM::INFO> iburstnoise = makeBurstNoiseParamInfos( "y", "A" );
369
370 static std::vector<PARAM::INFO> vrandomuniform = makeRandomUniformParamInfos( "y", "V" );
371 static std::vector<PARAM::INFO> irandomuniform = makeRandomUniformParamInfos( "y", "A" );
372
373 static std::vector<PARAM::INFO> vrandomnormal = makeRandomNormalParamInfos( "y", "V" );
374 static std::vector<PARAM::INFO> irandomnormal = makeRandomNormalParamInfos( "y", "A" );
375
376 static std::vector<PARAM::INFO> vrandomexp = makeRandomExpParamInfos( "y", "V" );
377 static std::vector<PARAM::INFO> irandomexp = makeRandomExpParamInfos( "y", "A" );
378
379 static std::vector<PARAM::INFO> vrandompoisson = makeRandomPoissonParamInfos( "y", "V" );
380 static std::vector<PARAM::INFO> irandompoisson = makeRandomPoissonParamInfos( "y", "A" );
381
382 switch( aType )
383 {
384 case TYPE::V: return vdc;
385 case TYPE::I: return idc;
386 case TYPE::V_SIN: return vsin;
387 case TYPE::I_SIN: return isin;
388 case TYPE::V_PULSE: return vpulse;
389 case TYPE::I_PULSE: return ipulse;
390 case TYPE::V_EXP: return vexp;
391 case TYPE::I_EXP: return iexp;
392 case TYPE::V_AM: return vam;
393 case TYPE::I_AM: return iam;
394 case TYPE::V_SFFM: return vsffm;
395 case TYPE::I_SFFM: return isffm;
396 case TYPE::V_VCL: return vcvs;
397 case TYPE::V_CCL: return ccvs;
398 case TYPE::V_PWL: return vpwl;
399 case TYPE::I_VCL: return vccs;
400 case TYPE::I_CCL: return cccs;
401 case TYPE::I_PWL: return ipwl;
402 case TYPE::V_WHITENOISE: return vwhitenoise;
403 case TYPE::I_WHITENOISE: return iwhitenoise;
404 case TYPE::V_PINKNOISE: return vpinknoise;
405 case TYPE::I_PINKNOISE: return ipinknoise;
406 case TYPE::V_BURSTNOISE: return vburstnoise;
407 case TYPE::I_BURSTNOISE: return iburstnoise;
408 case TYPE::V_RANDUNIFORM: return vrandomuniform;
409 case TYPE::I_RANDUNIFORM: return irandomuniform;
410 case TYPE::V_RANDGAUSSIAN: return vrandomnormal;
411 case TYPE::I_RANDGAUSSIAN: return irandomnormal;
412 case TYPE::V_RANDEXP: return vrandomexp;
413 case TYPE::I_RANDEXP: return irandomexp;
414 case TYPE::V_RANDPOISSON: return vrandompoisson;
415 case TYPE::I_RANDPOISSON: return irandompoisson;
416 default:
417 wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_SOURCE" );
418 static std::vector<SIM_MODEL::PARAM::INFO> empty;
419 return empty;
420 }
421}
422
423
424std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeDcParamInfos( const std::string& aPrefix,
425 const std::string& aUnit )
426{
427 std::vector<PARAM::INFO> paramInfos;
428 PARAM::INFO paramInfo;
429
430 paramInfo.name = "dc";
431 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
432 paramInfo.unit = aUnit;
433 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
434 paramInfo.defaultValue = "0";
435 paramInfo.description = "DC value";
436 paramInfos.push_back( paramInfo );
437
438 appendAcParamInfos( paramInfos, aUnit );
439 appendSpParamInfos( paramInfos, aUnit );
440 return paramInfos;
441}
442
443
444std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeSinParamInfos( const std::string& aPrefix,
445 const std::string& aUnit )
446{
447 std::vector<PARAM::INFO> paramInfos;
448 PARAM::INFO paramInfo;
449
450 paramInfo.name = "dc";
451 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
452 paramInfo.unit = aUnit;
453 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
454 paramInfo.defaultValue = "";
455 paramInfo.description = "DC offset";
456 paramInfos.push_back( paramInfo );
457
458 paramInfo.name = "ampl";
459 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
460 paramInfo.unit = aUnit;
461 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
462 paramInfo.defaultValue = "";
463 paramInfo.description = "Amplitude";
464 paramInfos.push_back( paramInfo );
465
466 paramInfo.name = "f";
467 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
468 paramInfo.unit = "Hz";
469 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
470 paramInfo.defaultValue = "1/tstop";
471 paramInfo.description = "Frequency";
472 paramInfos.push_back( paramInfo );
473
474 paramInfo.name = "td";
475 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
476 paramInfo.unit = "s";
477 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
478 paramInfo.defaultValue = "0";
479 paramInfo.description = "Delay";
480 paramInfos.push_back( paramInfo );
481
482 paramInfo.name = "theta";
483 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
484 paramInfo.unit = "1/s";
485 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
486 paramInfo.defaultValue = "0";
487 paramInfo.description = "Damping factor";
488 paramInfos.push_back( paramInfo );
489
490 paramInfo.name = "phase";
491 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
492 paramInfo.unit = "°";
493 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
494 paramInfo.defaultValue = "0";
495 paramInfo.description = "Phase";
496 paramInfos.push_back( paramInfo );
497
498 appendAcParamInfos( paramInfos, aUnit );
499 appendSpParamInfos( paramInfos, aUnit );
500 return paramInfos;
501}
502
503
504std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePulseParamInfos( const std::string& aPrefix,
505 const std::string& aUnit )
506{
507 std::vector<PARAM::INFO> paramInfos;
508 PARAM::INFO paramInfo;
509
510 paramInfo.name = aPrefix + "1";
511 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
512 paramInfo.unit = aUnit;
513 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
514 paramInfo.defaultValue = "";
515 paramInfo.description = "Initial value";
516 paramInfos.push_back( paramInfo );
517
518 paramInfo.name = aPrefix + "2";
519 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
520 paramInfo.unit = aUnit;
521 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
522 paramInfo.defaultValue = "";
523 paramInfo.description = "Pulsed value";
524 paramInfos.push_back( paramInfo );
525
526 paramInfo.name = "td";
527 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
528 paramInfo.unit = "s";
529 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
530 paramInfo.defaultValue = "0";
531 paramInfo.description = "Delay";
532 paramInfos.push_back( paramInfo );
533
534 paramInfo.name = "tr";
535 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
536 paramInfo.unit = "s";
537 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
538 paramInfo.defaultValue = "tstep";
539 paramInfo.description = "Rise time";
540 paramInfos.push_back( paramInfo );
541
542 paramInfo.name = "tf";
543 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
544 paramInfo.unit = "s";
545 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
546 paramInfo.defaultValue = "tstep";
547 paramInfo.description = "Fall time";
548 paramInfos.push_back( paramInfo );
549
550 paramInfo.name = "tw"; // Ngspice calls it "pw".
551 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
552 paramInfo.unit = "s";
553 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
554 paramInfo.defaultValue = "tstop";
555 paramInfo.description = "Pulse width";
556 paramInfos.push_back( paramInfo );
557
558 paramInfo.name = "per";
559 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
560 paramInfo.unit = "s";
561 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
562 paramInfo.defaultValue = "tstop";
563 paramInfo.description = "Period";
564 paramInfos.push_back( paramInfo );
565
566 paramInfo.name = "np";
567 paramInfo.type = SIM_VALUE::TYPE_INT;
568 paramInfo.unit = "";
569 paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
570 paramInfo.defaultValue = "";
571 paramInfo.description = "Number of pulses";
572 paramInfos.push_back( paramInfo );
573
574 appendAcParamInfos( paramInfos, aUnit );
575 appendSpParamInfos( paramInfos, aUnit );
576 return paramInfos;
577}
578
579
580std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeExpParamInfos( const std::string& aPrefix,
581 const std::string& aUnit )
582{
583 std::vector<PARAM::INFO> paramInfos;
584 PARAM::INFO paramInfo;
585
586 paramInfo.name = aPrefix + "1";
587 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
588 paramInfo.unit = aUnit;
589 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
590 paramInfo.defaultValue = "";
591 paramInfo.description = "Initial value";
592 paramInfos.push_back( paramInfo );
593
594 paramInfo.name = aPrefix + "2";
595 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
596 paramInfo.unit = aUnit;
597 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
598 paramInfo.defaultValue = "";
599 paramInfo.description = "Pulsed value";
600 paramInfos.push_back( paramInfo );
601
602 paramInfo.name = "td1";
603 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
604 paramInfo.unit = "s";
605 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
606 paramInfo.defaultValue = "0";
607 paramInfo.description = "Rise delay time";
608 paramInfos.push_back( paramInfo );
609
610 paramInfo.name = "tau1";
611 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
612 paramInfo.unit = "s";
613 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
614 paramInfo.defaultValue = "tstep";
615 paramInfo.description = "Rise time constant";
616 paramInfos.push_back( paramInfo );
617
618 paramInfo.name = "td2";
619 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
620 paramInfo.unit = "s";
621 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
622 paramInfo.defaultValue = "td1+tstep";
623 paramInfo.description = "Fall delay time";
624 paramInfos.push_back( paramInfo );
625
626 paramInfo.name = "tau2";
627 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
628 paramInfo.unit = "s";
629 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
630 paramInfo.defaultValue = "tstep";
631 paramInfo.description = "Fall time constant";
632 paramInfos.push_back( paramInfo );
633
634 appendAcParamInfos( paramInfos, aUnit );
635 appendSpParamInfos( paramInfos, aUnit );
636 return paramInfos;
637}
638
639
640std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeAMParamInfos( const std::string& aPrefix,
641 const std::string& aUnit )
642{
643 std::vector<PARAM::INFO> paramInfos;
644 PARAM::INFO paramInfo;
645
646 paramInfo.name = "vo";
647 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
648 paramInfo.unit = aUnit;
649 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
650 paramInfo.defaultValue = "";
651 paramInfo.description = "Overall offset";
652 paramInfos.push_back( paramInfo );
653
654 paramInfo.name = "vmo";
655 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
656 paramInfo.unit = aUnit;
657 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
658 paramInfo.defaultValue = "";
659 paramInfo.description = "Modulation signal offset";
660 paramInfos.push_back( paramInfo );
661
662 paramInfo.name = "vma";
663 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
664 paramInfo.unit = aUnit;
665 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
666 paramInfo.defaultValue = "";
667 paramInfo.description = "Modulation signal amplitude";
668 paramInfos.push_back( paramInfo );
669
670 paramInfo.name = "fm";
671 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
672 paramInfo.unit = "Hz";
673 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
674 paramInfo.defaultValue = "5/tstop";
675 paramInfo.description = "Modulation signal frequency";
676 paramInfos.push_back( paramInfo );
677
678 paramInfo.name = "fc";
679 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
680 paramInfo.unit = "Hz";
681 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
682 paramInfo.defaultValue = "500/tstop";
683 paramInfo.description = "Carrier signal frequency";
684 paramInfos.push_back( paramInfo );
685
686 paramInfo.name = "td";
687 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
688 paramInfo.unit = "s";
689 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
690 paramInfo.defaultValue = "0";
691 paramInfo.description = "Overall delay";
692 paramInfos.push_back( paramInfo );
693
694 paramInfo.name = "phasem";
695 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
696 paramInfo.unit = "°";
697 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
698 paramInfo.defaultValue = "0";
699 paramInfo.description = "Modulation signal phase";
700 paramInfos.push_back( paramInfo );
701
702 paramInfo.name = "phasec";
703 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
704 paramInfo.unit = "°";
705 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
706 paramInfo.defaultValue = "0";
707 paramInfo.description = "Carrier signal phase";
708 paramInfos.push_back( paramInfo );
709
710 appendAcParamInfos( paramInfos, aUnit );
711 appendSpParamInfos( paramInfos, aUnit );
712 return paramInfos;
713}
714
715
716std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeSFFMParamInfos( const std::string& aPrefix,
717 const std::string& aUnit )
718{
719 std::vector<PARAM::INFO> paramInfos;
720 PARAM::INFO paramInfo;
721
722 paramInfo.name = "vo";
723 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
724 paramInfo.unit = aUnit;
725 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
726 paramInfo.defaultValue = "";
727 paramInfo.description = "DC offset";
728 paramInfos.push_back( paramInfo );
729
730 paramInfo.name = "va";
731 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
732 paramInfo.unit = aUnit;
733 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
734 paramInfo.defaultValue = "";
735 paramInfo.description = "Amplitude";
736 paramInfos.push_back( paramInfo );
737
738 paramInfo.name = "fm";
739 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
740 paramInfo.unit = "Hz";
741 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
742 paramInfo.defaultValue = "5/tstop";
743 paramInfo.description = "Modulating frequency";
744 paramInfos.push_back( paramInfo );
745
746 paramInfo.name = "mdi";
747 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
748 paramInfo.unit = "";
749 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
750 paramInfo.defaultValue = "";
751 paramInfo.description = "Modulation index";
752 paramInfos.push_back( paramInfo );
753
754 paramInfo.name = "fc";
755 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
756 paramInfo.unit = "Hz";
757 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
758 paramInfo.defaultValue = "500/tstop";
759 paramInfo.description = "Carrier frequency";
760 paramInfos.push_back( paramInfo );
761
762 paramInfo.name = "phasem";
763 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
764 paramInfo.unit = "°";
765 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
766 paramInfo.defaultValue = "0";
767 paramInfo.description = "Modulating signal phase";
768 paramInfos.push_back( paramInfo );
769
770 paramInfo.name = "phasec";
771 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
772 paramInfo.unit = "°";
773 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
774 paramInfo.defaultValue = "0";
775 paramInfo.description = "Carrier signal phase";
776 paramInfos.push_back( paramInfo );
777
778 appendAcParamInfos( paramInfos, aUnit );
779 appendSpParamInfos( paramInfos, aUnit );
780 return paramInfos;
781}
782
783
784std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeCcParamInfos( const std::string& aGainUnit )
785{
786 std::vector<PARAM::INFO> paramInfos;
787 PARAM::INFO paramInfo;
788
789 paramInfo.name = "gain";
790 paramInfo.id = 1;
791 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
792 paramInfo.unit = aGainUnit;
793 paramInfo.description = "Gain";
794 paramInfos.push_back( paramInfo );
795
796 paramInfo.name = "control";
797 paramInfo.id = 2;
798 paramInfo.type = SIM_VALUE::TYPE_STRING;
799 paramInfo.unit = "";
800 paramInfo.description = "Controlling voltage source";
801 paramInfos.push_back( paramInfo );
802
803 return paramInfos;
804}
805
806
807std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeVcParamInfos( const std::string& aGainUnit )
808{
809 std::vector<PARAM::INFO> paramInfos;
810 PARAM::INFO paramInfo;
811
812 paramInfo.name = "gain";
813 paramInfo.id = 1;
814 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
815 paramInfo.unit = aGainUnit;
816 paramInfo.description = "Gain";
817 paramInfos.push_back( paramInfo );
818
819 return paramInfos;
820}
821
822
823std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePwlParamInfos( const std::string& aPrefix,
824 const std::string& aQuantity,
825 const std::string& aUnit )
826{
827 std::vector<PARAM::INFO> paramInfos;
828 PARAM::INFO paramInfo;
829
830 paramInfo.name = "pwl";
831 paramInfo.type = SIM_VALUE::TYPE_STRING;
832 paramInfo.unit = "s," + aUnit;
833 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
834 paramInfo.defaultValue = "";
835 paramInfo.description = aUnit == "V" ? "Time-voltage points" : "Time-current points";
836 paramInfos.push_back( paramInfo );
837
838 // TODO: Ngspice doesn't support "td" and "r" for current sources, so let's disable that for
839 // now.
840
841 /*paramInfo.name = "td";
842 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
843 paramInfo.unit = "s";
844 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
845 paramInfo.defaultValue = "0";
846 paramInfo.description = aUnit == "V" ? "Time-voltage points" : "Time-current points";
847 paramInfo.isSpiceInstanceParam = true;
848 paramInfos.push_back( paramInfo );
849
850 paramInfo.name = "repeat";
851 paramInfo.type = SIM_VALUE::TYPE_BOOL;
852 paramInfo.unit = "";
853 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
854 paramInfo.defaultValue = "0";
855 paramInfo.description = "Repeat forever";
856 paramInfo.isSpiceInstanceParam = true;
857 paramInfo.spiceInstanceName = "r";
858 paramInfos.push_back( paramInfo );*/
859
860 /*paramInfo.name = "t";
861 paramInfo.type = SIM_VALUE::TYPE_FLOAT_VECTOR;
862 paramInfo.unit = "s";
863 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
864 paramInfo.defaultValue = "";
865 paramInfo.description = "Time vector";
866 paramInfos.push_back( paramInfo );
867
868 paramInfo.name = aPrefix;
869 paramInfo.type = SIM_VALUE::TYPE_FLOAT_VECTOR;
870 paramInfo.unit = aUnit;
871 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
872 paramInfo.defaultValue = "";
873 paramInfo.description = aQuantity + " vector";
874 paramInfos.push_back( paramInfo );
875
876 paramInfo.name = "repeat";
877 paramInfo.type = SIM_VALUE::TYPE_BOOL;
878 paramInfo.unit = "";
879 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
880 paramInfo.defaultValue = "";
881 paramInfo.description = "Repeat forever";
882 paramInfos.push_back( paramInfo );
883
884 paramInfo.name = "td";
885 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
886 paramInfo.unit = "s";
887 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
888 paramInfo.defaultValue = "0";
889 paramInfo.description = "Delay";
890 paramInfos.push_back( paramInfo );*/
891
892 appendAcParamInfos( paramInfos, aUnit );
893 appendSpParamInfos( paramInfos, aUnit );
894 return paramInfos;
895}
896
897
898std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeWhiteNoiseParamInfos( const std::string& aPrefix,
899 const std::string& aUnit )
900{
901 std::vector<PARAM::INFO> paramInfos;
902 PARAM::INFO paramInfo;
903
904 paramInfo.name = "rms";
905 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
906 paramInfo.unit = aUnit;
907 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
908 paramInfo.defaultValue = "0";
909 paramInfo.description = "White noise RMS amplitude";
910 paramInfos.push_back( paramInfo );
911
912 paramInfo.name = "dt";
913 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
914 paramInfo.unit = "s";
915 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
916 paramInfo.defaultValue = "0";
917 paramInfo.description = "Time step";
918 paramInfos.push_back( paramInfo );
919
920 appendAcParamInfos( paramInfos, aUnit );
921 appendSpParamInfos( paramInfos, aUnit );
922 return paramInfos;
923}
924
925
926std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePinkNoiseParamInfos( const std::string& aPrefix,
927 const std::string& aUnit )
928{
929 std::vector<PARAM::INFO> paramInfos;
930 PARAM::INFO paramInfo;
931
932 paramInfo.name = "rms";
933 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
934 paramInfo.unit = "";
935 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
936 paramInfo.defaultValue = "0";
937 paramInfo.description = "1/f noise RMS amplitude";
938 paramInfos.push_back( paramInfo );
939
940 paramInfo.name = "slope";
941 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
942 paramInfo.unit = "";
943 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
944 paramInfo.defaultValue = "1";
945 paramInfo.description = "1/f noise exponent";
946 paramInfos.push_back( paramInfo );
947
948 paramInfo.name = "dt";
949 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
950 paramInfo.unit = "s";
951 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
952 paramInfo.defaultValue = "0";
953 paramInfo.description = "Time step";
954 paramInfos.push_back( paramInfo );
955
956 appendAcParamInfos( paramInfos, aUnit );
957 appendSpParamInfos( paramInfos, aUnit );
958 return paramInfos;
959}
960
961
962std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeBurstNoiseParamInfos( const std::string& aPrefix,
963 const std::string& aUnit )
964{
965 std::vector<PARAM::INFO> paramInfos;
966 PARAM::INFO paramInfo;
967
968 paramInfo.name = "ampl";
969 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
970 paramInfo.unit = aUnit;
971 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
972 paramInfo.defaultValue = "0";
973 paramInfo.description = "Burst noise amplitude";
974 paramInfos.push_back( paramInfo );
975
976 paramInfo.name = "tcapt";
977 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
978 paramInfo.unit = "s";
979 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
980 paramInfo.defaultValue = "0";
981 paramInfo.description = "Burst noise trap capture time";
982 paramInfos.push_back( paramInfo );
983
984 paramInfo.name = "temit";
985 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
986 paramInfo.unit = "s";
987 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
988 paramInfo.defaultValue = "0";
989 paramInfo.description = "Burst noise trap emission time";
990 paramInfos.push_back( paramInfo );
991
992 appendAcParamInfos( paramInfos, aUnit );
993 appendSpParamInfos( paramInfos, aUnit );
994 return paramInfos;
995}
996
997
998std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomUniformParamInfos( const std::string& aPrefix,
999 const std::string& aUnit )
1000{
1001 std::vector<PARAM::INFO> paramInfos;
1002 PARAM::INFO paramInfo;
1003
1004 paramInfo.name = "ts";
1005 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1006 paramInfo.unit = "s";
1007 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1008 paramInfo.defaultValue = "";
1009 paramInfo.description = "Individual voltage duration";
1010 paramInfos.push_back( paramInfo );
1011
1012 paramInfo.name = "td";
1013 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1014 paramInfo.unit = "s";
1015 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1016 paramInfo.defaultValue = "0";
1017 paramInfo.description = "Delay";
1018 paramInfos.push_back( paramInfo );
1019
1020 paramInfo.name = "range";
1021 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1022 paramInfo.unit = aUnit;
1023 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1024 paramInfo.defaultValue = "1";
1025 paramInfo.description = "Range";
1026 paramInfos.push_back( paramInfo );
1027
1028 paramInfo.name = "offset";
1029 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1030 paramInfo.unit = aUnit;
1031 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1032 paramInfo.defaultValue = "0";
1033 paramInfo.description = "Offset";
1034 paramInfos.push_back( paramInfo );
1035
1036 appendAcParamInfos( paramInfos, aUnit );
1037 appendSpParamInfos( paramInfos, aUnit );
1038 return paramInfos;
1039}
1040
1041
1042std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomNormalParamInfos( const std::string& aPrefix,
1043 const std::string& aUnit )
1044{
1045 std::vector<PARAM::INFO> paramInfos;
1046 PARAM::INFO paramInfo;
1047
1048 paramInfo.name = "ts";
1049 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1050 paramInfo.unit = "s";
1051 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1052 paramInfo.defaultValue = "";
1053 paramInfo.description = "Individual voltage duration";
1054 paramInfos.push_back( paramInfo );
1055
1056 paramInfo.name = "td";
1057 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1058 paramInfo.unit = "s";
1059 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1060 paramInfo.defaultValue = "0";
1061 paramInfo.description = "Delay";
1062 paramInfos.push_back( paramInfo );
1063
1064 paramInfo.name = "stddev";
1065 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1066 paramInfo.unit = aUnit;
1067 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1068 paramInfo.defaultValue = "1";
1069 paramInfo.description = "Standard deviation";
1070 paramInfos.push_back( paramInfo );
1071
1072 paramInfo.name = "mean";
1073 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1074 paramInfo.unit = aUnit;
1075 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1076 paramInfo.defaultValue = "0";
1077 paramInfo.description = "Mean";
1078 paramInfos.push_back( paramInfo );
1079
1080 appendAcParamInfos( paramInfos, aUnit );
1081 appendSpParamInfos( paramInfos, aUnit );
1082 return paramInfos;
1083}
1084
1085
1086std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomExpParamInfos( const std::string& aPrefix,
1087 const std::string& aUnit )
1088{
1089 std::vector<PARAM::INFO> paramInfos;
1090 PARAM::INFO paramInfo;
1091
1092 paramInfo.name = "ts";
1093 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1094 paramInfo.unit = "s";
1095 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1096 paramInfo.defaultValue = "";
1097 paramInfo.description = "Individual voltage duration";
1098 paramInfos.push_back( paramInfo );
1099
1100 paramInfo.name = "td";
1101 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1102 paramInfo.unit = "s";
1103 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1104 paramInfo.defaultValue = "0";
1105 paramInfo.description = "Delay";
1106 paramInfos.push_back( paramInfo );
1107
1108 paramInfo.name = "mean";
1109 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1110 paramInfo.unit = aUnit;
1111 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1112 paramInfo.defaultValue = "1";
1113 paramInfo.description = "Mean";
1114 paramInfos.push_back( paramInfo );
1115
1116 paramInfo.name = "offset";
1117 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1118 paramInfo.unit = aUnit;
1119 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1120 paramInfo.defaultValue = "0";
1121 paramInfo.description = "Offset";
1122 paramInfos.push_back( paramInfo );
1123
1124 appendAcParamInfos( paramInfos, aUnit );
1125 appendSpParamInfos( paramInfos, aUnit );
1126 return paramInfos;
1127}
1128
1129
1130std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeRandomPoissonParamInfos( const std::string& aPrefix,
1131 const std::string& aUnit )
1132{
1133 std::vector<PARAM::INFO> paramInfos;
1134 PARAM::INFO paramInfo;
1135
1136 paramInfo.name = "ts";
1137 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1138 paramInfo.unit = "s";
1139 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1140 paramInfo.defaultValue = "";
1141 paramInfo.description = "Individual voltage duration";
1142 paramInfos.push_back( paramInfo );
1143
1144 paramInfo.name = "td";
1145 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1146 paramInfo.unit = "s";
1147 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1148 paramInfo.defaultValue = "0";
1149 paramInfo.description = "Delay";
1150 paramInfos.push_back( paramInfo );
1151
1152 paramInfo.name = "lambda";
1153 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1154 paramInfo.unit = aUnit;
1155 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1156 paramInfo.defaultValue = "1";
1157 paramInfo.description = "Lambda";
1158 paramInfos.push_back( paramInfo );
1159
1160 paramInfo.name = "offset";
1161 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1162 paramInfo.unit = aUnit;
1163 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
1164 paramInfo.defaultValue = "0";
1165 paramInfo.description = "Offset";
1166 paramInfos.push_back( paramInfo );
1167
1168 appendAcParamInfos( paramInfos, aUnit );
1169 appendSpParamInfos( paramInfos, aUnit );
1170 return paramInfos;
1171}
1172
1173void SIM_MODEL_SOURCE::appendAcParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit )
1174{
1175 PARAM::INFO paramInfo;
1176
1177 paramInfo.name = "ac";
1178 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1179 paramInfo.unit = aUnit;
1180 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::AC;
1181 paramInfo.defaultValue = "0";
1182 paramInfo.description = "AC magnitude";
1183 aParamInfos.push_back( paramInfo );
1184
1185 paramInfo.name = "ph";
1186 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1187 paramInfo.unit = "°";
1188 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::AC;
1189 paramInfo.defaultValue = "0";
1190 paramInfo.description = "AC phase";
1191 aParamInfos.push_back( paramInfo );
1192}
1193
1194void SIM_MODEL_SOURCE::appendSpParamInfos( std::vector<PARAM::INFO>& aParamInfos,
1195 const std::string& aUnit )
1196{
1197 PARAM::INFO paramInfo;
1198
1199 if( !strcmp( aUnit.c_str(), "V" ) )
1200 {
1201 paramInfo.name = "portnum";
1202 paramInfo.type = SIM_VALUE::TYPE_INT;
1203 paramInfo.unit = "";
1204 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::S_PARAM;
1205 paramInfo.defaultValue = "";
1206 paramInfo.description = "Port number";
1207 aParamInfos.push_back( paramInfo );
1208
1209 paramInfo.name = "z0";
1210 paramInfo.type = SIM_VALUE::TYPE_FLOAT;
1211 paramInfo.unit = "Ohm";
1212 paramInfo.category = SIM_MODEL::PARAM::CATEGORY::S_PARAM;
1213 paramInfo.defaultValue = "";
1214 paramInfo.description = "Internal impedance";
1215 aParamInfos.push_back( paramInfo );
1216 }
1217}
1218
1219
1220std::vector<std::string> SIM_MODEL_SOURCE::GetPinNames() const
1221{
1222 if( GetDeviceType() == SIM_MODEL::DEVICE_T::E || GetDeviceType() == SIM_MODEL::DEVICE_T::G )
1223 return { "+", "-", "C+", "C-" };
1224 else
1225 return { "+", "-" };
1226}
1227
1229{
1230 switch( GetType() )
1231 {
1232 case SIM_MODEL::TYPE::V: // VDC/IDC: it is clear which parameter should be used
1233 case SIM_MODEL::TYPE::I:
1234 return &GetParam( 0 );
1235
1236 default:
1237 break; // other sources: unclear which parameter the user wants
1238 }
1239 return nullptr;
1240}
static void appendAcParamInfos(std::vector< PARAM::INFO > &aParamInfos, const std::string &aUnit)
static std::vector< PARAM::INFO > makeBurstNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
std::vector< std::string > GetPinNames() const override
const PARAM * GetTunerParam() const override
static const std::vector< PARAM::INFO > & makeParamInfos(TYPE aType)
static std::vector< PARAM::INFO > makeExpParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeAMParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeRandomNormalParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< SIM_MODEL::PARAM::INFO > makeVcParamInfos(const std::string &aGainUnit)
static void appendSpParamInfos(std::vector< PARAM::INFO > &aParamInfos, const std::string &aUnit)
SIM_MODEL_SOURCE(TYPE aType)
static std::vector< PARAM::INFO > makeRandomExpParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeSFFMParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeRandomUniformParamInfos(const std::string &aPrefix, const std::string &aUnit)
void doSetParamValue(int aParamIndex, const std::string &aValue) override
static std::vector< PARAM::INFO > makeRandomPoissonParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeDcParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePulseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePinkNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makeSinParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< PARAM::INFO > makePwlParamInfos(const std::string &aPrefix, const std::string &aQuantity, const std::string &aUnit)
static std::vector< PARAM::INFO > makeWhiteNoiseParamInfos(const std::string &aPrefix, const std::string &aUnit)
static std::vector< SIM_MODEL::PARAM::INFO > makeCcParamInfos(const std::string &aGainUnit)
void AddParam(const PARAM::INFO &aInfo)
const SPICE_GENERATOR & SpiceGenerator() const
Definition sim_model.h:431
virtual const PARAM & GetParam(unsigned aParamIndex) const
SIM_MODEL()=delete
int GetParamCount() const
Definition sim_model.h:477
DEVICE_T GetDeviceType() const
Definition sim_model.h:459
virtual void doSetParamValue(int aParamIndex, const std::string &aValue)
std::vector< PARAM > m_params
Definition sim_model.h:534
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
TYPE GetType() const
Definition sim_model.h:460
@ TYPE_STRING
Definition sim_value.h:71
static std::string ToSpice(const std::string &aString)
std::string ModelLine(const SPICE_ITEM &aItem) const override
std::string ItemLine(const SPICE_ITEM &aItem) const override
std::string TunerCommand(const SPICE_ITEM &aItem, double aValue) const override
std::string getParamValueString(const std::string &aParamName, const std::string &aDefaultValue) const
virtual std::string ItemName(const SPICE_ITEM &aItem) const
virtual std::string ItemLine(const SPICE_ITEM &aItem) const
const SIM_MODEL & m_model
static bool empty(const wxTextEntryBase *aCtrl)
STL namespace.
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:57
std::vector< FAB_LAYER_COLOR > dummy
std::string modelName
const SIM_MODEL * model
wxString result
Test unit parsing edge cases and error handling.