KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_source.h
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 (C) 2022 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
25#ifndef SIM_MODEL_SOURCE_H
26#define SIM_MODEL_SOURCE_H
27
28#include <sim/sim_model.h>
30#include <sim/spice_generator.h>
31
32
34{
35 using namespace SIM_MODEL_SERIALIZER_GRAMMAR;
36
37 struct pwlSep : plus<space> {};
38 struct pwlValues : seq<opt<number<SIM_VALUE::TYPE_FLOAT, NOTATION::SI>>,
39 star<pwlSep,
40 number<SIM_VALUE::TYPE_FLOAT, NOTATION::SI>>> {};
41 struct pwlValuesGrammar : must<opt<sep>,
42 pwlValues,
43 opt<sep>,
44 tao::pegtl::eof> {};
45}
46
47
49{
50public:
52
53 std::string ModelLine( const SPICE_ITEM& aItem ) const override;
54 std::string ItemLine( const SPICE_ITEM& aItem ) const override;
55
56 std::string TunerCommand( const SPICE_ITEM& aItem, double aValue ) const override;
57
58private:
59 std::string getParamValueString( const std::string& aParamName,
60 const std::string& aDefaultValue ) const;
61};
62
63
65{
66public:
68};
69
70
72{
73public:
74 SIM_MODEL_SOURCE( TYPE aType );
75
76 bool HasAutofill() const override { return true; }
77 bool HasPrimaryValue() const override { return GetType() == TYPE::V || GetType() == TYPE::I; }
78
79 std::vector<std::string> GetPinNames() const override;
80
81 const PARAM* GetTunerParam() const override;
82
83protected:
84 void doSetParamValue( int aParamIndex, const std::string& aValue ) override;
85
86private:
87 static const std::vector<PARAM::INFO>& makeParamInfos( TYPE aType );
88
89 static std::vector<PARAM::INFO> makeDcParamInfos( const std::string& aPrefix,
90 const std::string& aUnit );
91 static std::vector<PARAM::INFO> makeSinParamInfos( const std::string& aPrefix,
92 const std::string& aUnit );
93 static std::vector<PARAM::INFO> makePulseParamInfos( const std::string& aPrefix,
94 const std::string& aUnit );
95 static std::vector<PARAM::INFO> makeExpParamInfos( const std::string& aPrefix,
96 const std::string& aUnit );
97 static std::vector<PARAM::INFO> makeAMParamInfos( const std::string& aPrefix,
98 const std::string& aUnit );
99 static std::vector<PARAM::INFO> makeSFFMParamInfos( const std::string& aPrefix,
100 const std::string& aUnit );
101 static std::vector<SIM_MODEL::PARAM::INFO> makeVcParamInfos( const std::string& aGainUnit );
102 static std::vector<SIM_MODEL::PARAM::INFO> makeCcParamInfos( const std::string& aGainUnit );
103 static std::vector<PARAM::INFO> makePwlParamInfos( const std::string& aPrefix,
104 const std::string& aQuantity,
105 const std::string& aUnit );
106 static std::vector<PARAM::INFO> makeWhiteNoiseParamInfos( const std::string& aPrefix,
107 const std::string& aUnit );
108 static std::vector<PARAM::INFO> makePinkNoiseParamInfos( const std::string& aPrefix,
109 const std::string& aUnit );
110 static std::vector<PARAM::INFO> makeBurstNoiseParamInfos( const std::string& aPrefix,
111 const std::string& aUnit );
112 static std::vector<PARAM::INFO> makeRandomUniformParamInfos( const std::string& aPrefix,
113 const std::string& aUnit );
114 static std::vector<PARAM::INFO> makeRandomNormalParamInfos( const std::string& aPrefix,
115 const std::string& aUnit );
116 static std::vector<PARAM::INFO> makeRandomExpParamInfos( const std::string& aPrefix,
117 const std::string& aUnit );
118 static std::vector<PARAM::INFO> makeRandomPoissonParamInfos( const std::string& aPrefix,
119 const std::string& aUnit );
120
121 static void appendAcParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit );
122 static void appendSpParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit );
123
124};
125
126#endif // SIM_MODEL_SOURCE_H
Serializes/deserializes a SIM_MODEL for storage in LIB_FIELDs/SCH_FIELDs.
SIM_MODEL_SERIALIZER(SIM_MODEL &aModel)
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
bool HasAutofill() 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)
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)
bool HasPrimaryValue() const override
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)
TYPE GetType() const
Definition: sim_model.h:464
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
SPICE_GENERATOR(const SIM_MODEL &aModel)
SIM_MODEL::TYPE TYPE
Definition: sim_model.cpp:57