KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_model_multiunit.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SIM_MODEL_MULTIUNIT_H
21#define SIM_MODEL_MULTIUNIT_H
22
23#include <utility>
24#include <vector>
25#include <wx/string.h>
26
27#include <sim/sim_model_spice.h>
28#include <sim/spice_generator.h>
29
30
39{
40 int unit = 0;
41 std::vector<std::pair<wxString, wxString>> pins; // symbolPinNumber -> modelPinName
42};
43
44
58{
59 enum class MODE
60 {
63 };
64
66 std::vector<wxString> sharedModelPins; // model-pin names common to all instances
67
68 static SIM_DECOMPOSITION Parse( const wxString& aField );
69 wxString Format() const;
70};
71
72
83std::vector<std::pair<wxString, wxString>> ParseSimPinsTokens( const wxString& aPins,
84 const wxString& aRef );
85
86
88
89
98{
99public:
101
102 std::string ModelName( const SPICE_ITEM& aItem ) const override;
103 std::string ModelLine( const SPICE_ITEM& aItem ) const override;
104 std::vector<std::string> CurrentNames( const SPICE_ITEM& aItem ) const override;
105
106private:
107 const SIM_MODEL_MULTIUNIT& multiunit() const;
108};
109
110
124{
125public:
127
137 SIM_MODEL_MULTIUNIT( const SIM_MODEL& aBaseModel, const wxString& aBaseModelName,
138 const std::vector<UNIT_PIN_MAP>& aUnitMaps,
139 const std::vector<wxString>& aSharedModelPins );
140
141 const wxString& GetSignature() const { return m_signature; }
142 int GetInstanceCount() const { return static_cast<int>( m_instances.size() ); }
143
144private:
145 struct INSTANCE
146 {
147 int unit = 0;
148 std::vector<wxString> nodes;
149 };
150
151 wxString computeSignature() const;
152
154 wxString m_signature;
155 std::vector<INSTANCE> m_instances;
156};
157
158#endif // SIM_MODEL_MULTIUNIT_H
Wraps a resolved single-unit base model and presents it as one component-level SPICE device.
wxString m_baseModelName
name referenced by each inner instance line
std::vector< INSTANCE > m_instances
wxString m_signature
content-derived wrapper subckt name
wxString computeSignature() const
friend class SPICE_GENERATOR_MULTIUNIT
SIM_MODEL_MULTIUNIT(const SIM_MODEL &aBaseModel, const wxString &aBaseModelName, const std::vector< UNIT_PIN_MAP > &aUnitMaps, const std::vector< wxString > &aSharedModelPins)
const wxString & GetSignature() const
SIM_MODEL_SPICE(TYPE aType, std::unique_ptr< SPICE_GENERATOR > aSpiceGenerator)
SIM_MODEL()=delete
SPICE generator for the synthesized repeat-per-unit wrapper.
const SIM_MODEL_MULTIUNIT & multiunit() const
std::string ModelLine(const SPICE_ITEM &aItem) const override
SPICE_GENERATOR(const SIM_MODEL &aModel)
std::string ModelName(const SPICE_ITEM &aItem) const override
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
SPICE_GENERATOR(const SIM_MODEL &aModel)
std::vector< std::pair< wxString, wxString > > ParseSimPinsTokens(const wxString &aPins, const wxString &aRef)
Parse one unit's Sim.Pins text into (symbolPinNumber -> modelPinName) pairs, preserving the written o...
Per-component decomposition descriptor stored in the Sim.Decomposition field.
static SIM_DECOMPOSITION Parse(const wxString &aField)
std::vector< wxString > sharedModelPins
wxString Format() const
std::vector< wxString > nodes
one node per base-model pin, in base order
One functional unit's pin map, gathered from its Sim.Pins field.
std::vector< std::pair< wxString, wxString > > pins