KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_ngspice.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 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SIM_MODEL_NGSPICE_H
22#define SIM_MODEL_NGSPICE_H
23
24#include <sim/sim_model_spice.h>
25#include <sim/spice_generator.h>
26
27
29{
30public:
31 using SPICE_GENERATOR_SPICE::SPICE_GENERATOR_SPICE;
32
33 std::vector<std::string> CurrentNames( const SPICE_ITEM& aItem ) const override;
34};
35
36
38{
39public:
41
42
43 SIM_MODEL_NGSPICE( TYPE aType );
44
45 void SetParamFromSpiceCode( const std::string& aParamName, const std::string& aValue,
46 SIM_VALUE_GRAMMAR::NOTATION aNotation ) override;
47
48 std::vector<std::string> GetPinNames() const override;
49
50 // Protected because it's accessed by QA tests.
51protected:
53 NONE,
54 //RESISTOR,
55 //CAPACITOR,
56 //INDUCTOR,
57 //LTRA,
58 //TRANLINE,
59 //URC,
60 //TRANSLINE,
61 //SWITCH,
62 //CSWITCH,
63 DIODE,
64 BJT,
65 VBIC,
66 HICUM2,
67 JFET,
68 JFET2,
69 MES,
70 MESA,
71 HFET1,
72 HFET2,
73 VDMOS,
74 MOS1,
75 MOS2,
76 MOS3,
77 BSIM1,
78 BSIM2,
79 MOS6,
80 BSIM3,
81 MOS9,
82 B4SOI,
83 BSIM4,
84 B3SOIFD,
85 B3SOIDD,
86 B3SOIPD,
87 HISIM2,
88 HISIMHV1,
89 HISIMHV2
90 )
91
92 struct MODEL_INFO
93 {
94 std::string name;
95 std::string variant1;
96 std::string variant2;
97 std::vector<std::string> pinNames;
98 std::string description;
99 std::vector<SIM_MODEL::PARAM::INFO> modelParams;
100 std::vector<SIM_MODEL::PARAM::INFO> instanceParams;
101 };
102
103 static const MODEL_INFO& ModelInfo( MODEL_TYPE aType );
104
105 int doFindParam( const std::string& aParamName ) const override;
106
107private:
108 bool canSilentlyIgnoreParam( const std::string& aParamName );
109
110 MODEL_TYPE getModelType() const;
111};
112
113
115{
116 using MODEL_TYPE = SIM_MODEL_NGSPICE::MODEL_TYPE;
117 using MODEL_INFO = SIM_MODEL_NGSPICE::MODEL_INFO;
118
119 std::unordered_map<MODEL_TYPE, MODEL_INFO> modelInfos;
120
122
123private:
124 void addBJT();
125 void addBSIM1();
126 void addBSIM2();
127 void addBSIM3();
128 void addBSIM4();
129 void addB3SOI();
130 void addB4SOI();
131 void addDIODE();
132 void addHFET();
133 void addHICUM2();
134 void addHSIM();
135 void addJFET();
136 void addMES();
137 void addMOS();
138 void addMOS6();
139 void addMOS9();
140 void addVBIC();
141};
142
143#endif /* SIM_MODEL_NGSPICE_H */
const char * name
bool canSilentlyIgnoreParam(const std::string &aParamName)
static const MODEL_INFO & ModelInfo(MODEL_TYPE aType)
std::vector< std::string > GetPinNames() const override
MODEL_TYPE getModelType() const
void SetParamFromSpiceCode(const std::string &aParamName, const std::string &aValue, SIM_VALUE_GRAMMAR::NOTATION aNotation) override
int doFindParam(const std::string &aParamName) const override
SIM_MODEL_NGSPICE(TYPE aType)
DEFINE_ENUM_CLASS_WITH_ITERATOR(MODEL_TYPE, NONE, DIODE, BJT, VBIC, HICUM2, JFET, JFET2, MES, MESA, HFET1, HFET2, VDMOS, MOS1, MOS2, MOS3, BSIM1, BSIM2, MOS6, BSIM3, MOS9, B4SOI, BSIM4, B3SOIFD, B3SOIDD, B3SOIPD, HISIM2, HISIMHV1, HISIMHV2) struct MODEL_INFO
friend struct NGSPICE_MODEL_INFO_MAP
SIM_MODEL_SPICE(TYPE aType, std::unique_ptr< SPICE_GENERATOR > aSpiceGenerator)
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
@ NONE
Definition eda_shape.h:72
SIM_MODEL::TYPE TYPE
Definition sim_model.cpp:54
std::unordered_map< MODEL_TYPE, MODEL_INFO > modelInfos
SIM_MODEL_NGSPICE::MODEL_TYPE MODEL_TYPE
SIM_MODEL_NGSPICE::MODEL_INFO MODEL_INFO