29#include <pegtl/contrib/parse_tree.hpp>
49 std::string result =
"";
53 case SIM_MODEL::TYPE::V:
54 case SIM_MODEL::TYPE::I:
75 bool emptyLine =
true;
87 item.
modelName += fmt::format(
"DC {} ", dc );
94 std::string args =
"";
98 case SIM_MODEL::TYPE::V_PWL:
99 case SIM_MODEL::TYPE::I_PWL:
102 std::unique_ptr<tao::pegtl::parse_tree::node> root;
110 catch(
const tao::pegtl::parse_error& )
117 for(
const auto& node : root->children )
120 SIM_VALUE::NOTATION::SI>>() )
130 case SIM_MODEL::TYPE::V_WHITENOISE:
131 case SIM_MODEL::TYPE::I_WHITENOISE:
134 args.append(
"0 0 0 0 0 " );
137 case SIM_MODEL::TYPE::V_PINKNOISE:
138 case SIM_MODEL::TYPE::I_PINKNOISE:
143 args.append(
"0 0 0 " );
146 case SIM_MODEL::TYPE::V_BURSTNOISE:
147 case SIM_MODEL::TYPE::I_BURSTNOISE:
148 args.append(
"0 0 0 0 " );
154 case SIM_MODEL::TYPE::V_RANDUNIFORM:
155 case SIM_MODEL::TYPE::I_RANDUNIFORM:
165 case SIM_MODEL::TYPE::V_RANDGAUSSIAN:
166 case SIM_MODEL::TYPE::I_RANDGAUSSIAN:
174 case SIM_MODEL::TYPE::V_RANDEXP:
175 case SIM_MODEL::TYPE::I_RANDEXP:
183 case SIM_MODEL::TYPE::V_RANDPOISSON:
184 case SIM_MODEL::TYPE::I_RANDPOISSON:
197 if( ac !=
"" && (
param.Matches(
"ac" ) ||
param.Matches(
"ph" ) ) )
203 args.append( argStr +
" " );
215 case SIM_MODEL::TYPE::V_VCL:
216 case SIM_MODEL::TYPE::I_VCL:
223 case SIM_MODEL::TYPE::V_CCL:
224 case SIM_MODEL::TYPE::I_CCL:
244 item.
modelName += fmt::format(
"AC {} {} ", ac, ph );
247 std::string portnum =
"";
254 item.
modelName += fmt::format(
"portnum {} ", portnum );
262 item.
modelName += fmt::format(
"z0 {} ", z0 );
275 const std::string& aDefaultValue )
const
277 std::string result =
"";
283 result = aDefaultValue;
304 for(
int paramIndex = aParamIndex; paramIndex <
GetParamCount(); ++paramIndex )
306 m_params.at( aParamIndex ).value =
"";
311 for(
int paramIndex = 0; paramIndex < aParamIndex; ++paramIndex )
316 wxString defaultValue =
m_params.at( aParamIndex ).info.defaultValue;
318 if( !defaultValue.ToDouble( &
dummy ) )
319 defaultValue = wxT(
"0" );
321 m_params.at( aParamIndex ).value = defaultValue;
382 case TYPE::V:
return vdc;
383 case TYPE::I:
return idc;
384 case TYPE::V_SIN:
return vsin;
385 case TYPE::I_SIN:
return isin;
386 case TYPE::V_PULSE:
return vpulse;
387 case TYPE::I_PULSE:
return ipulse;
388 case TYPE::V_EXP:
return vexp;
389 case TYPE::I_EXP:
return iexp;
390 case TYPE::V_AM:
return vam;
391 case TYPE::I_AM:
return iam;
392 case TYPE::V_SFFM:
return vsffm;
393 case TYPE::I_SFFM:
return isffm;
394 case TYPE::V_VCL:
return vcvs;
395 case TYPE::V_CCL:
return ccvs;
396 case TYPE::V_PWL:
return vpwl;
397 case TYPE::I_VCL:
return vccs;
398 case TYPE::I_CCL:
return cccs;
399 case TYPE::I_PWL:
return ipwl;
400 case TYPE::V_WHITENOISE:
return vwhitenoise;
401 case TYPE::I_WHITENOISE:
return iwhitenoise;
402 case TYPE::V_PINKNOISE:
return vpinknoise;
403 case TYPE::I_PINKNOISE:
return ipinknoise;
404 case TYPE::V_BURSTNOISE:
return vburstnoise;
405 case TYPE::I_BURSTNOISE:
return iburstnoise;
406 case TYPE::V_RANDUNIFORM:
return vrandomuniform;
407 case TYPE::I_RANDUNIFORM:
return irandomuniform;
408 case TYPE::V_RANDGAUSSIAN:
return vrandomnormal;
409 case TYPE::I_RANDGAUSSIAN:
return irandomnormal;
410 case TYPE::V_RANDEXP:
return vrandomexp;
411 case TYPE::I_RANDEXP:
return irandomexp;
412 case TYPE::V_RANDPOISSON:
return vrandompoisson;
413 case TYPE::I_RANDPOISSON:
return irandompoisson;
415 wxFAIL_MSG(
"Unhandled SIM_MODEL type in SIM_MODEL_SOURCE" );
416 static std::vector<SIM_MODEL::PARAM::INFO>
empty;
423 const std::string& aUnit )
425 std::vector<PARAM::INFO> paramInfos;
428 paramInfo.
name =
"dc";
430 paramInfo.
unit = aUnit;
434 paramInfos.push_back( paramInfo );
443 const std::string& aUnit )
445 std::vector<PARAM::INFO> paramInfos;
448 paramInfo.
name =
"dc";
450 paramInfo.
unit = aUnit;
454 paramInfos.push_back( paramInfo );
456 paramInfo.
name =
"ampl";
458 paramInfo.
unit = aUnit;
462 paramInfos.push_back( paramInfo );
464 paramInfo.
name =
"f";
466 paramInfo.
unit =
"Hz";
470 paramInfos.push_back( paramInfo );
472 paramInfo.
name =
"td";
474 paramInfo.
unit =
"s";
478 paramInfos.push_back( paramInfo );
480 paramInfo.
name =
"theta";
482 paramInfo.
unit =
"1/s";
486 paramInfos.push_back( paramInfo );
488 paramInfo.
name =
"phase";
490 paramInfo.
unit =
"°";
494 paramInfos.push_back( paramInfo );
503 const std::string& aUnit )
505 std::vector<PARAM::INFO> paramInfos;
508 paramInfo.
name = aPrefix +
"1";
510 paramInfo.
unit = aUnit;
514 paramInfos.push_back( paramInfo );
516 paramInfo.
name = aPrefix +
"2";
518 paramInfo.
unit = aUnit;
522 paramInfos.push_back( paramInfo );
524 paramInfo.
name =
"td";
526 paramInfo.
unit =
"s";
530 paramInfos.push_back( paramInfo );
532 paramInfo.
name =
"tr";
534 paramInfo.
unit =
"s";
538 paramInfos.push_back( paramInfo );
540 paramInfo.
name =
"tf";
542 paramInfo.
unit =
"s";
546 paramInfos.push_back( paramInfo );
548 paramInfo.
name =
"tw";
550 paramInfo.
unit =
"s";
554 paramInfos.push_back( paramInfo );
556 paramInfo.
name =
"per";
558 paramInfo.
unit =
"s";
562 paramInfos.push_back( paramInfo );
564 paramInfo.
name =
"np";
570 paramInfos.push_back( paramInfo );
579 const std::string& aUnit )
581 std::vector<PARAM::INFO> paramInfos;
584 paramInfo.
name = aPrefix +
"1";
586 paramInfo.
unit = aUnit;
590 paramInfos.push_back( paramInfo );
592 paramInfo.
name = aPrefix +
"2";
594 paramInfo.
unit = aUnit;
598 paramInfos.push_back( paramInfo );
600 paramInfo.
name =
"td1";
602 paramInfo.
unit =
"s";
606 paramInfos.push_back( paramInfo );
608 paramInfo.
name =
"tau1";
610 paramInfo.
unit =
"s";
614 paramInfos.push_back( paramInfo );
616 paramInfo.
name =
"td2";
618 paramInfo.
unit =
"s";
622 paramInfos.push_back( paramInfo );
624 paramInfo.
name =
"tau2";
626 paramInfo.
unit =
"s";
630 paramInfos.push_back( paramInfo );
639 const std::string& aUnit )
641 std::vector<PARAM::INFO> paramInfos;
644 paramInfo.
name =
"vo";
646 paramInfo.
unit = aUnit;
650 paramInfos.push_back( paramInfo );
652 paramInfo.
name =
"vmo";
654 paramInfo.
unit = aUnit;
657 paramInfo.
description =
"Modulation signal offset";
658 paramInfos.push_back( paramInfo );
660 paramInfo.
name =
"vma";
662 paramInfo.
unit = aUnit;
665 paramInfo.
description =
"Modulation signal amplitude";
666 paramInfos.push_back( paramInfo );
668 paramInfo.
name =
"fm";
670 paramInfo.
unit =
"Hz";
673 paramInfo.
description =
"Modulation signal frequency";
674 paramInfos.push_back( paramInfo );
676 paramInfo.
name =
"fc";
678 paramInfo.
unit =
"Hz";
681 paramInfo.
description =
"Carrier signal frequency";
682 paramInfos.push_back( paramInfo );
684 paramInfo.
name =
"td";
686 paramInfo.
unit =
"s";
690 paramInfos.push_back( paramInfo );
692 paramInfo.
name =
"phasem";
694 paramInfo.
unit =
"°";
698 paramInfos.push_back( paramInfo );
700 paramInfo.
name =
"phasec";
702 paramInfo.
unit =
"°";
706 paramInfos.push_back( paramInfo );
715 const std::string& aUnit )
717 std::vector<PARAM::INFO> paramInfos;
720 paramInfo.
name =
"vo";
722 paramInfo.
unit = aUnit;
726 paramInfos.push_back( paramInfo );
728 paramInfo.
name =
"va";
730 paramInfo.
unit = aUnit;
734 paramInfos.push_back( paramInfo );
736 paramInfo.
name =
"fm";
738 paramInfo.
unit =
"Hz";
742 paramInfos.push_back( paramInfo );
744 paramInfo.
name =
"mdi";
750 paramInfos.push_back( paramInfo );
752 paramInfo.
name =
"fc";
754 paramInfo.
unit =
"Hz";
758 paramInfos.push_back( paramInfo );
760 paramInfo.
name =
"phasem";
762 paramInfo.
unit =
"°";
766 paramInfos.push_back( paramInfo );
768 paramInfo.
name =
"phasec";
770 paramInfo.
unit =
"°";
774 paramInfos.push_back( paramInfo );
784 std::vector<PARAM::INFO> paramInfos;
787 paramInfo.
name =
"gain";
790 paramInfo.
unit = aGainUnit;
792 paramInfos.push_back( paramInfo );
794 paramInfo.
name =
"control";
798 paramInfo.
description =
"Controlling voltage source";
799 paramInfos.push_back( paramInfo );
807 std::vector<PARAM::INFO> paramInfos;
810 paramInfo.
name =
"gain";
813 paramInfo.
unit = aGainUnit;
815 paramInfos.push_back( paramInfo );
822 const std::string& aQuantity,
823 const std::string& aUnit )
825 std::vector<PARAM::INFO> paramInfos;
828 paramInfo.
name =
"pwl";
830 paramInfo.
unit =
"s," + aUnit;
833 paramInfo.
description = aUnit ==
"V" ?
"Time-voltage points" :
"Time-current points";
834 paramInfos.push_back( paramInfo );
897 const std::string& aUnit )
899 std::vector<PARAM::INFO> paramInfos;
902 paramInfo.
name =
"rms";
904 paramInfo.
unit = aUnit;
907 paramInfo.
description =
"White noise RMS amplitude";
908 paramInfos.push_back( paramInfo );
910 paramInfo.
name =
"dt";
912 paramInfo.
unit =
"s";
916 paramInfos.push_back( paramInfo );
925 const std::string& aUnit )
927 std::vector<PARAM::INFO> paramInfos;
930 paramInfo.
name =
"rms";
936 paramInfos.push_back( paramInfo );
938 paramInfo.
name =
"slope";
944 paramInfos.push_back( paramInfo );
946 paramInfo.
name =
"dt";
948 paramInfo.
unit =
"s";
952 paramInfos.push_back( paramInfo );
961 const std::string& aUnit )
963 std::vector<PARAM::INFO> paramInfos;
966 paramInfo.
name =
"ampl";
968 paramInfo.
unit = aUnit;
972 paramInfos.push_back( paramInfo );
974 paramInfo.
name =
"tcapt";
976 paramInfo.
unit =
"s";
979 paramInfo.
description =
"Burst noise trap capture time";
980 paramInfos.push_back( paramInfo );
982 paramInfo.
name =
"temit";
984 paramInfo.
unit =
"s";
987 paramInfo.
description =
"Burst noise trap emission time";
988 paramInfos.push_back( paramInfo );
997 const std::string& aUnit )
999 std::vector<PARAM::INFO> paramInfos;
1002 paramInfo.
name =
"ts";
1004 paramInfo.
unit =
"s";
1007 paramInfo.
description =
"Individual voltage duration";
1008 paramInfos.push_back( paramInfo );
1010 paramInfo.
name =
"td";
1012 paramInfo.
unit =
"s";
1016 paramInfos.push_back( paramInfo );
1018 paramInfo.
name =
"range";
1020 paramInfo.
unit = aUnit;
1024 paramInfos.push_back( paramInfo );
1026 paramInfo.
name =
"offset";
1028 paramInfo.
unit = aUnit;
1032 paramInfos.push_back( paramInfo );
1041 const std::string& aUnit )
1043 std::vector<PARAM::INFO> paramInfos;
1046 paramInfo.
name =
"ts";
1048 paramInfo.
unit =
"s";
1051 paramInfo.
description =
"Individual voltage duration";
1052 paramInfos.push_back( paramInfo );
1054 paramInfo.
name =
"td";
1056 paramInfo.
unit =
"s";
1060 paramInfos.push_back( paramInfo );
1062 paramInfo.
name =
"stddev";
1064 paramInfo.
unit = aUnit;
1068 paramInfos.push_back( paramInfo );
1070 paramInfo.
name =
"mean";
1072 paramInfo.
unit = aUnit;
1076 paramInfos.push_back( paramInfo );
1085 const std::string& aUnit )
1087 std::vector<PARAM::INFO> paramInfos;
1090 paramInfo.
name =
"ts";
1092 paramInfo.
unit =
"s";
1095 paramInfo.
description =
"Individual voltage duration";
1096 paramInfos.push_back( paramInfo );
1098 paramInfo.
name =
"td";
1100 paramInfo.
unit =
"s";
1104 paramInfos.push_back( paramInfo );
1106 paramInfo.
name =
"mean";
1108 paramInfo.
unit = aUnit;
1112 paramInfos.push_back( paramInfo );
1114 paramInfo.
name =
"offset";
1116 paramInfo.
unit = aUnit;
1120 paramInfos.push_back( paramInfo );
1129 const std::string& aUnit )
1131 std::vector<PARAM::INFO> paramInfos;
1134 paramInfo.
name =
"ts";
1136 paramInfo.
unit =
"s";
1139 paramInfo.
description =
"Individual voltage duration";
1140 paramInfos.push_back( paramInfo );
1142 paramInfo.
name =
"td";
1144 paramInfo.
unit =
"s";
1148 paramInfos.push_back( paramInfo );
1150 paramInfo.
name =
"lambda";
1152 paramInfo.
unit = aUnit;
1156 paramInfos.push_back( paramInfo );
1158 paramInfo.
name =
"offset";
1160 paramInfo.
unit = aUnit;
1164 paramInfos.push_back( paramInfo );
1175 paramInfo.
name =
"ac";
1177 paramInfo.
unit = aUnit;
1181 aParamInfos.push_back( paramInfo );
1183 paramInfo.
name =
"ph";
1185 paramInfo.
unit =
"°";
1189 aParamInfos.push_back( paramInfo );
1193 const std::string& aUnit )
1197 if( !strcmp( aUnit.c_str(),
"V" ) )
1199 paramInfo.
name =
"portnum";
1201 paramInfo.
unit =
"";
1205 aParamInfos.push_back( paramInfo );
1207 paramInfo.
name =
"z0";
1209 paramInfo.
unit =
"Ohm";
1213 aParamInfos.push_back( paramInfo );
1221 return {
"+",
"-",
"C+",
"C-" };
1223 return {
"+",
"-" };
1230 case SIM_MODEL::TYPE::V:
1231 case SIM_MODEL::TYPE::I:
return &
GetParam( 0 );
break;
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
virtual const PARAM & GetParam(unsigned aParamIndex) const
int GetParamCount() const
DEVICE_T GetDeviceType() const
const PARAM * FindParam(const std::string &aParamName) const
virtual void doSetParamValue(int aParamIndex, const std::string &aValue)
std::vector< PARAM > m_params
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
SPICE_INFO GetSpiceInfo() const
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)
std::vector< FAB_LAYER_COLOR > dummy