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
56private:
57 std::string getParamValueString( const std::string& aParamName,
58 const std::string& aDefaultValue ) const;
59};
60
61
63{
64public:
66};
67
68
70{
71public:
72 SIM_MODEL_SOURCE( TYPE aType );
73
74 bool HasAutofill() const override { return true; }
75 bool HasPrimaryValue() const override { return GetType() == TYPE::V || GetType() == TYPE::I; }
76
77 std::vector<std::string> GetPinNames() const override;
78
79protected:
80 void doSetParamValue( int aParamIndex, const std::string& aValue ) override;
81
82private:
83 static const std::vector<PARAM::INFO>& makeParamInfos( TYPE aType );
84
85 static std::vector<PARAM::INFO> makeDcParamInfos( const std::string& aPrefix,
86 const std::string& aUnit );
87 static std::vector<PARAM::INFO> makeSinParamInfos( const std::string& aPrefix,
88 const std::string& aUnit );
89 static std::vector<PARAM::INFO> makePulseParamInfos( const std::string& aPrefix,
90 const std::string& aUnit );
91 static std::vector<PARAM::INFO> makeExpParamInfos( const std::string& aPrefix,
92 const std::string& aUnit );
93 static std::vector<PARAM::INFO> makeAMParamInfos( const std::string& aPrefix,
94 const std::string& aUnit );
95 static std::vector<PARAM::INFO> makeSFFMParamInfos( const std::string& aPrefix,
96 const std::string& aUnit );
97 static std::vector<SIM_MODEL::PARAM::INFO> makeVcParamInfos( const std::string& aGainUnit );
98 static std::vector<SIM_MODEL::PARAM::INFO> makeCcParamInfos( const std::string& aGainUnit );
99 static std::vector<PARAM::INFO> makePwlParamInfos( const std::string& aPrefix,
100 const std::string& aQuantity,
101 const std::string& aUnit );
102 static std::vector<PARAM::INFO> makeWhiteNoiseParamInfos( const std::string& aPrefix,
103 const std::string& aUnit );
104 static std::vector<PARAM::INFO> makePinkNoiseParamInfos( const std::string& aPrefix,
105 const std::string& aUnit );
106 static std::vector<PARAM::INFO> makeBurstNoiseParamInfos( const std::string& aPrefix,
107 const std::string& aUnit );
108 static std::vector<PARAM::INFO> makeRandomUniformParamInfos( const std::string& aPrefix,
109 const std::string& aUnit );
110 static std::vector<PARAM::INFO> makeRandomNormalParamInfos( const std::string& aPrefix,
111 const std::string& aUnit );
112 static std::vector<PARAM::INFO> makeRandomExpParamInfos( const std::string& aPrefix,
113 const std::string& aUnit );
114 static std::vector<PARAM::INFO> makeRandomPoissonParamInfos( const std::string& aPrefix,
115 const std::string& aUnit );
116
117 static void appendAcParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit );
118 static void appendSpParamInfos( std::vector<PARAM::INFO>& aParamInfos, const std::string& aUnit );
119
120};
121
122#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
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:465
std::string ModelLine(const SPICE_ITEM &aItem) const override
std::string ItemLine(const SPICE_ITEM &aItem) 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:53