2022-02-21 03:58:31 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 Mikolaj Wielgus
|
2022-12-08 23:56:55 +00:00
|
|
|
* Copyright (C) 2022 CERN
|
2023-02-22 09:10:06 +00:00
|
|
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-02-21 03:58:31 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 3
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SIM_MODEL_H
|
|
|
|
#define SIM_MODEL_H
|
|
|
|
|
|
|
|
#include <wx/string.h>
|
2022-03-09 01:40:59 +00:00
|
|
|
#include <map>
|
2022-08-30 07:00:52 +00:00
|
|
|
#include <utility>
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2023-01-02 22:47:46 +00:00
|
|
|
#include <reporter.h>
|
2022-07-31 08:32:00 +00:00
|
|
|
#include <sch_field.h>
|
|
|
|
#include <lib_field.h>
|
|
|
|
|
|
|
|
// Must be included after sch_field.h (exactly eda_shape.h) to avoid a colliding
|
|
|
|
// declaration with a window header (under msys2)
|
|
|
|
#include <sim/sim_value.h>
|
|
|
|
#include <enum_vector.h>
|
|
|
|
|
2022-04-01 04:30:50 +00:00
|
|
|
class SIM_LIBRARY;
|
2023-02-28 16:47:56 +00:00
|
|
|
struct SPICE_ITEM;
|
2022-09-15 03:25:57 +00:00
|
|
|
class SPICE_GENERATOR;
|
2022-12-21 00:38:52 +00:00
|
|
|
class SIM_MODEL_SERIALIZER;
|
2022-12-14 13:00:25 +00:00
|
|
|
class PROJECT;
|
2022-04-01 04:30:50 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2023-01-05 14:16:06 +00:00
|
|
|
#define SIM_REFERENCE_FIELD wxT( "Reference" )
|
|
|
|
#define SIM_VALUE_FIELD wxT( "Value" )
|
|
|
|
|
|
|
|
#define SIM_DEVICE_TYPE_FIELD wxT( "Sim.Device" )
|
|
|
|
#define SIM_TYPE_FIELD wxT( "Sim.Type" )
|
|
|
|
#define SIM_PINS_FIELD wxT( "Sim.Pins" )
|
|
|
|
#define SIM_PARAMS_FIELD wxT( "Sim.Params" )
|
|
|
|
#define SIM_ENABLE_FIELD wxT( "Sim.Enable" )
|
|
|
|
#define SIM_LIBRARY_FIELD wxT( "Sim.Library" )
|
|
|
|
#define SIM_NAME_FIELD wxT( "Sim.Name" )
|
|
|
|
|
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
class SIM_MODEL
|
|
|
|
{
|
|
|
|
public:
|
2022-09-15 03:25:57 +00:00
|
|
|
friend class SPICE_GENERATOR;
|
2022-09-27 20:47:00 +00:00
|
|
|
friend class NETLIST_EXPORTER_SPICE;
|
2022-09-15 03:25:57 +00:00
|
|
|
|
2022-09-14 07:19:25 +00:00
|
|
|
struct PIN;
|
|
|
|
struct PARAM;
|
|
|
|
|
2022-06-21 02:22:52 +00:00
|
|
|
// There's a trailing '_' because `DEVICE_TYPE` collides with something in Windows headers.
|
2022-12-06 14:59:49 +00:00
|
|
|
DEFINE_ENUM_CLASS_WITH_ITERATOR( DEVICE_T,
|
2022-02-21 03:58:31 +00:00
|
|
|
NONE,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
R,
|
|
|
|
C,
|
|
|
|
L,
|
2022-02-21 03:58:31 +00:00
|
|
|
TLINE,
|
2022-04-12 14:37:06 +00:00
|
|
|
SW,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
D,
|
2022-02-21 03:58:31 +00:00
|
|
|
NPN,
|
|
|
|
PNP,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
NJFET,
|
|
|
|
PJFET,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
NMES,
|
|
|
|
PMES,
|
2022-04-12 14:37:06 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
NMOS,
|
|
|
|
PMOS,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
V,
|
|
|
|
I,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
SUBCKT,
|
|
|
|
XSPICE,
|
2022-09-30 12:29:44 +00:00
|
|
|
|
|
|
|
KIBIS,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
SPICE
|
2022-02-21 03:58:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
struct DEVICE_INFO
|
|
|
|
{
|
2022-09-22 05:38:45 +00:00
|
|
|
std::string fieldValue;
|
|
|
|
std::string description;
|
2022-11-20 21:06:21 +00:00
|
|
|
bool isBuiltin;
|
2022-02-21 03:58:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_ENUM_CLASS_WITH_ITERATOR( TYPE,
|
|
|
|
NONE,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
R,
|
2022-10-22 02:33:26 +00:00
|
|
|
R_POT,
|
2022-04-12 14:37:06 +00:00
|
|
|
R_BEHAVIORAL,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
C,
|
|
|
|
C_BEHAVIORAL,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
L,
|
2022-09-11 17:00:09 +00:00
|
|
|
L_MUTUAL,
|
2022-04-12 14:37:06 +00:00
|
|
|
L_BEHAVIORAL,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-05-31 02:55:48 +00:00
|
|
|
TLINE_Z0,
|
|
|
|
TLINE_RLGC,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
SW_V,
|
|
|
|
SW_I,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
D,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
NPN_VBIC,
|
|
|
|
PNP_VBIC,
|
2022-11-29 09:10:33 +00:00
|
|
|
NPN_GUMMELPOON,
|
|
|
|
PNP_GUMMELPOON,
|
2022-02-21 03:58:31 +00:00
|
|
|
//NPN_MEXTRAM,
|
|
|
|
//PNP_MEXTRAM,
|
2022-06-21 02:22:52 +00:00
|
|
|
NPN_HICUM2,
|
|
|
|
PNP_HICUM2,
|
2022-02-21 03:58:31 +00:00
|
|
|
//NPN_HICUM_L0,
|
|
|
|
//PNP_HICUM_L0,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
NJFET_SHICHMANHODGES,
|
|
|
|
PJFET_SHICHMANHODGES,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
NJFET_PARKERSKELLERN,
|
|
|
|
PJFET_PARKERSKELLERN,
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
NMES_STATZ,
|
|
|
|
PMES_STATZ,
|
|
|
|
|
|
|
|
NMES_YTTERDAL,
|
|
|
|
PMES_YTTERDAL,
|
|
|
|
|
|
|
|
NMES_HFET1,
|
|
|
|
PMES_HFET1,
|
|
|
|
|
|
|
|
NMES_HFET2,
|
|
|
|
PMES_HFET2,
|
|
|
|
|
|
|
|
|
2022-11-28 03:45:00 +00:00
|
|
|
NMOS_VDMOS,
|
|
|
|
PMOS_VDMOS,
|
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
NMOS_MOS1,
|
|
|
|
PMOS_MOS1,
|
|
|
|
|
|
|
|
NMOS_MOS2,
|
|
|
|
PMOS_MOS2,
|
|
|
|
|
|
|
|
NMOS_MOS3,
|
|
|
|
PMOS_MOS3,
|
|
|
|
|
|
|
|
NMOS_BSIM1,
|
|
|
|
PMOS_BSIM1,
|
|
|
|
|
|
|
|
NMOS_BSIM2,
|
|
|
|
PMOS_BSIM2,
|
|
|
|
|
|
|
|
NMOS_MOS6,
|
|
|
|
PMOS_MOS6,
|
|
|
|
|
|
|
|
NMOS_MOS9,
|
|
|
|
PMOS_MOS9,
|
|
|
|
|
|
|
|
NMOS_BSIM3,
|
|
|
|
PMOS_BSIM3,
|
|
|
|
|
|
|
|
NMOS_B4SOI,
|
|
|
|
PMOS_B4SOI,
|
|
|
|
|
|
|
|
NMOS_BSIM4,
|
|
|
|
PMOS_BSIM4,
|
|
|
|
|
|
|
|
//NMOS_EKV2_6,
|
|
|
|
//PMOS_EKV2_6,
|
|
|
|
|
|
|
|
//NMOS_PSP,
|
|
|
|
//PMOS_PSP,
|
|
|
|
|
|
|
|
NMOS_B3SOIFD,
|
|
|
|
PMOS_B3SOIFD,
|
|
|
|
|
|
|
|
NMOS_B3SOIDD,
|
|
|
|
PMOS_B3SOIDD,
|
|
|
|
|
|
|
|
NMOS_B3SOIPD,
|
|
|
|
PMOS_B3SOIPD,
|
|
|
|
|
|
|
|
//NMOS_STAG,
|
|
|
|
//PMOS_STAG,
|
|
|
|
|
|
|
|
NMOS_HISIM2,
|
|
|
|
PMOS_HISIM2,
|
|
|
|
|
2022-04-12 14:37:06 +00:00
|
|
|
NMOS_HISIMHV1,
|
|
|
|
PMOS_HISIMHV1,
|
|
|
|
|
|
|
|
NMOS_HISIMHV2,
|
|
|
|
PMOS_HISIMHV2,
|
|
|
|
|
|
|
|
|
2022-06-21 02:22:52 +00:00
|
|
|
V,
|
2022-04-12 14:37:06 +00:00
|
|
|
V_SIN,
|
|
|
|
V_PULSE,
|
|
|
|
V_EXP,
|
2022-06-12 03:39:13 +00:00
|
|
|
/*V_SFAM,
|
|
|
|
V_SFFM,*/
|
2022-04-12 14:37:06 +00:00
|
|
|
V_PWL,
|
|
|
|
V_WHITENOISE,
|
|
|
|
V_PINKNOISE,
|
|
|
|
V_BURSTNOISE,
|
|
|
|
V_RANDUNIFORM,
|
|
|
|
V_RANDNORMAL,
|
|
|
|
V_RANDEXP,
|
2022-06-21 02:22:52 +00:00
|
|
|
//V_RANDPOISSON,
|
2022-04-12 14:37:06 +00:00
|
|
|
V_BEHAVIORAL,
|
|
|
|
|
2022-06-21 02:22:52 +00:00
|
|
|
I,
|
2022-04-12 14:37:06 +00:00
|
|
|
I_SIN,
|
|
|
|
I_PULSE,
|
|
|
|
I_EXP,
|
2022-06-12 03:39:13 +00:00
|
|
|
/*I_SFAM,
|
|
|
|
I_SFFM,*/
|
2022-04-12 14:37:06 +00:00
|
|
|
I_PWL,
|
|
|
|
I_WHITENOISE,
|
|
|
|
I_PINKNOISE,
|
|
|
|
I_BURSTNOISE,
|
|
|
|
I_RANDUNIFORM,
|
|
|
|
I_RANDNORMAL,
|
|
|
|
I_RANDEXP,
|
2022-06-21 02:22:52 +00:00
|
|
|
//I_RANDPOISSON,
|
2022-04-12 14:37:06 +00:00
|
|
|
I_BEHAVIORAL,
|
|
|
|
|
2022-09-30 12:29:44 +00:00
|
|
|
SUBCKT,
|
|
|
|
XSPICE,
|
|
|
|
|
2022-09-27 20:47:00 +00:00
|
|
|
KIBIS_DEVICE,
|
2022-09-30 12:29:44 +00:00
|
|
|
KIBIS_DRIVER_DC,
|
|
|
|
KIBIS_DRIVER_RECT,
|
|
|
|
KIBIS_DRIVER_PRBS,
|
2022-04-12 14:37:06 +00:00
|
|
|
|
2022-09-18 19:22:59 +00:00
|
|
|
RAWSPICE
|
2022-02-21 03:58:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
struct INFO
|
|
|
|
{
|
2022-12-06 14:59:49 +00:00
|
|
|
DEVICE_T deviceType;
|
2022-09-22 05:38:45 +00:00
|
|
|
std::string fieldValue;
|
|
|
|
std::string description;
|
2022-02-21 03:58:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-04-01 04:30:50 +00:00
|
|
|
struct SPICE_INFO
|
|
|
|
{
|
2022-09-22 05:38:45 +00:00
|
|
|
std::string itemType;
|
|
|
|
std::string modelType = "";
|
|
|
|
std::string inlineTypeString = "";
|
|
|
|
std::string level = "";
|
2023-02-22 09:48:32 +00:00
|
|
|
bool isDefaultLevel = false;
|
|
|
|
bool hasExpression = false;
|
2022-09-22 05:38:45 +00:00
|
|
|
std::string version = "";
|
2022-04-01 04:30:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-03-09 01:40:59 +00:00
|
|
|
struct PIN
|
|
|
|
{
|
2022-09-22 05:38:45 +00:00
|
|
|
const std::string name;
|
2023-02-22 09:48:32 +00:00
|
|
|
std::string symbolPinNumber;
|
2022-08-22 05:40:23 +00:00
|
|
|
|
|
|
|
static constexpr auto NOT_CONNECTED = -1;
|
2022-03-09 01:40:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
struct PARAM
|
|
|
|
{
|
2022-06-21 02:22:52 +00:00
|
|
|
// MS Windows compilers complain about the names IN and OUT, so we prefix them.
|
|
|
|
enum DIR
|
2022-02-21 03:58:31 +00:00
|
|
|
{
|
2022-06-21 02:22:52 +00:00
|
|
|
DIR_IN,
|
|
|
|
DIR_OUT,
|
|
|
|
DIR_INOUT
|
2022-02-21 03:58:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class CATEGORY
|
|
|
|
{
|
|
|
|
PRINCIPAL,
|
2022-06-21 02:22:52 +00:00
|
|
|
GEOMETRY,
|
2022-06-12 03:39:13 +00:00
|
|
|
AC,
|
2022-02-21 03:58:31 +00:00
|
|
|
DC,
|
|
|
|
CAPACITANCE,
|
|
|
|
TEMPERATURE,
|
|
|
|
NOISE,
|
|
|
|
DISTRIBUTED_QUANTITIES,
|
|
|
|
LIMITING_VALUES,
|
|
|
|
ADVANCED,
|
|
|
|
FLAGS,
|
2022-09-27 20:47:00 +00:00
|
|
|
WAVEFORM,
|
2022-02-21 03:58:31 +00:00
|
|
|
INITIAL_CONDITIONS,
|
|
|
|
SUPERFLUOUS
|
|
|
|
};
|
|
|
|
|
|
|
|
struct INFO
|
|
|
|
{
|
2023-02-22 09:48:32 +00:00
|
|
|
INFO( const std::string& aName = "",
|
|
|
|
unsigned aId = 0,
|
|
|
|
DIR aDir = DIR_INOUT,
|
|
|
|
SIM_VALUE::TYPE aType = SIM_VALUE::TYPE_FLOAT,
|
|
|
|
const std::string& aUnit = "",
|
|
|
|
CATEGORY aCategory = CATEGORY::PRINCIPAL,
|
|
|
|
const std::string& aDefaultValue = "",
|
|
|
|
const std::string& legacy_unused_value = "",
|
|
|
|
const std::string& aDescription = "",
|
|
|
|
bool aIsSpiceInstanceParam = false,
|
|
|
|
bool aIsInstanceParam = false,
|
|
|
|
const std::string& aSpiceModelName = "",
|
|
|
|
const std::string& aSpiceInstanceName = "",
|
2022-09-22 05:38:45 +00:00
|
|
|
std::vector<std::string> aEnumValues = {} ) :
|
2022-08-02 12:43:03 +00:00
|
|
|
name( aName ),
|
|
|
|
id( aId ),
|
|
|
|
dir( aDir ),
|
|
|
|
type( aType ),
|
|
|
|
unit( aUnit ),
|
|
|
|
category( aCategory ),
|
|
|
|
defaultValue( aDefaultValue ),
|
|
|
|
description( aDescription ),
|
|
|
|
isSpiceInstanceParam( aIsSpiceInstanceParam ),
|
|
|
|
isInstanceParam( aIsInstanceParam ),
|
2022-08-30 07:00:52 +00:00
|
|
|
spiceModelName( aSpiceModelName ),
|
|
|
|
spiceInstanceName( aSpiceInstanceName ),
|
|
|
|
enumValues( std::move( aEnumValues ) )
|
2023-02-22 09:48:32 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
unsigned id;
|
|
|
|
DIR dir;
|
|
|
|
SIM_VALUE::TYPE type;
|
|
|
|
std::string unit;
|
|
|
|
CATEGORY category;
|
|
|
|
std::string defaultValue;
|
|
|
|
std::string description;
|
|
|
|
bool isSpiceInstanceParam;
|
|
|
|
bool isInstanceParam;
|
|
|
|
std::string spiceModelName;
|
|
|
|
std::string spiceInstanceName;
|
|
|
|
std::vector<std::string> enumValues;
|
2022-02-21 03:58:31 +00:00
|
|
|
};
|
|
|
|
|
2023-02-22 09:10:06 +00:00
|
|
|
std::string value;
|
|
|
|
const INFO& info;
|
2022-07-31 08:32:00 +00:00
|
|
|
|
2023-02-22 09:10:06 +00:00
|
|
|
PARAM( const INFO& aInfo ) :
|
|
|
|
info( aInfo )
|
2022-02-21 03:58:31 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-12-06 14:59:49 +00:00
|
|
|
static DEVICE_INFO DeviceInfo( DEVICE_T aDeviceType );
|
2022-02-21 03:58:31 +00:00
|
|
|
static INFO TypeInfo( TYPE aType );
|
2022-04-01 04:30:50 +00:00
|
|
|
static SPICE_INFO SpiceInfo( TYPE aType );
|
|
|
|
|
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
template <typename T>
|
2022-12-09 20:58:47 +00:00
|
|
|
static TYPE ReadTypeFromFields( const std::vector<T>& aFields );
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-05-08 09:54:35 +00:00
|
|
|
template <typename T>
|
|
|
|
static TYPE InferTypeFromLegacyFields( const std::vector<T>& aFields );
|
|
|
|
|
2022-12-05 02:07:45 +00:00
|
|
|
|
2023-01-02 22:47:46 +00:00
|
|
|
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, const std::vector<LIB_PIN*>& aPins,
|
|
|
|
REPORTER* aReporter );
|
2022-12-17 15:21:35 +00:00
|
|
|
|
2023-01-03 15:29:45 +00:00
|
|
|
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
|
2023-01-02 22:47:46 +00:00
|
|
|
const std::vector<LIB_PIN*>& aPins,
|
|
|
|
REPORTER* aReporter );
|
2022-04-12 14:37:06 +00:00
|
|
|
|
|
|
|
template <typename T>
|
2023-01-03 15:29:45 +00:00
|
|
|
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
|
2022-12-17 15:21:35 +00:00
|
|
|
const std::vector<LIB_PIN*>& aPins,
|
2023-01-02 22:47:46 +00:00
|
|
|
const std::vector<T>& aFields,
|
|
|
|
REPORTER* aReporter );
|
2022-04-01 04:30:50 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
template <typename T>
|
2022-12-17 15:21:35 +00:00
|
|
|
static std::unique_ptr<SIM_MODEL> Create( const std::vector<T>& aFields,
|
2023-01-02 22:47:46 +00:00
|
|
|
const std::vector<LIB_PIN*>& aPins,
|
2023-01-03 15:29:45 +00:00
|
|
|
bool aResolved, REPORTER* aReporter );
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-04-01 04:30:50 +00:00
|
|
|
template <typename T>
|
2023-01-05 14:16:06 +00:00
|
|
|
static std::string GetFieldValue( const std::vector<T>* aFields, const wxString& aFieldName,
|
2022-12-19 18:10:57 +00:00
|
|
|
bool aResolve = true );
|
2022-04-01 04:30:50 +00:00
|
|
|
|
|
|
|
template <typename T>
|
2023-01-05 14:16:06 +00:00
|
|
|
static void SetFieldValue( std::vector<T>& aFields, const wxString& aFieldName,
|
2022-09-22 05:38:45 +00:00
|
|
|
const std::string& aValue );
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-09-14 07:19:25 +00:00
|
|
|
const SPICE_GENERATOR& SpiceGenerator() const { return *m_spiceGenerator; }
|
2022-12-21 00:38:52 +00:00
|
|
|
const SIM_MODEL_SERIALIZER& Serializer() const { return *m_serializer; }
|
2022-09-14 07:19:25 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
// Move semantics.
|
|
|
|
// Rule of five.
|
2022-09-15 03:25:57 +00:00
|
|
|
virtual ~SIM_MODEL(); // = default in implementation file.
|
2022-02-21 03:58:31 +00:00
|
|
|
SIM_MODEL() = delete;
|
|
|
|
SIM_MODEL( const SIM_MODEL& aOther ) = delete;
|
|
|
|
SIM_MODEL( SIM_MODEL&& aOther ) = default;
|
2022-04-01 04:30:50 +00:00
|
|
|
SIM_MODEL& operator=(SIM_MODEL&& aOther ) = delete;
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-12-17 15:21:35 +00:00
|
|
|
template <typename T>
|
|
|
|
void ReadDataFields( const std::vector<T>* aFields, const std::vector<LIB_PIN*>& aPins );
|
2022-02-21 03:58:31 +00:00
|
|
|
|
|
|
|
template <typename T>
|
2022-05-08 09:54:35 +00:00
|
|
|
void WriteFields( std::vector<T>& aFields ) const;
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-05-31 02:55:48 +00:00
|
|
|
SPICE_INFO GetSpiceInfo() const { return SpiceInfo( GetType() ); }
|
2022-04-12 14:37:06 +00:00
|
|
|
|
|
|
|
void AddPin( const PIN& aPin );
|
2022-11-25 04:31:03 +00:00
|
|
|
void ClearPins();
|
2022-10-25 09:45:40 +00:00
|
|
|
|
2022-09-22 05:38:45 +00:00
|
|
|
int FindModelPinIndex( const std::string& aSymbolPinNumber );
|
2023-02-21 19:55:47 +00:00
|
|
|
void AddParam( const PARAM::INFO& aInfo );
|
2022-04-01 04:30:50 +00:00
|
|
|
|
2022-11-20 21:06:21 +00:00
|
|
|
DEVICE_INFO GetDeviceInfo() const { return DeviceInfo( GetDeviceType() ); }
|
2022-05-31 02:55:48 +00:00
|
|
|
INFO GetTypeInfo() const { return TypeInfo( GetType() ); }
|
|
|
|
|
2022-12-06 14:59:49 +00:00
|
|
|
DEVICE_T GetDeviceType() const { return GetTypeInfo().deviceType; }
|
2022-04-01 04:30:50 +00:00
|
|
|
TYPE GetType() const { return m_type; }
|
|
|
|
|
2022-09-30 12:29:44 +00:00
|
|
|
const SIM_MODEL* GetBaseModel() const { return m_baseModel; }
|
2023-02-04 20:55:52 +00:00
|
|
|
virtual void SetBaseModel( const SIM_MODEL& aBaseModel );
|
2022-04-01 04:30:50 +00:00
|
|
|
|
2023-01-19 12:14:29 +00:00
|
|
|
virtual std::vector<std::string> GetPinNames() const { return {}; }
|
|
|
|
|
2022-08-22 05:40:23 +00:00
|
|
|
int GetPinCount() const { return static_cast<int>( m_pins.size() ); }
|
2022-05-08 09:54:35 +00:00
|
|
|
const PIN& GetPin( unsigned aIndex ) const { return m_pins.at( aIndex ); }
|
|
|
|
|
|
|
|
std::vector<std::reference_wrapper<const PIN>> GetPins() const;
|
2022-04-01 04:30:50 +00:00
|
|
|
|
2022-11-25 04:31:03 +00:00
|
|
|
void SetPinSymbolPinNumber( int aPinIndex, const std::string& aSymbolPinNumber );
|
2022-12-22 20:21:10 +00:00
|
|
|
virtual void SetPinSymbolPinNumber( const std::string& aPinName,
|
|
|
|
const std::string& aSymbolPinNumber );
|
2022-03-09 01:40:59 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-08-22 05:40:23 +00:00
|
|
|
int GetParamCount() const { return static_cast<int>( m_params.size() ); }
|
2022-09-29 08:35:01 +00:00
|
|
|
virtual const PARAM& GetParam( unsigned aParamIndex ) const; // Return base parameter unless it's overridden.
|
2022-05-08 09:54:35 +00:00
|
|
|
|
2022-10-24 01:11:52 +00:00
|
|
|
virtual const PARAM* GetTunerParam() const { return nullptr; }
|
|
|
|
|
2022-09-22 05:38:45 +00:00
|
|
|
const PARAM* FindParam( const std::string& aParamName ) const;
|
2022-05-31 02:55:48 +00:00
|
|
|
|
2022-05-08 09:54:35 +00:00
|
|
|
std::vector<std::reference_wrapper<const PARAM>> GetParams() const;
|
|
|
|
|
2022-12-14 13:00:25 +00:00
|
|
|
const PARAM& GetParamOverride( unsigned aParamIndex ) const; // Return the actual parameter.
|
2022-05-08 09:54:35 +00:00
|
|
|
const PARAM& GetBaseParam( unsigned aParamIndex ) const; // Always return base parameter if it exists.
|
2022-06-21 02:22:52 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-10-12 02:26:16 +00:00
|
|
|
void SetParamValue( int aParamIndex, const std::string& aValue,
|
2022-10-04 15:17:41 +00:00
|
|
|
SIM_VALUE::NOTATION aNotation = SIM_VALUE::NOTATION::SI );
|
2022-10-12 02:26:16 +00:00
|
|
|
void SetParamValue( const std::string& aParamName, const std::string& aValue,
|
2022-10-04 15:17:41 +00:00
|
|
|
SIM_VALUE::NOTATION aNotation = SIM_VALUE::NOTATION::SI );
|
2022-06-21 02:22:52 +00:00
|
|
|
|
2022-04-01 04:30:50 +00:00
|
|
|
// Can modifying a model parameter also modify other parameters?
|
|
|
|
virtual bool HasAutofill() const { return false; }
|
2022-11-11 02:07:34 +00:00
|
|
|
virtual bool HasPrimaryValue() const { return false; }
|
|
|
|
|
2022-06-21 02:22:52 +00:00
|
|
|
void SetIsEnabled( bool aIsEnabled ) { m_isEnabled = aIsEnabled; }
|
|
|
|
bool IsEnabled() const { return m_isEnabled; }
|
2022-05-08 09:54:35 +00:00
|
|
|
|
2022-11-22 00:46:02 +00:00
|
|
|
void SetIsStoredInValue( bool aIsStoredInValue )
|
|
|
|
{
|
|
|
|
if( HasPrimaryValue() )
|
|
|
|
m_isStoredInValue = aIsStoredInValue;
|
|
|
|
}
|
2022-11-18 07:37:58 +00:00
|
|
|
bool IsStoredInValue() const { return m_isStoredInValue; }
|
2022-10-16 03:10:57 +00:00
|
|
|
|
2022-12-17 15:21:35 +00:00
|
|
|
virtual void SwitchSingleEndedDiff( bool aDiff ) { };
|
|
|
|
|
2022-12-18 22:53:53 +00:00
|
|
|
template <class T_symbol, class T_field>
|
2022-12-19 18:10:57 +00:00
|
|
|
static bool InferSimModel( T_symbol& aSymbol, std::vector<T_field>* aFields, bool aResolve,
|
2022-12-18 22:53:53 +00:00
|
|
|
SIM_VALUE_GRAMMAR::NOTATION aNotation, wxString* aDeviceType,
|
|
|
|
wxString* aModelType, wxString* aModelParams, wxString* aPinMap );
|
2022-12-09 15:09:34 +00:00
|
|
|
|
2022-12-08 23:56:55 +00:00
|
|
|
template <class T_symbol, class T_field>
|
2022-12-14 13:00:25 +00:00
|
|
|
static void MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject );
|
2022-12-08 23:56:55 +00:00
|
|
|
|
2022-04-01 04:30:50 +00:00
|
|
|
protected:
|
2022-11-07 18:33:31 +00:00
|
|
|
static std::unique_ptr<SIM_MODEL> Create( TYPE aType );
|
2022-09-18 19:22:59 +00:00
|
|
|
|
2022-09-15 03:25:57 +00:00
|
|
|
SIM_MODEL( TYPE aType );
|
2022-12-09 20:58:47 +00:00
|
|
|
SIM_MODEL( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator );
|
|
|
|
SIM_MODEL( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator,
|
2022-12-21 00:38:52 +00:00
|
|
|
std::unique_ptr<SIM_MODEL_SERIALIZER> aSerializer );
|
2022-02-21 03:58:31 +00:00
|
|
|
|
2022-12-22 20:21:10 +00:00
|
|
|
void createPins( const std::vector<LIB_PIN*>& aSymbolPins );
|
2022-08-11 00:42:16 +00:00
|
|
|
|
2022-12-20 23:49:11 +00:00
|
|
|
virtual int doFindParam( const std::string& aParamName ) const;
|
2023-02-22 09:10:06 +00:00
|
|
|
virtual void doSetParamValue( int aParamIndex, const std::string& aValue );
|
2022-12-20 23:49:11 +00:00
|
|
|
|
2022-02-21 03:58:31 +00:00
|
|
|
private:
|
2022-12-17 15:21:35 +00:00
|
|
|
template <typename T>
|
|
|
|
void doReadDataFields( const std::vector<T>* aFields, const std::vector<LIB_PIN*>& aPins );
|
|
|
|
|
2022-03-09 01:40:59 +00:00
|
|
|
template <typename T>
|
2022-05-08 09:54:35 +00:00
|
|
|
void doWriteFields( std::vector<T>& aFields ) const;
|
2022-03-09 01:40:59 +00:00
|
|
|
|
2023-02-25 15:21:08 +00:00
|
|
|
virtual bool requiresSpiceModelLine( const SPICE_ITEM& aItem ) const;
|
2022-05-31 02:55:48 +00:00
|
|
|
|
2022-12-09 20:58:47 +00:00
|
|
|
protected:
|
2022-12-21 00:38:52 +00:00
|
|
|
std::vector<PARAM> m_params;
|
2022-12-22 20:21:10 +00:00
|
|
|
std::vector<PIN> m_pins;
|
2022-12-21 00:38:52 +00:00
|
|
|
const SIM_MODEL* m_baseModel;
|
|
|
|
std::unique_ptr<SIM_MODEL_SERIALIZER> m_serializer;
|
2022-04-12 14:37:06 +00:00
|
|
|
|
2022-12-09 20:58:47 +00:00
|
|
|
private:
|
2022-12-21 00:38:52 +00:00
|
|
|
std::unique_ptr<SPICE_GENERATOR> m_spiceGenerator;
|
2022-04-12 14:37:06 +00:00
|
|
|
|
2022-12-21 00:38:52 +00:00
|
|
|
const TYPE m_type;
|
|
|
|
bool m_isEnabled;
|
|
|
|
bool m_isStoredInValue;
|
2022-02-21 03:58:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SIM_MODEL_H
|