Sim: Improvements to model serialization
Don't serialize parameters in certain models for default values. Infer models from Value field for some kinds of models. Resolve synonyms when loading models from Spice libraries.
This commit is contained in:
parent
6450ec6b85
commit
fe38c622a9
|
@ -327,6 +327,7 @@ if( KICAD_SPICE )
|
||||||
sim/sim_model_xspice.cpp
|
sim/sim_model_xspice.cpp
|
||||||
sim/sim_model_ideal.cpp
|
sim/sim_model_ideal.cpp
|
||||||
sim/sim_model_ngspice.cpp
|
sim/sim_model_ngspice.cpp
|
||||||
|
sim/sim_model_passive.cpp
|
||||||
sim/sim_model_spice.cpp
|
sim/sim_model_spice.cpp
|
||||||
sim/sim_model_source.cpp
|
sim/sim_model_source.cpp
|
||||||
sim/sim_model_subckt.cpp
|
sim/sim_model_subckt.cpp
|
||||||
|
|
|
@ -221,6 +221,9 @@ void DIALOG_SIM_MODEL<T>::updateModelParamsTab()
|
||||||
m_firstCategory = m_paramGrid->Append( new wxPropertyCategory( "DC" ) );
|
m_firstCategory = m_paramGrid->Append( new wxPropertyCategory( "DC" ) );
|
||||||
m_paramGrid->HideProperty( "DC" );
|
m_paramGrid->HideProperty( "DC" );
|
||||||
|
|
||||||
|
m_paramGrid->Append( new wxPropertyCategory( "Capacitance" ) );
|
||||||
|
m_paramGrid->HideProperty( "Capacitance" );
|
||||||
|
|
||||||
m_paramGrid->Append( new wxPropertyCategory( "Temperature" ) );
|
m_paramGrid->Append( new wxPropertyCategory( "Temperature" ) );
|
||||||
m_paramGrid->HideProperty( "Temperature" );
|
m_paramGrid->HideProperty( "Temperature" );
|
||||||
|
|
||||||
|
@ -242,7 +245,7 @@ void DIALOG_SIM_MODEL<T>::updateModelParamsTab()
|
||||||
m_paramGrid->Append( new wxPropertyCategory( "Flags" ) );
|
m_paramGrid->Append( new wxPropertyCategory( "Flags" ) );
|
||||||
m_paramGrid->HideProperty( "Flags" );
|
m_paramGrid->HideProperty( "Flags" );
|
||||||
|
|
||||||
for( int i = 0; i < curModel().GetParamCount(); ++i )
|
for( unsigned i = 0; i < curModel().GetParamCount(); ++i )
|
||||||
addParamPropertyIfRelevant( i );
|
addParamPropertyIfRelevant( i );
|
||||||
|
|
||||||
m_paramGrid->CollapseAll();
|
m_paramGrid->CollapseAll();
|
||||||
|
@ -309,9 +312,9 @@ void DIALOG_SIM_MODEL<T>::updatePinAssignmentsTab()
|
||||||
"Not Connected" );
|
"Not Connected" );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < curModel().GetPinCount(); ++i )
|
for( unsigned i = 0; i < curModel().GetPinCount(); ++i )
|
||||||
{
|
{
|
||||||
int symbolPinNumber = curModel().GetPin( i ).symbolPinNumber;
|
unsigned symbolPinNumber = curModel().GetPin( i ).symbolPinNumber;
|
||||||
|
|
||||||
if( symbolPinNumber == SIM_MODEL::PIN::NOT_CONNECTED )
|
if( symbolPinNumber == SIM_MODEL::PIN::NOT_CONNECTED )
|
||||||
continue;
|
continue;
|
||||||
|
@ -319,7 +322,7 @@ void DIALOG_SIM_MODEL<T>::updatePinAssignmentsTab()
|
||||||
wxString modelPinString = getModelPinString( i + 1 );
|
wxString modelPinString = getModelPinString( i + 1 );
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
|
|
||||||
m_pinAssignmentsGrid->SetCellValue( symbolPinNumber - 1,
|
m_pinAssignmentsGrid->SetCellValue( static_cast<int>( symbolPinNumber - 1 ),
|
||||||
static_cast<int>( PIN_COLUMN::MODEL ),
|
static_cast<int>( PIN_COLUMN::MODEL ),
|
||||||
modelPinString );
|
modelPinString );
|
||||||
}
|
}
|
||||||
|
@ -337,7 +340,7 @@ void DIALOG_SIM_MODEL<T>::updatePinAssignmentsGridEditors()
|
||||||
wxString modelPinChoicesString = "";
|
wxString modelPinChoicesString = "";
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
|
|
||||||
for( int i = 0; i < curModel().GetPinCount(); ++i )
|
for( unsigned i = 0; i < curModel().GetPinCount(); ++i )
|
||||||
{
|
{
|
||||||
const SIM_MODEL::PIN& modelPin = curModel().GetPin( i );
|
const SIM_MODEL::PIN& modelPin = curModel().GetPin( i );
|
||||||
int modelPinNumber = static_cast<int>( i + 1 );
|
int modelPinNumber = static_cast<int>( i + 1 );
|
||||||
|
@ -386,7 +389,15 @@ void DIALOG_SIM_MODEL<T>::updatePinAssignmentsGridEditors()
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath )
|
void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath )
|
||||||
{
|
{
|
||||||
m_library->ReadFile( Prj().AbsolutePath( aFilePath ) );
|
const wxString absolutePath = Prj().AbsolutePath( aFilePath );
|
||||||
|
|
||||||
|
if( !m_library->ReadFile( Prj().AbsolutePath( aFilePath ) ) )
|
||||||
|
{
|
||||||
|
DisplayErrorMessage( this, wxString::Format( _( "Error loading model library '%s'" ),
|
||||||
|
Prj().AbsolutePath( aFilePath ), aFilePath ),
|
||||||
|
m_library->GetErrorMessage() );
|
||||||
|
}
|
||||||
|
|
||||||
m_libraryPathInput->SetValue( aFilePath );
|
m_libraryPathInput->SetValue( aFilePath );
|
||||||
|
|
||||||
m_libraryModels.clear();
|
m_libraryModels.clear();
|
||||||
|
@ -482,6 +493,12 @@ wxPGProperty* DIALOG_SIM_MODEL<T>::newParamProperty( int aParamIndex ) const
|
||||||
|
|
||||||
switch( param.info.type )
|
switch( param.info.type )
|
||||||
{
|
{
|
||||||
|
case TYPE::BOOL:
|
||||||
|
// TODO.
|
||||||
|
prop = new wxBoolProperty( paramDescription, param.info.name );
|
||||||
|
prop->SetAttribute( wxPG_BOOL_USE_CHECKBOX, true );
|
||||||
|
break;
|
||||||
|
|
||||||
case TYPE::INT:
|
case TYPE::INT:
|
||||||
prop = new SIM_PROPERTY( paramDescription, param.info.name, m_library, curModelSharedPtr(),
|
prop = new SIM_PROPERTY( paramDescription, param.info.name, m_library, curModelSharedPtr(),
|
||||||
aParamIndex, SIM_VALUE::TYPE::INT );
|
aParamIndex, SIM_VALUE::TYPE::INT );
|
||||||
|
@ -492,9 +509,12 @@ wxPGProperty* DIALOG_SIM_MODEL<T>::newParamProperty( int aParamIndex ) const
|
||||||
aParamIndex, SIM_VALUE::TYPE::FLOAT );
|
aParamIndex, SIM_VALUE::TYPE::FLOAT );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE::BOOL:
|
//case TYPE::COMPLEX:
|
||||||
prop = new wxBoolProperty( paramDescription, param.info.name );
|
// break;
|
||||||
prop->SetAttribute( wxPG_BOOL_USE_CHECKBOX, true );
|
|
||||||
|
case TYPE::STRING:
|
||||||
|
prop = new SIM_PROPERTY( paramDescription, param.info.name, m_library, curModelSharedPtr(),
|
||||||
|
aParamIndex, SIM_VALUE::TYPE::STRING );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "netlist_exporter_spice.h"
|
#include "netlist_exporter_spice.h"
|
||||||
#include <pegtl.hpp>
|
#include <pegtl.hpp>
|
||||||
#include <pegtl/contrib/parse_tree.hpp>
|
#include <pegtl/contrib/parse_tree.hpp>
|
||||||
|
#include <sim/sim_model_spice.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
|
@ -175,7 +176,7 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives()
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( text.ToStdString()+"\n", "from_content" );
|
tao::pegtl::string_input<> in( text.ToStdString() + "\n", "from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -209,12 +210,20 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives()
|
||||||
void NETLIST_EXPORTER_SPICE::readLibraryField( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem )
|
void NETLIST_EXPORTER_SPICE::readLibraryField( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem )
|
||||||
{
|
{
|
||||||
SCH_FIELD* field = aSymbol.FindField( SIM_LIBRARY::LIBRARY_FIELD );
|
SCH_FIELD* field = aSymbol.FindField( SIM_LIBRARY::LIBRARY_FIELD );
|
||||||
|
wxString path;
|
||||||
|
|
||||||
if( !field )
|
if( field )
|
||||||
|
path = field->GetShownText();
|
||||||
|
else if( auto model = dynamic_cast<const SIM_MODEL_SPICE*>( aItem.model.get() ) )
|
||||||
|
{
|
||||||
|
// Special case for legacy models.
|
||||||
|
int libParamIndex = static_cast<int>( SIM_MODEL_SPICE::SPICE_PARAM::LIB );
|
||||||
|
path = model->GetParam( libParamIndex ).value->ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( path.IsEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString path = field->GetShownText();
|
|
||||||
|
|
||||||
if( auto library = SIM_LIBRARY::Create( m_schematic->Prj().AbsolutePath( path ) ) )
|
if( auto library = SIM_LIBRARY::Create( m_schematic->Prj().AbsolutePath( path ) ) )
|
||||||
m_libraries.try_emplace( path, std::move( library ) );
|
m_libraries.try_emplace( path, std::move( library ) );
|
||||||
|
|
||||||
|
@ -239,7 +248,7 @@ void NETLIST_EXPORTER_SPICE::readNameField( SCH_SYMBOL& aSymbol, SPICE_ITEM& aIt
|
||||||
if( baseModel )
|
if( baseModel )
|
||||||
{
|
{
|
||||||
aItem.model = SIM_MODEL::Create( *baseModel,
|
aItem.model = SIM_MODEL::Create( *baseModel,
|
||||||
static_cast<int>( m_sortedSymbolPinList.size() ),
|
m_sortedSymbolPinList.size(),
|
||||||
aSymbol.GetFields() );
|
aSymbol.GetFields() );
|
||||||
aItem.modelName = modelName;
|
aItem.modelName = modelName;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -52,9 +52,9 @@ class NGSPICE : public SPICE_SIMULATOR
|
||||||
public:
|
public:
|
||||||
DEFINE_ENUM_CLASS_WITH_ITERATOR( MODEL_TYPE,
|
DEFINE_ENUM_CLASS_WITH_ITERATOR( MODEL_TYPE,
|
||||||
NONE,
|
NONE,
|
||||||
RESISTOR,
|
//RESISTOR,
|
||||||
CAPACITOR,
|
//CAPACITOR,
|
||||||
INDUCTOR,
|
//INDUCTOR,
|
||||||
LTRA,
|
LTRA,
|
||||||
TRANLINE,
|
TRANLINE,
|
||||||
URC,
|
URC,
|
||||||
|
|
|
@ -99,12 +99,12 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
static MODEL_INFO model = {};
|
static MODEL_INFO model = {};
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
case MODEL_TYPE::RESISTOR:
|
/*case MODEL_TYPE::RESISTOR:
|
||||||
{
|
{
|
||||||
static MODEL_INFO model = { "Resistor", "R", "", { "+", "-" }, "Simple linear resistor",
|
static MODEL_INFO model = { "Resistor", "R", "", { "+", "-" }, "Simple linear resistor",
|
||||||
// Model parameters
|
// Model parameters
|
||||||
{
|
{
|
||||||
{ "rsh", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "ohm/m", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Sheet resistance" },
|
{ "rsh", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "ohm/m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Sheet resistance" },
|
||||||
{ "narrow", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Z(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Narrowing of resistor" },
|
{ "narrow", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Z(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Narrowing of resistor" },
|
||||||
{ "dw", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, ZR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Narrowing of resistor" },
|
{ "dw", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, ZR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Narrowing of resistor" },
|
||||||
{ "short", 109, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Z(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Shortening of resistor" },
|
{ "short", 109, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Z(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Shortening of resistor" },
|
||||||
|
@ -117,15 +117,15 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
{ "defw", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device width" },
|
{ "defw", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device width" },
|
||||||
{ "w", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device width" },
|
{ "w", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device width" },
|
||||||
{ "l", 105, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device length" },
|
{ "l", 105, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default device length" },
|
||||||
{ "kf", 110, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "", SIM_MODEL::PARAM::CATEGORY::NOISE, "0", "", "Flicker noise coefficient" },
|
{ "kf", 110, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Flicker noise coefficient" },
|
||||||
{ "af", 111, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "", SIM_MODEL::PARAM::CATEGORY::NOISE, "0", "", "Flicker noise exponent" },
|
{ "af", 111, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, Q(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Flicker noise exponent" },
|
||||||
{ "tnom", 108, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
{ "tnom", 108, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
||||||
{ "r", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "ohm", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Resistor model default value" },
|
{ "r", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "ohm", SIM_MODEL::PARAM::CATEGORY::PRINCIPAL, "0", "", "Resistor model default value" },
|
||||||
{ "res", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, R(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "n.a." },
|
{ "res", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, R(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "n.a." },
|
||||||
{ "bv_max", 112, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "V", SIM_MODEL::PARAM::CATEGORY::LIMITING_VALUES, "1e+99", "", "maximum voltage over resistor" },
|
{ "bv_max", 112, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "V", SIM_MODEL::PARAM::CATEGORY::LIMITING_VALUES, "1e+99", "", "maximum voltage over resistor" },
|
||||||
{ "lf", 113, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::NOISE, "1", "", "noise area length exponent" },
|
{ "lf", 113, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1", "", "noise area length exponent" },
|
||||||
{ "wf", 114, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::NOISE, "1", "", "noise area width exponent" },
|
{ "wf", 114, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1", "", "noise area width exponent" },
|
||||||
{ "ef", 115, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::NOISE, "1", "", "noise frequency exponent" },
|
{ "ef", 115, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1", "", "noise frequency exponent" },
|
||||||
},
|
},
|
||||||
// Instance parameters
|
// Instance parameters
|
||||||
{
|
{
|
||||||
|
@ -162,10 +162,10 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
static MODEL_INFO model = { "Capacitor", "C", "", { "+", "-" }, "Fixed capacitor",
|
static MODEL_INFO model = { "Capacitor", "C", "", { "+", "-" }, "Fixed capacitor",
|
||||||
// Model parameters
|
// Model parameters
|
||||||
{
|
{
|
||||||
{ "cap", 113, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Model capacitance" },
|
{ "cap", 113, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F", SIM_MODEL::PARAM::CATEGORY::PRINCIPAL, "0", "", "Model capacitance" },
|
||||||
{ "cj", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Bottom Capacitance per area" },
|
{ "cj", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Bottom Capacitance per area" },
|
||||||
{ "cox", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, AR(), "F", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Bottom Capacitance per area" },
|
{ "cox", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, AR(), "F", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Bottom Capacitance per area" },
|
||||||
{ "cjsw", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F/m", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Sidewall capacitance per meter" },
|
{ "cjsw", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "F/m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Sidewall capacitance per meter" },
|
||||||
{ "capsw", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, AR(), "F/m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Sidewall capacitance per meter" },
|
{ "capsw", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, AR(), "F/m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Sidewall capacitance per meter" },
|
||||||
{ "defw", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default width" },
|
{ "defw", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, X(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default width" },
|
||||||
{ "w", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default width" },
|
{ "w", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XR(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "1e-05", "", "Default width" },
|
||||||
|
@ -178,7 +178,7 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
{ "tc2", 109, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C^2", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "Second order temp. coefficient" },
|
{ "tc2", 109, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C^2", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "Second order temp. coefficient" },
|
||||||
{ "tnom", 110, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
{ "tnom", 110, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
||||||
{ "di", 111, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Relative dielectric constant" },
|
{ "di", 111, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Relative dielectric constant" },
|
||||||
{ "thick", 112, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "m", SIM_MODEL::PARAM::CATEGORY::GEOMETRY, "0", "", "Insulator thickness" },
|
{ "thick", 112, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Insulator thickness" },
|
||||||
{ "bv_max", 115, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "F", SIM_MODEL::PARAM::CATEGORY::LIMITING_VALUES, "1e+99", "", "maximum voltage over capacitance" },
|
{ "bv_max", 115, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, {}, "F", SIM_MODEL::PARAM::CATEGORY::LIMITING_VALUES, "1e+99", "", "maximum voltage over capacitance" },
|
||||||
{ "c", 104, SIM_MODEL::PARAM::DIR::IN, SIM_VALUE::TYPE::BOOL, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "Capacitor model" },
|
{ "c", 104, SIM_MODEL::PARAM::DIR::IN, SIM_VALUE::TYPE::BOOL, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "Capacitor model" },
|
||||||
},
|
},
|
||||||
|
@ -214,14 +214,14 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
static MODEL_INFO model = { "Inductor", "L", "", { "+", "-" }, "Fixed inductor",
|
static MODEL_INFO model = { "Inductor", "L", "", { "+", "-" }, "Fixed inductor",
|
||||||
// Model parameters
|
// Model parameters
|
||||||
{
|
{
|
||||||
{ "ind", 100, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "H", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Model inductance" },
|
{ "ind", 100, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "H", SIM_MODEL::PARAM::CATEGORY::PRINCIPAL, "0", "", "Model inductance" },
|
||||||
{ "tc1", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "First order temp. coefficient" },
|
{ "tc1", 101, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "First order temp. coefficient" },
|
||||||
{ "tc2", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C^2", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "Second order temp. coefficient" },
|
{ "tc2", 102, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "ohm/deg C^2", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "0", "", "Second order temp. coefficient" },
|
||||||
{ "tnom", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
{ "tnom", 103, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, XU(), "deg C", SIM_MODEL::PARAM::CATEGORY::TEMPERATURE, "27", "", "Parameter measurement temperature" },
|
||||||
{ "csect", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::GEOMETRY, "0", "", "Inductor cross section" },
|
{ "csect", 104, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Inductor cross section" },
|
||||||
{ "length", 105, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "m", SIM_MODEL::PARAM::CATEGORY::GEOMETRY, "0", "", "Inductor length" },
|
{ "length", 105, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "m", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Inductor length" },
|
||||||
{ "nt", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::GEOMETRY, "0", "", "Model number of turns" },
|
{ "nt", 106, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Model number of turns" },
|
||||||
{ "mu", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::DISTRIBUTED_QUANTITIES, "0", "", "Relative magnetic permeability" },
|
{ "mu", 107, SIM_MODEL::PARAM::DIR::INOUT, SIM_VALUE::TYPE::FLOAT, A(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "0", "", "Relative magnetic permeability" },
|
||||||
{ "l", 108, SIM_MODEL::PARAM::DIR::IN, SIM_VALUE::TYPE::BOOL, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "Inductor model" },
|
{ "l", 108, SIM_MODEL::PARAM::DIR::IN, SIM_VALUE::TYPE::BOOL, {}, "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "Inductor model" },
|
||||||
},
|
},
|
||||||
// Instance parameters
|
// Instance parameters
|
||||||
|
@ -248,7 +248,7 @@ const NGSPICE::MODEL_INFO& NGSPICE::ModelInfo( MODEL_TYPE aType )
|
||||||
{ "sens_cplx", 205, SIM_MODEL::PARAM::DIR::OUT, SIM_VALUE::TYPE::COMPLEX, U(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "ac sensitivity" },
|
{ "sens_cplx", 205, SIM_MODEL::PARAM::DIR::OUT, SIM_VALUE::TYPE::COMPLEX, U(), "", SIM_MODEL::PARAM::CATEGORY::SUPERFLUOUS, "", "", "ac sensitivity" },
|
||||||
} };
|
} };
|
||||||
return model;
|
return model;
|
||||||
}
|
}*/
|
||||||
case MODEL_TYPE::LTRA:
|
case MODEL_TYPE::LTRA:
|
||||||
{
|
{
|
||||||
static MODEL_INFO model = { "LTRA", "LTRA", "", { "1+", "1-", "2+", "2-" }, "Lossy transmission line",
|
static MODEL_INFO model = { "LTRA", "LTRA", "", { "1+", "1-", "2+", "2-" }, "Lossy transmission line",
|
||||||
|
|
|
@ -23,14 +23,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include <sim/sim_model.h>
|
#include <sim/sim_model.h>
|
||||||
#include <sim/sim_model_ideal.h>
|
|
||||||
#include <sim/sim_model_behavioral.h>
|
#include <sim/sim_model_behavioral.h>
|
||||||
|
#include <sim/sim_model_ideal.h>
|
||||||
|
#include <sim/sim_model_ngspice.h>
|
||||||
|
#include <sim/sim_model_passive.h>
|
||||||
#include <sim/sim_model_source.h>
|
#include <sim/sim_model_source.h>
|
||||||
|
#include <sim/sim_model_spice.h>
|
||||||
#include <sim/sim_model_subckt.h>
|
#include <sim/sim_model_subckt.h>
|
||||||
#include <sim/sim_model_xspice.h>
|
#include <sim/sim_model_xspice.h>
|
||||||
#include <sim/sim_model_spice.h>
|
|
||||||
#include <sim/sim_model_ngspice.h>
|
|
||||||
#include <pegtl.hpp>
|
#include <pegtl.hpp>
|
||||||
#include <pegtl/contrib/parse_tree.hpp>
|
#include <pegtl/contrib/parse_tree.hpp>
|
||||||
#include <locale_io.h>
|
#include <locale_io.h>
|
||||||
|
@ -45,17 +48,15 @@ namespace SIM_MODEL_PARSER
|
||||||
using namespace SIM_MODEL_GRAMMAR;
|
using namespace SIM_MODEL_GRAMMAR;
|
||||||
|
|
||||||
|
|
||||||
template <typename Rule> struct paramValuePairsSelector : std::false_type {};
|
template <typename Rule> struct fieldParamValuePairsSelector : std::false_type {};
|
||||||
|
|
||||||
template <> struct paramValuePairsSelector<param> : std::true_type {};
|
template <> struct fieldParamValuePairsSelector<param> : std::true_type {};
|
||||||
template <> struct paramValuePairsSelector<number<SIM_VALUE::TYPE::INT, NOTATION::SI>>
|
template <> struct fieldParamValuePairsSelector<number<SIM_VALUE::TYPE::INT, NOTATION::SI>>
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
template <> struct paramValuePairsSelector<number<SIM_VALUE::TYPE::FLOAT, NOTATION::SI>>
|
template <> struct fieldParamValuePairsSelector<number<SIM_VALUE::TYPE::FLOAT, NOTATION::SI>>
|
||||||
: std::true_type {};
|
|
||||||
template <> struct paramValuePairsSelector<number<SIM_VALUE::TYPE::INT, NOTATION::SPICE>>
|
|
||||||
: std::true_type {};
|
|
||||||
template <> struct paramValuePairsSelector<number<SIM_VALUE::TYPE::FLOAT, NOTATION::SPICE>>
|
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
template <> struct fieldParamValuePairsSelector<unquotedString> : std::true_type {};
|
||||||
|
template <> struct fieldParamValuePairsSelector<quotedString> : std::true_type {};
|
||||||
|
|
||||||
|
|
||||||
template <typename Rule> struct spiceUnitSelector : std::false_type {};
|
template <typename Rule> struct spiceUnitSelector : std::false_type {};
|
||||||
|
@ -140,7 +141,7 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType )
|
||||||
case TYPE::SW_V: return { DEVICE_TYPE::SW, "V", "Voltage-controlled" };
|
case TYPE::SW_V: return { DEVICE_TYPE::SW, "V", "Voltage-controlled" };
|
||||||
case TYPE::SW_I: return { DEVICE_TYPE::SW, "I", "Current-controlled" };
|
case TYPE::SW_I: return { DEVICE_TYPE::SW, "I", "Current-controlled" };
|
||||||
|
|
||||||
case TYPE::D: return { DEVICE_TYPE::D, "", "" };
|
case TYPE::D: return { DEVICE_TYPE::D, "", "" };
|
||||||
|
|
||||||
case TYPE::NPN_GUMMELPOON: return { DEVICE_TYPE::NPN, "GUMMELPOON", "Gummel-Poon" };
|
case TYPE::NPN_GUMMELPOON: return { DEVICE_TYPE::NPN, "GUMMELPOON", "Gummel-Poon" };
|
||||||
case TYPE::PNP_GUMMELPOON: return { DEVICE_TYPE::PNP, "GUMMELPOON", "Gummel-Poon" };
|
case TYPE::PNP_GUMMELPOON: return { DEVICE_TYPE::PNP, "GUMMELPOON", "Gummel-Poon" };
|
||||||
|
@ -253,18 +254,18 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
||||||
switch( aType )
|
switch( aType )
|
||||||
{
|
{
|
||||||
case TYPE::R: return { "R", "" };
|
case TYPE::R: return { "R", "" };
|
||||||
case TYPE::R_ADV: return { "R", "R" };
|
case TYPE::R_ADV: return { "R", "r" };
|
||||||
case TYPE::R_BEHAVIORAL: return { "R", "", "", 0, true };
|
case TYPE::R_BEHAVIORAL: return { "R", "", "", 0, true };
|
||||||
|
|
||||||
case TYPE::C: return { "C", "" };
|
case TYPE::C: return { "C", "" };
|
||||||
case TYPE::C_ADV: return { "C", "C", };
|
case TYPE::C_ADV: return { "C", "c", };
|
||||||
case TYPE::C_BEHAVIORAL: return { "C", "", "", 0, true };
|
case TYPE::C_BEHAVIORAL: return { "C", "", "", 0, true };
|
||||||
|
|
||||||
case TYPE::L: return { "L", "" };
|
case TYPE::L: return { "L", "" };
|
||||||
case TYPE::L_ADV: return { "L", "L" };
|
case TYPE::L_ADV: return { "L", "l" };
|
||||||
case TYPE::L_BEHAVIORAL: return { "L", "", "", 0, true };
|
case TYPE::L_BEHAVIORAL: return { "L", "", "", 0, true };
|
||||||
|
|
||||||
case TYPE::TLINE_LOSSY: return { "O", "LTRA" };
|
case TYPE::TLINE_LOSSY: return { "O", "ltra" };
|
||||||
case TYPE::TLINE_LOSSLESS: return { "T" };
|
case TYPE::TLINE_LOSSLESS: return { "T" };
|
||||||
case TYPE::TLINE_URC: return { "U" };
|
case TYPE::TLINE_URC: return { "U" };
|
||||||
case TYPE::TLINE_KSPICE: return { "Y" };
|
case TYPE::TLINE_KSPICE: return { "Y" };
|
||||||
|
@ -272,69 +273,69 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
||||||
case TYPE::SW_V: return { "S", "switch" };
|
case TYPE::SW_V: return { "S", "switch" };
|
||||||
case TYPE::SW_I: return { "W", "cswitch" };
|
case TYPE::SW_I: return { "W", "cswitch" };
|
||||||
|
|
||||||
case TYPE::D: return { "D", "D" };
|
case TYPE::D: return { "D", "d" };
|
||||||
|
|
||||||
case TYPE::NPN_GUMMELPOON: return { "Q", "NPN", "", 1 };
|
case TYPE::NPN_GUMMELPOON: return { "Q", "npn", "", 1 };
|
||||||
case TYPE::PNP_GUMMELPOON: return { "Q", "PNP", "", 1 };
|
case TYPE::PNP_GUMMELPOON: return { "Q", "pnp", "", 1 };
|
||||||
|
|
||||||
case TYPE::NPN_VBIC: return { "Q", "NPN", "", 4 };
|
case TYPE::NPN_VBIC: return { "Q", "npn", "", 4 };
|
||||||
case TYPE::PNP_VBIC: return { "Q", "PNP", "", 4 };
|
case TYPE::PNP_VBIC: return { "Q", "pnp", "", 4 };
|
||||||
|
|
||||||
case TYPE::NPN_HICUML2: return { "Q", "NPN", "", 8 };
|
case TYPE::NPN_HICUML2: return { "Q", "npn", "", 8 };
|
||||||
case TYPE::PNP_HICUML2: return { "Q", "PNP", "", 8 };
|
case TYPE::PNP_HICUML2: return { "Q", "pnp", "", 8 };
|
||||||
|
|
||||||
case TYPE::NJFET_SHICHMANHODGES: return { "M", "NJF", "", 1 };
|
case TYPE::NJFET_SHICHMANHODGES: return { "M", "njf", "", 1 };
|
||||||
case TYPE::PJFET_SHICHMANHODGES: return { "M", "PJF", "", 1 };
|
case TYPE::PJFET_SHICHMANHODGES: return { "M", "pjf", "", 1 };
|
||||||
case TYPE::NJFET_PARKERSKELLERN: return { "M", "NJF", "", 2 };
|
case TYPE::NJFET_PARKERSKELLERN: return { "M", "njf", "", 2 };
|
||||||
case TYPE::PJFET_PARKERSKELLERN: return { "M", "PJF", "", 2 };
|
case TYPE::PJFET_PARKERSKELLERN: return { "M", "pjf", "", 2 };
|
||||||
|
|
||||||
case TYPE::NMES_STATZ: return { "Z", "NMF", "", 1 };
|
case TYPE::NMES_STATZ: return { "Z", "nmf", "", 1 };
|
||||||
case TYPE::PMES_STATZ: return { "Z", "PMF", "", 1 };
|
case TYPE::PMES_STATZ: return { "Z", "pmf", "", 1 };
|
||||||
case TYPE::NMES_YTTERDAL: return { "Z", "NMF", "", 2 };
|
case TYPE::NMES_YTTERDAL: return { "Z", "nmf", "", 2 };
|
||||||
case TYPE::PMES_YTTERDAL: return { "Z", "PMF", "", 2 };
|
case TYPE::PMES_YTTERDAL: return { "Z", "pmf", "", 2 };
|
||||||
case TYPE::NMES_HFET1: return { "Z", "NMF", "", 5 };
|
case TYPE::NMES_HFET1: return { "Z", "nmf", "", 5 };
|
||||||
case TYPE::PMES_HFET1: return { "Z", "PMF", "", 5 };
|
case TYPE::PMES_HFET1: return { "Z", "pmf", "", 5 };
|
||||||
case TYPE::PMES_HFET2: return { "Z", "NMF", "", 6 };
|
case TYPE::PMES_HFET2: return { "Z", "nmf", "", 6 };
|
||||||
case TYPE::NMES_HFET2: return { "Z", "PMF", "", 6 };
|
case TYPE::NMES_HFET2: return { "Z", "pmf", "", 6 };
|
||||||
|
|
||||||
case TYPE::NMOS_MOS1: return { "M", "NMOS", "", 1 };
|
case TYPE::NMOS_MOS1: return { "M", "nmos", "", 1 };
|
||||||
case TYPE::PMOS_MOS1: return { "M", "PMOS", "", 1 };
|
case TYPE::PMOS_MOS1: return { "M", "pmos", "", 1 };
|
||||||
case TYPE::NMOS_MOS2: return { "M", "NMOS", "", 2 };
|
case TYPE::NMOS_MOS2: return { "M", "nmos", "", 2 };
|
||||||
case TYPE::PMOS_MOS2: return { "M", "PMOS", "", 2 };
|
case TYPE::PMOS_MOS2: return { "M", "pmos", "", 2 };
|
||||||
case TYPE::NMOS_MOS3: return { "M", "NMOS", "", 3 };
|
case TYPE::NMOS_MOS3: return { "M", "nmos", "", 3 };
|
||||||
case TYPE::PMOS_MOS3: return { "M", "PMOS", "", 3 };
|
case TYPE::PMOS_MOS3: return { "M", "pmos", "", 3 };
|
||||||
case TYPE::NMOS_BSIM1: return { "M", "NMOS", "", 4 };
|
case TYPE::NMOS_BSIM1: return { "M", "nmos", "", 4 };
|
||||||
case TYPE::PMOS_BSIM1: return { "M", "PMOS", "", 4 };
|
case TYPE::PMOS_BSIM1: return { "M", "pmos", "", 4 };
|
||||||
case TYPE::NMOS_BSIM2: return { "M", "NMOS", "", 5 };
|
case TYPE::NMOS_BSIM2: return { "M", "nmos", "", 5 };
|
||||||
case TYPE::PMOS_BSIM2: return { "M", "PMOS", "", 5 };
|
case TYPE::PMOS_BSIM2: return { "M", "pmos", "", 5 };
|
||||||
case TYPE::NMOS_MOS6: return { "M", "NMOS", "", 6 };
|
case TYPE::NMOS_MOS6: return { "M", "nmos", "", 6 };
|
||||||
case TYPE::PMOS_MOS6: return { "M", "PMOS", "", 6 };
|
case TYPE::PMOS_MOS6: return { "M", "pmos", "", 6 };
|
||||||
case TYPE::NMOS_BSIM3: return { "M", "NMOS", "", 8 };
|
case TYPE::NMOS_BSIM3: return { "M", "nmos", "", 8 };
|
||||||
case TYPE::PMOS_BSIM3: return { "M", "PMOS", "", 8 };
|
case TYPE::PMOS_BSIM3: return { "M", "pmos", "", 8 };
|
||||||
case TYPE::NMOS_MOS9: return { "M", "NMOS", "", 9 };
|
case TYPE::NMOS_MOS9: return { "M", "nmos", "", 9 };
|
||||||
case TYPE::PMOS_MOS9: return { "M", "PMOS", "", 9 };
|
case TYPE::PMOS_MOS9: return { "M", "pmos", "", 9 };
|
||||||
case TYPE::NMOS_B4SOI: return { "M", "NMOS", "", 10 };
|
case TYPE::NMOS_B4SOI: return { "M", "nmos", "", 10 };
|
||||||
case TYPE::PMOS_B4SOI: return { "M", "PMOS", "", 10 };
|
case TYPE::PMOS_B4SOI: return { "M", "pmos", "", 10 };
|
||||||
case TYPE::NMOS_BSIM4: return { "M", "NMOS", "", 14 };
|
case TYPE::NMOS_BSIM4: return { "M", "nmos", "", 14 };
|
||||||
case TYPE::PMOS_BSIM4: return { "M", "PMOS", "", 14 };
|
case TYPE::PMOS_BSIM4: return { "M", "pmos", "", 14 };
|
||||||
//case TYPE::NMOS_EKV2_6: return {};
|
//case TYPE::NMOS_EKV2_6: return {};
|
||||||
//case TYPE::PMOS_EKV2_6: return {};
|
//case TYPE::PMOS_EKV2_6: return {};
|
||||||
//case TYPE::NMOS_PSP: return {};
|
//case TYPE::NMOS_PSP: return {};
|
||||||
//case TYPE::PMOS_PSP: return {};
|
//case TYPE::PMOS_PSP: return {};
|
||||||
case TYPE::NMOS_B3SOIFD: return { "M", "NMOS", "", 55 };
|
case TYPE::NMOS_B3SOIFD: return { "M", "nmos", "", 55 };
|
||||||
case TYPE::PMOS_B3SOIFD: return { "M", "PMOS", "", 55 };
|
case TYPE::PMOS_B3SOIFD: return { "M", "pmos", "", 55 };
|
||||||
case TYPE::NMOS_B3SOIDD: return { "M", "NMOS", "", 56 };
|
case TYPE::NMOS_B3SOIDD: return { "M", "nmos", "", 56 };
|
||||||
case TYPE::PMOS_B3SOIDD: return { "M", "PMOS", "", 56 };
|
case TYPE::PMOS_B3SOIDD: return { "M", "pmos", "", 56 };
|
||||||
case TYPE::NMOS_B3SOIPD: return { "M", "NMOS", "", 57 };
|
case TYPE::NMOS_B3SOIPD: return { "M", "nmos", "", 57 };
|
||||||
case TYPE::PMOS_B3SOIPD: return { "M", "PMOS", "", 57 };
|
case TYPE::PMOS_B3SOIPD: return { "M", "pmos", "", 57 };
|
||||||
//case TYPE::NMOS_STAG: return {};
|
//case TYPE::NMOS_STAG: return {};
|
||||||
//case TYPE::PMOS_STAG: return {};
|
//case TYPE::PMOS_STAG: return {};
|
||||||
case TYPE::NMOS_HISIM2: return { "M", "NMOS", "", 68 };
|
case TYPE::NMOS_HISIM2: return { "M", "nmos", "", 68 };
|
||||||
case TYPE::PMOS_HISIM2: return { "M", "PMOS", "", 68 };
|
case TYPE::PMOS_HISIM2: return { "M", "pmos", "", 68 };
|
||||||
case TYPE::NMOS_HISIMHV1: return { "M", "NMOS", "", 73, false, "1.2.4" };
|
case TYPE::NMOS_HISIMHV1: return { "M", "nmos", "", 73, false, "1.2.4" };
|
||||||
case TYPE::PMOS_HISIMHV1: return { "M", "PMOS", "", 73, false, "1.2.4" };
|
case TYPE::PMOS_HISIMHV1: return { "M", "pmos", "", 73, false, "1.2.4" };
|
||||||
case TYPE::NMOS_HISIMHV2: return { "M", "NMOS", "", 73, false, "2.2.0" };
|
case TYPE::NMOS_HISIMHV2: return { "M", "nmos", "", 73, false, "2.2.0" };
|
||||||
case TYPE::PMOS_HISIMHV2: return { "M", "PMOS", "", 73, false, "2.2.0" };
|
case TYPE::PMOS_HISIMHV2: return { "M", "pmos", "", 73, false, "2.2.0" };
|
||||||
|
|
||||||
case TYPE::V_DC: return { "V", "" };
|
case TYPE::V_DC: return { "V", "" };
|
||||||
case TYPE::V_SIN: return { "V", "", "SIN" };
|
case TYPE::V_SIN: return { "V", "", "SIN" };
|
||||||
|
@ -442,10 +443,10 @@ template TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<LIB_FIELD>& aFiel
|
||||||
template <typename T>
|
template <typename T>
|
||||||
TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields )
|
TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields )
|
||||||
{
|
{
|
||||||
wxString typeFieldValue = GetFieldValue( &aFields, TYPE_FIELD );
|
|
||||||
wxString deviceTypeFieldValue = GetFieldValue( &aFields, DEVICE_TYPE_FIELD );
|
wxString deviceTypeFieldValue = GetFieldValue( &aFields, DEVICE_TYPE_FIELD );
|
||||||
|
wxString typeFieldValue = GetFieldValue( &aFields, TYPE_FIELD );
|
||||||
|
|
||||||
if( !typeFieldValue.IsEmpty() )
|
if( !deviceTypeFieldValue.IsEmpty() )
|
||||||
{
|
{
|
||||||
for( TYPE type : TYPE_ITERATOR() )
|
for( TYPE type : TYPE_ITERATOR() )
|
||||||
{
|
{
|
||||||
|
@ -455,26 +456,85 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<T>& aFields )
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TYPE::NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !typeFieldValue.IsEmpty() )
|
||||||
|
return TYPE::NONE;
|
||||||
|
|
||||||
// No type information. For passives we infer the model from the mandatory fields in this case.
|
// No type information. For passives we infer the model from the mandatory fields in this case.
|
||||||
|
TYPE typeFromRef = InferTypeFromRef( GetFieldValue( &aFields, REFERENCE_FIELD ) );
|
||||||
|
if( typeFromRef != TYPE::NONE )
|
||||||
|
return typeFromRef;
|
||||||
|
|
||||||
wxString ref = GetFieldValue( &aFields, REFERENCE_FIELD );
|
// Finally, try to infer the model from legacy fields, if present.
|
||||||
|
return InferTypeFromLegacyFields( aFields );
|
||||||
|
}
|
||||||
|
|
||||||
if( ref.StartsWith( "R" ) )
|
|
||||||
return TYPE::R;
|
TYPE SIM_MODEL::InferTypeFromRef( const wxString& aRef )
|
||||||
else if( ref.StartsWith( "C" ) )
|
{
|
||||||
return TYPE::C;
|
static std::map<wxString, TYPE> refPrefixToType = {
|
||||||
else if( ref.StartsWith( "L" ) )
|
{ "R", TYPE::R },
|
||||||
return TYPE::L;
|
{ "C", TYPE::C },
|
||||||
|
{ "L", TYPE::L },
|
||||||
|
{ "VDC", TYPE::V_DC },
|
||||||
|
{ "VSIN", TYPE::V_SIN },
|
||||||
|
{ "VPULSE", TYPE::V_PULSE },
|
||||||
|
{ "VEXP", TYPE::V_EXP },
|
||||||
|
{ "VSFAM", TYPE::V_SFAM },
|
||||||
|
{ "VSFFM", TYPE::V_SFFM },
|
||||||
|
{ "VPWL", TYPE::V_PWL },
|
||||||
|
{ "VWHITENOISE", TYPE::V_WHITENOISE },
|
||||||
|
{ "VPINKNOISE", TYPE::V_PINKNOISE },
|
||||||
|
{ "VBURSTNOISE", TYPE::V_BURSTNOISE },
|
||||||
|
{ "VRANDUNIFORM", TYPE::V_RANDUNIFORM },
|
||||||
|
{ "VRANDNORMAL", TYPE::V_RANDNORMAL },
|
||||||
|
{ "VRANDEXP", TYPE::V_RANDEXP },
|
||||||
|
{ "VRANDPOISSON", TYPE::V_RANDPOISSON },
|
||||||
|
{ "VBEHAVIORAL", TYPE::V_BEHAVIORAL },
|
||||||
|
{ "IDC", TYPE::I_DC },
|
||||||
|
{ "ISIN", TYPE::I_SIN },
|
||||||
|
{ "IPULSE", TYPE::I_PULSE },
|
||||||
|
{ "IEXP", TYPE::I_EXP },
|
||||||
|
{ "ISFAM", TYPE::I_SFAM },
|
||||||
|
{ "ISFFM", TYPE::I_SFFM },
|
||||||
|
{ "IPWL", TYPE::I_PWL },
|
||||||
|
{ "IWHITENOISE", TYPE::I_WHITENOISE },
|
||||||
|
{ "IPINKNOISE", TYPE::I_PINKNOISE },
|
||||||
|
{ "IBURSTNOISE", TYPE::I_BURSTNOISE },
|
||||||
|
{ "IRANDUNIFORM", TYPE::I_RANDUNIFORM },
|
||||||
|
{ "IRANDNORMAL", TYPE::I_RANDNORMAL },
|
||||||
|
{ "IRANDEXP", TYPE::I_RANDEXP },
|
||||||
|
{ "IRANDPOISSON", TYPE::I_RANDPOISSON },
|
||||||
|
{ "IBEHAVIORAL", TYPE::I_BEHAVIORAL }
|
||||||
|
};
|
||||||
|
|
||||||
|
for( auto&& [prefix, type] : refPrefixToType )
|
||||||
|
{
|
||||||
|
if( aRef.StartsWith( prefix ) )
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
return TYPE::NONE;
|
return TYPE::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, int aSymbolPinCount )
|
template <typename T>
|
||||||
|
TYPE SIM_MODEL::InferTypeFromLegacyFields( const std::vector<T>& aFields )
|
||||||
|
{
|
||||||
|
if( !GetFieldValue( &aFields, SIM_MODEL_SPICE::LEGACY_TYPE_FIELD ).IsEmpty()
|
||||||
|
|| !GetFieldValue( &aFields, SIM_MODEL_SPICE::LEGACY_MODEL_FIELD ).IsEmpty()
|
||||||
|
|| !GetFieldValue( &aFields, SIM_MODEL_SPICE::LEGACY_ENABLED_FIELD ).IsEmpty()
|
||||||
|
|| !GetFieldValue( &aFields, SIM_MODEL_SPICE::LEGACY_LIB_FIELD ).IsEmpty() )
|
||||||
|
{
|
||||||
|
return TYPE::SPICE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return TYPE::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, unsigned aSymbolPinCount )
|
||||||
{
|
{
|
||||||
std::unique_ptr<SIM_MODEL> model = create( aType );
|
std::unique_ptr<SIM_MODEL> model = create( aType );
|
||||||
|
|
||||||
|
@ -502,15 +562,15 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::string& aSpiceCode )
|
||||||
|
|
||||||
|
|
||||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel,
|
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel,
|
||||||
int aSymbolPinCount,
|
unsigned aSymbolPinCount,
|
||||||
const std::vector<SCH_FIELD>& aFields );
|
const std::vector<SCH_FIELD>& aFields );
|
||||||
|
|
||||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel,
|
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel,
|
||||||
int aSymbolPinCount,
|
unsigned aSymbolPinCount,
|
||||||
const std::vector<LIB_FIELD>& aFields );
|
const std::vector<LIB_FIELD>& aFields );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel, unsigned aSymbolPinCount,
|
||||||
const std::vector<T>& aFields )
|
const std::vector<T>& aFields )
|
||||||
{
|
{
|
||||||
std::unique_ptr<SIM_MODEL> model = create( aBaseModel.GetType() );
|
std::unique_ptr<SIM_MODEL> model = create( aBaseModel.GetType() );
|
||||||
|
@ -521,13 +581,14 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel, int a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( int aSymbolPinCount,
|
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( unsigned aSymbolPinCount,
|
||||||
const std::vector<SCH_FIELD>& aFields );
|
const std::vector<SCH_FIELD>& aFields );
|
||||||
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( int aSymbolPinCount,
|
template std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( unsigned aSymbolPinCount,
|
||||||
const std::vector<LIB_FIELD>& aFields );
|
const std::vector<LIB_FIELD>& aFields );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( int aSymbolPinCount, const std::vector<T>& aFields )
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( unsigned aSymbolPinCount,
|
||||||
|
const std::vector<T>& aFields )
|
||||||
{
|
{
|
||||||
std::unique_ptr<SIM_MODEL> model = SIM_MODEL::create( ReadTypeFromFields( aFields ) );
|
std::unique_ptr<SIM_MODEL> model = SIM_MODEL::create( ReadTypeFromFields( aFields ) );
|
||||||
|
|
||||||
|
@ -608,10 +669,10 @@ bool SIM_MODEL::ReadSpiceCode( const std::string& aSpiceCode )
|
||||||
{
|
{
|
||||||
// The default behavior is to treat the Spice param=value pairs as the model parameters and
|
// The default behavior is to treat the Spice param=value pairs as the model parameters and
|
||||||
// values (for many models the correspondence is not exact, so this function is overridden).
|
// values (for many models the correspondence is not exact, so this function is overridden).
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aSpiceCode, "from_content" );
|
tao::pegtl::string_input<> in( aSpiceCode, "from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
root = tao::pegtl::parse_tree::parse<SIM_MODEL_PARSER::spiceUnitGrammar,
|
root = tao::pegtl::parse_tree::parse<SIM_MODEL_PARSER::spiceUnitGrammar,
|
||||||
|
@ -620,6 +681,7 @@ bool SIM_MODEL::ReadSpiceCode( const std::string& aSpiceCode )
|
||||||
}
|
}
|
||||||
catch( tao::pegtl::parse_error& e )
|
catch( tao::pegtl::parse_error& e )
|
||||||
{
|
{
|
||||||
|
m_errorMessage = e.what();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +719,7 @@ bool SIM_MODEL::ReadSpiceCode( const std::string& aSpiceCode )
|
||||||
{
|
{
|
||||||
wxASSERT( !paramName.IsEmpty() );
|
wxASSERT( !paramName.IsEmpty() );
|
||||||
|
|
||||||
if( !setParamFromSpiceCode( paramName, subnode->string() ) )
|
if( !SetParamFromSpiceCode( paramName, subnode->string() ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -680,59 +742,59 @@ bool SIM_MODEL::ReadSpiceCode( const std::string& aSpiceCode )
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SIM_MODEL::ReadDataFields( int aSymbolPinCount, const std::vector<T>* aFields )
|
void SIM_MODEL::ReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields )
|
||||||
{
|
{
|
||||||
doReadDataFields( aSymbolPinCount, aFields );
|
doReadDataFields( aSymbolPinCount, aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void SIM_MODEL::ReadDataFields( int aSymbolPinCount, const std::vector<SCH_FIELD>* aFields )
|
void SIM_MODEL::ReadDataFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
ReadDataSchFields( aSymbolPinCount, aFields );
|
ReadDataSchFields( aSymbolPinCount, aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void SIM_MODEL::ReadDataFields( int aSymbolPinCount, const std::vector<LIB_FIELD>* aFields )
|
void SIM_MODEL::ReadDataFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
ReadDataLibFields( aSymbolPinCount, aFields );
|
ReadDataLibFields( aSymbolPinCount, aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::ReadDataSchFields( int aSymbolPinCount, const std::vector<SCH_FIELD>* aFields )
|
void SIM_MODEL::ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
doReadDataFields( aSymbolPinCount, aFields );
|
doReadDataFields( aSymbolPinCount, aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::ReadDataLibFields( int aSymbolPinCount, const std::vector<LIB_FIELD>* aFields )
|
void SIM_MODEL::ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
doReadDataFields( aSymbolPinCount, aFields );
|
doReadDataFields( aSymbolPinCount, aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields )
|
void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields ) const
|
||||||
{
|
{
|
||||||
WriteDataSchFields( aFields );
|
WriteDataSchFields( aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void SIM_MODEL::WriteFields( std::vector<LIB_FIELD>& aFields )
|
void SIM_MODEL::WriteFields( std::vector<LIB_FIELD>& aFields ) const
|
||||||
{
|
{
|
||||||
WriteDataLibFields( aFields );
|
WriteDataLibFields( aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::WriteDataSchFields( std::vector<SCH_FIELD>& aFields )
|
void SIM_MODEL::WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const
|
||||||
{
|
{
|
||||||
doWriteFields( aFields );
|
doWriteFields( aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::WriteDataLibFields( std::vector<LIB_FIELD>& aFields )
|
void SIM_MODEL::WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const
|
||||||
{
|
{
|
||||||
doWriteFields( aFields );
|
doWriteFields( aFields );
|
||||||
}
|
}
|
||||||
|
@ -750,7 +812,7 @@ wxString SIM_MODEL::GenerateSpiceModelLine( const wxString& aModelName ) const
|
||||||
|
|
||||||
line << wxString::Format( ".model %s %s(\n+", aModelName, GetSpiceInfo().modelType );
|
line << wxString::Format( ".model %s %s(\n+", aModelName, GetSpiceInfo().modelType );
|
||||||
|
|
||||||
for( int paramIndex = 0; paramIndex < GetParamCount(); ++paramIndex )
|
for( unsigned paramIndex = 0; paramIndex < GetParamCount(); ++paramIndex )
|
||||||
{
|
{
|
||||||
const PARAM& param = GetParam( paramIndex );
|
const PARAM& param = GetParam( paramIndex );
|
||||||
wxString valueStr = param.value->ToString();
|
wxString valueStr = param.value->ToString();
|
||||||
|
@ -776,10 +838,10 @@ wxString SIM_MODEL::GenerateSpiceModelLine( const wxString& aModelName ) const
|
||||||
|
|
||||||
wxString SIM_MODEL::GenerateSpiceItemName( const wxString& aRefName ) const
|
wxString SIM_MODEL::GenerateSpiceItemName( const wxString& aRefName ) const
|
||||||
{
|
{
|
||||||
if( !aRefName.IsEmpty() && aRefName.StartsWith( GetSpiceInfo().primitive ) )
|
if( !aRefName.IsEmpty() && aRefName.StartsWith( GetSpiceInfo().itemType ) )
|
||||||
return aRefName;
|
return aRefName;
|
||||||
else
|
else
|
||||||
return GetSpiceInfo().primitive + aRefName;
|
return GetSpiceInfo().itemType + aRefName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,23 +859,21 @@ wxString SIM_MODEL::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
wxString result = "";
|
wxString result = "";
|
||||||
result << GenerateSpiceItemName( aRefName ) << " ";
|
result << GenerateSpiceItemName( aRefName ) << " ";
|
||||||
|
|
||||||
for( int i = 0; i < GetPinCount(); ++i )
|
for( const PIN& pin : GetPins() )
|
||||||
{
|
{
|
||||||
for( int j = 0; j < ( int ) aPinNetNames.size(); ++j )
|
for( unsigned i = 0; i < aPinNetNames.size(); ++i )
|
||||||
{
|
{
|
||||||
int symbolPinNumber = j + 1;
|
unsigned symbolPinNumber = i + 1;
|
||||||
|
|
||||||
if( symbolPinNumber == GetPin( i ).symbolPinNumber )
|
if( symbolPinNumber == pin.symbolPinNumber )
|
||||||
result << aPinNetNames[j] << " ";
|
result << aPinNetNames[i] << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result << aModelName << " ";
|
result << aModelName << " ";
|
||||||
|
|
||||||
for( int i = 0; i < GetParamCount(); ++i )
|
for( const PARAM& param : GetParams() )
|
||||||
{
|
{
|
||||||
const PARAM& param = GetParam( i );
|
|
||||||
|
|
||||||
if( param.info.isInstanceParam )
|
if( param.info.isInstanceParam )
|
||||||
result << param.info.name << "=" << param.value->ToString() << " ";
|
result << param.info.name << "=" << param.value->ToString() << " ";
|
||||||
}
|
}
|
||||||
|
@ -860,63 +920,15 @@ std::vector<wxString> SIM_MODEL::GenerateSpiceCurrentNames( const wxString& aRef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::ParsePinsField( int aSymbolPinCount, const wxString& aPinsField )
|
|
||||||
{
|
|
||||||
// Default pin sequence: model pins are the same as symbol pins.
|
|
||||||
// Excess model pins are set as Not Connected.
|
|
||||||
for( int i = 0; i < static_cast<int>( getPinNames().size() ); ++i )
|
|
||||||
{
|
|
||||||
if( i < aSymbolPinCount )
|
|
||||||
AddPin( { getPinNames().at( i ), i + 1 } );
|
|
||||||
else
|
|
||||||
AddPin( { getPinNames().at( i ), PIN::NOT_CONNECTED } );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aPinsField.IsEmpty() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
LOCALE_IO toggle;
|
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aPinsField.ToStdString(), "from_content" );
|
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
root = tao::pegtl::parse_tree::parse<SIM_MODEL_PARSER::pinSequenceGrammar,
|
|
||||||
SIM_MODEL_PARSER::pinSequenceSelector>( in );
|
|
||||||
}
|
|
||||||
catch( const tao::pegtl::parse_error& e )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxASSERT( root );
|
|
||||||
|
|
||||||
if( static_cast<int>( root->children.size() ) != GetPinCount() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for( unsigned int i = 0; i < root->children.size(); ++i )
|
|
||||||
{
|
|
||||||
if( root->children.at( i )->string() == "X" )
|
|
||||||
SetPinSymbolPinNumber( static_cast<int>( i ), PIN::NOT_CONNECTED );
|
|
||||||
else
|
|
||||||
SetPinSymbolPinNumber( static_cast<int>( i ),
|
|
||||||
std::stoi( root->children.at( i )->string() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::AddPin( const PIN& aPin )
|
void SIM_MODEL::AddPin( const PIN& aPin )
|
||||||
{
|
{
|
||||||
m_pins.push_back( aPin );
|
m_pins.push_back( aPin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SIM_MODEL::FindModelPinNumber( int aSymbolPinNumber )
|
unsigned SIM_MODEL::FindModelPinNumber( unsigned aSymbolPinNumber )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < GetPinCount(); ++i )
|
for( unsigned i = 0; i < GetPinCount(); ++i )
|
||||||
{
|
{
|
||||||
if( GetPin( i ).symbolPinNumber == aSymbolPinNumber )
|
if( GetPin( i ).symbolPinNumber == aSymbolPinNumber )
|
||||||
return i + 1;
|
return i + 1;
|
||||||
|
@ -932,7 +944,18 @@ void SIM_MODEL::AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SIM_MODEL::PARAM& SIM_MODEL::GetParam( int aParamIndex ) const
|
std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> SIM_MODEL::GetPins() const
|
||||||
|
{
|
||||||
|
std::vector<std::reference_wrapper<const PIN>> pins;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < GetPinCount(); ++i )
|
||||||
|
pins.emplace_back( GetPin( i ) );
|
||||||
|
|
||||||
|
return pins;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const SIM_MODEL::PARAM& SIM_MODEL::GetParam( unsigned aParamIndex ) const
|
||||||
{
|
{
|
||||||
if( m_baseModel && m_params.at( aParamIndex ).value->ToString().IsEmpty() )
|
if( m_baseModel && m_params.at( aParamIndex ).value->ToString().IsEmpty() )
|
||||||
return m_baseModel->GetParam( aParamIndex );
|
return m_baseModel->GetParam( aParamIndex );
|
||||||
|
@ -941,13 +964,24 @@ const SIM_MODEL::PARAM& SIM_MODEL::GetParam( int aParamIndex ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SIM_MODEL::PARAM& SIM_MODEL::GetUnderlyingParam( int aParamIndex ) const
|
std::vector<std::reference_wrapper<const SIM_MODEL::PARAM>> SIM_MODEL::GetParams() const
|
||||||
|
{
|
||||||
|
std::vector<std::reference_wrapper<const PARAM>> params;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < GetParamCount(); ++i )
|
||||||
|
params.emplace_back( GetParam( i ) );
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const SIM_MODEL::PARAM& SIM_MODEL::GetUnderlyingParam( unsigned aParamIndex ) const
|
||||||
{
|
{
|
||||||
return m_params.at( aParamIndex );
|
return m_params.at( aParamIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SIM_MODEL::PARAM& SIM_MODEL::GetBaseParam( int aParamIndex ) const
|
const SIM_MODEL::PARAM& SIM_MODEL::GetBaseParam( unsigned aParamIndex ) const
|
||||||
{
|
{
|
||||||
if( m_baseModel )
|
if( m_baseModel )
|
||||||
return m_baseModel->GetParam( aParamIndex );
|
return m_baseModel->GetParam( aParamIndex );
|
||||||
|
@ -956,7 +990,7 @@ const SIM_MODEL::PARAM& SIM_MODEL::GetBaseParam( int aParamIndex ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::SetParamValue( int aParamIndex, const wxString& aValue,
|
bool SIM_MODEL::SetParamValue( unsigned aParamIndex, const wxString& aValue,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
{
|
{
|
||||||
// Models sourced from a library are immutable.
|
// Models sourced from a library are immutable.
|
||||||
|
@ -999,6 +1033,191 @@ SIM_MODEL::SIM_MODEL( TYPE aType ) : m_baseModel( nullptr ), m_type( aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template void SIM_MODEL::WriteInferredDataFields( std::vector<SCH_FIELD>& aFields,
|
||||||
|
const wxString& aValue ) const;
|
||||||
|
template void SIM_MODEL::WriteInferredDataFields( std::vector<LIB_FIELD>& aFields,
|
||||||
|
const wxString& aValue ) const;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL::WriteInferredDataFields( std::vector<T>& aFields, const wxString& aValue ) const
|
||||||
|
{
|
||||||
|
if( GetPinCount() == 2
|
||||||
|
&& GetPin( 0 ).symbolPinNumber == 1
|
||||||
|
&& GetPin( 1 ).symbolPinNumber == 2 )
|
||||||
|
{
|
||||||
|
SetFieldValue( aFields, PINS_FIELD, "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFieldValue( aFields, VALUE_FIELD, aValue );
|
||||||
|
SetFieldValue( aFields, DEVICE_TYPE_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, TYPE_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, PARAMS_FIELD, "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL::GenerateParamValuePair( const PARAM& aParam, bool& aIsFirst ) const
|
||||||
|
{
|
||||||
|
wxString result = "";
|
||||||
|
|
||||||
|
if( aIsFirst )
|
||||||
|
aIsFirst = false;
|
||||||
|
else
|
||||||
|
result << " ";
|
||||||
|
|
||||||
|
result << aParam.info.name + "=" + aParam.value->ToString();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL::GenerateParamsField( const wxString& aPairSeparator ) const
|
||||||
|
{
|
||||||
|
bool isFirst = true;
|
||||||
|
wxString result = "";
|
||||||
|
|
||||||
|
for( const PARAM& param : m_params )
|
||||||
|
{
|
||||||
|
wxString valueStr = param.value->ToString();
|
||||||
|
|
||||||
|
if( valueStr.IsEmpty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result << GenerateParamValuePair( param, isFirst );
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL::ParseParamsField( const wxString& aParamsField )
|
||||||
|
{
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
tao::pegtl::string_input<> in( aParamsField.ToStdString(), "from_content" );
|
||||||
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Using parse tree instead of actions because we don't care about performance that much,
|
||||||
|
// and having a tree greatly simplifies some things.
|
||||||
|
root = tao::pegtl::parse_tree::parse<
|
||||||
|
SIM_MODEL_PARSER::fieldParamValuePairsGrammar,
|
||||||
|
SIM_MODEL_PARSER::fieldParamValuePairsSelector>
|
||||||
|
( in );
|
||||||
|
}
|
||||||
|
catch( const tao::pegtl::parse_error& e )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxASSERT( root );
|
||||||
|
|
||||||
|
wxString paramName = "";
|
||||||
|
|
||||||
|
for( const auto& node : root->children )
|
||||||
|
{
|
||||||
|
if( node->is_type<SIM_MODEL_PARSER::param>() )
|
||||||
|
paramName = node->string();
|
||||||
|
// TODO: Do something with number<SIM_VALUE::TYPE::INT, ...>.
|
||||||
|
// It doesn't seem too useful?
|
||||||
|
else if( node->is_type<SIM_MODEL_PARSER::number<SIM_VALUE::TYPE::INT,
|
||||||
|
SIM_MODEL_PARSER::NOTATION::SI>>()
|
||||||
|
|| node->is_type<SIM_MODEL_PARSER::number<SIM_VALUE::TYPE::FLOAT,
|
||||||
|
SIM_MODEL_PARSER::NOTATION::SI>>()
|
||||||
|
|| node->is_type<SIM_MODEL_PARSER::unquotedString>() )
|
||||||
|
{
|
||||||
|
wxASSERT( !paramName.IsEmpty() );
|
||||||
|
// TODO: Shouldn't be named "...fromSpiceCode" here...
|
||||||
|
|
||||||
|
SetParamFromSpiceCode( paramName, node->string(), SIM_VALUE_GRAMMAR::NOTATION::SI );
|
||||||
|
}
|
||||||
|
else if( node->is_type<SIM_MODEL_PARSER::quotedString>() )
|
||||||
|
{
|
||||||
|
wxASSERT( !paramName.IsEmpty() );
|
||||||
|
|
||||||
|
wxString str = node->string();
|
||||||
|
|
||||||
|
// Unescape quotes.
|
||||||
|
str.Replace( "\\\"", "\"" );
|
||||||
|
|
||||||
|
SetParamFromSpiceCode( paramName, str, SIM_VALUE_GRAMMAR::NOTATION::SI );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxFAIL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL::ParsePinsField( unsigned aSymbolPinCount, const wxString& aPinsField )
|
||||||
|
{
|
||||||
|
// Default pin sequence: model pins are the same as symbol pins.
|
||||||
|
// Excess model pins are set as Not Connected.
|
||||||
|
for( unsigned i = 0; i < getPinNames().size(); ++i )
|
||||||
|
{
|
||||||
|
if( i < aSymbolPinCount )
|
||||||
|
AddPin( { getPinNames().at( i ), i + 1 } );
|
||||||
|
else
|
||||||
|
AddPin( { getPinNames().at( i ), PIN::NOT_CONNECTED } );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aPinsField.IsEmpty() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
tao::pegtl::string_input<> in( aPinsField.ToStdString(), "from_content" );
|
||||||
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
root = tao::pegtl::parse_tree::parse<SIM_MODEL_PARSER::pinSequenceGrammar,
|
||||||
|
SIM_MODEL_PARSER::pinSequenceSelector>( in );
|
||||||
|
}
|
||||||
|
catch( const tao::pegtl::parse_error& e )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxASSERT( root );
|
||||||
|
|
||||||
|
if( root->children.size() != GetPinCount() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < root->children.size(); ++i )
|
||||||
|
{
|
||||||
|
if( root->children.at( i )->string() == "X" )
|
||||||
|
SetPinSymbolPinNumber( static_cast<int>( i ), PIN::NOT_CONNECTED );
|
||||||
|
else
|
||||||
|
SetPinSymbolPinNumber( static_cast<int>( i ),
|
||||||
|
std::stoi( root->children.at( i )->string() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL::SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
|
{
|
||||||
|
std::vector<std::reference_wrapper<const PARAM>> params = GetParams();
|
||||||
|
|
||||||
|
auto it = std::find_if( params.begin(), params.end(),
|
||||||
|
[aParamName]( const PARAM& param )
|
||||||
|
{
|
||||||
|
return param.info.name == aParamName.Lower();
|
||||||
|
} );
|
||||||
|
|
||||||
|
if( it == params.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SetParamValue( it - params.begin(), aParamValue, aNotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::create( TYPE aType )
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::create( TYPE aType )
|
||||||
{
|
{
|
||||||
switch( aType )
|
switch( aType )
|
||||||
|
@ -1008,6 +1227,11 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::create( TYPE aType )
|
||||||
case TYPE::L:
|
case TYPE::L:
|
||||||
return std::make_unique<SIM_MODEL_IDEAL>( aType );
|
return std::make_unique<SIM_MODEL_IDEAL>( aType );
|
||||||
|
|
||||||
|
case TYPE::R_ADV:
|
||||||
|
case TYPE::C_ADV:
|
||||||
|
case TYPE::L_ADV:
|
||||||
|
return std::make_unique<SIM_MODEL_PASSIVE>( aType );
|
||||||
|
|
||||||
case TYPE::R_BEHAVIORAL:
|
case TYPE::R_BEHAVIORAL:
|
||||||
case TYPE::C_BEHAVIORAL:
|
case TYPE::C_BEHAVIORAL:
|
||||||
case TYPE::L_BEHAVIORAL:
|
case TYPE::L_BEHAVIORAL:
|
||||||
|
@ -1052,7 +1276,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::create( TYPE aType )
|
||||||
return std::make_unique<SIM_MODEL_XSPICE>( aType );
|
return std::make_unique<SIM_MODEL_XSPICE>( aType );
|
||||||
|
|
||||||
case TYPE::SPICE:
|
case TYPE::SPICE:
|
||||||
return std::make_unique<SIM_MODEL_RAWSPICE>( aType );
|
return std::make_unique<SIM_MODEL_SPICE>( aType );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::make_unique<SIM_MODEL_NGSPICE>( aType );
|
return std::make_unique<SIM_MODEL_NGSPICE>( aType );
|
||||||
|
@ -1062,9 +1286,19 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::create( TYPE aType )
|
||||||
|
|
||||||
TYPE SIM_MODEL::readTypeFromSpiceTypeString( const std::string& aTypeString )
|
TYPE SIM_MODEL::readTypeFromSpiceTypeString( const std::string& aTypeString )
|
||||||
{
|
{
|
||||||
|
std::string lowercaseTypeString = aTypeString;
|
||||||
|
std::transform( lowercaseTypeString.begin(), lowercaseTypeString.end(),
|
||||||
|
lowercaseTypeString.begin(), ::tolower );
|
||||||
|
|
||||||
for( TYPE type : TYPE_ITERATOR() )
|
for( TYPE type : TYPE_ITERATOR() )
|
||||||
{
|
{
|
||||||
if( SpiceInfo( type ).modelType == aTypeString )
|
wxString typePrefix = SpiceInfo( type ).modelType;
|
||||||
|
|
||||||
|
if( typePrefix == "" )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Check if `aTypeString` starts with `typePrefix`.
|
||||||
|
if( lowercaseTypeString.rfind( typePrefix, 0 ) == 0 )
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,20 +1309,20 @@ TYPE SIM_MODEL::readTypeFromSpiceTypeString( const std::string& aTypeString )
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SIM_MODEL::doReadDataFields( int aSymbolPinCount, const std::vector<T>* aFields )
|
void SIM_MODEL::doReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields )
|
||||||
{
|
{
|
||||||
ParsePinsField( aSymbolPinCount, GetFieldValue( aFields, PINS_FIELD ) );
|
ParsePinsField( aSymbolPinCount, GetFieldValue( aFields, PINS_FIELD ) );
|
||||||
parseParamsField( GetFieldValue( aFields, PARAMS_FIELD ) );
|
ParseParamsField( GetFieldValue( aFields, PARAMS_FIELD ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SIM_MODEL::doWriteFields( std::vector<T>& aFields )
|
void SIM_MODEL::doWriteFields( std::vector<T>& aFields ) const
|
||||||
{
|
{
|
||||||
SetFieldValue( aFields, DEVICE_TYPE_FIELD, generateDeviceTypeField() );
|
SetFieldValue( aFields, DEVICE_TYPE_FIELD, generateDeviceTypeField() );
|
||||||
SetFieldValue( aFields, TYPE_FIELD, generateTypeField() );
|
SetFieldValue( aFields, TYPE_FIELD, generateTypeField() );
|
||||||
SetFieldValue( aFields, PINS_FIELD, generatePinsField() );
|
SetFieldValue( aFields, PINS_FIELD, generatePinsField() );
|
||||||
SetFieldValue( aFields, PARAMS_FIELD, generateParamsField( " " ) );
|
SetFieldValue( aFields, PARAMS_FIELD, GenerateParamsField( " " ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1109,7 +1343,7 @@ wxString SIM_MODEL::generatePinsField() const
|
||||||
wxString result = "";
|
wxString result = "";
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
|
|
||||||
for( int i = 0; i < GetPinCount(); ++i )
|
for( unsigned i = 0; i < GetPinCount(); ++i )
|
||||||
{
|
{
|
||||||
if( isFirst )
|
if( isFirst )
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
|
@ -1124,96 +1358,3 @@ wxString SIM_MODEL::generatePinsField() const
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SIM_MODEL::generateParamsField( const wxString& aPairSeparator ) const
|
|
||||||
{
|
|
||||||
bool isFirst = true;
|
|
||||||
wxString result = "";
|
|
||||||
|
|
||||||
for( const PARAM& param : m_params )
|
|
||||||
{
|
|
||||||
wxString valueStr = param.value->ToString();
|
|
||||||
|
|
||||||
if( valueStr.IsEmpty() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if( isFirst )
|
|
||||||
isFirst = false;
|
|
||||||
else
|
|
||||||
result << " ";
|
|
||||||
|
|
||||||
result << param.info.name;
|
|
||||||
result << "=";
|
|
||||||
result << param.value->ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::parseParamsField( const wxString& aParamsField )
|
|
||||||
{
|
|
||||||
LOCALE_IO toggle;
|
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aParamsField.ToStdString(), "from_content" );
|
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Using parse tree instead of actions because we don't care about performance that much,
|
|
||||||
// and having a tree greatly simplifies some things.
|
|
||||||
root = tao::pegtl::parse_tree::parse<
|
|
||||||
SIM_MODEL_PARSER::paramValuePairsGrammar<SIM_MODEL_PARSER::NOTATION::SI>,
|
|
||||||
SIM_MODEL_PARSER::paramValuePairsSelector>
|
|
||||||
( in );
|
|
||||||
}
|
|
||||||
catch( const tao::pegtl::parse_error& e )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxASSERT( root );
|
|
||||||
|
|
||||||
wxString paramName = "";
|
|
||||||
|
|
||||||
for( const auto& node : root->children )
|
|
||||||
{
|
|
||||||
if( node->is_type<SIM_MODEL_PARSER::param>() )
|
|
||||||
paramName = node->string();
|
|
||||||
// TODO: Do something with number<SIM_VALUE::TYPE::INT, ...>.
|
|
||||||
// It doesn't seem too useful?
|
|
||||||
else if( node->is_type<SIM_MODEL_PARSER::number<SIM_VALUE::TYPE::FLOAT,
|
|
||||||
SIM_MODEL_PARSER::NOTATION::SI>>() )
|
|
||||||
{
|
|
||||||
wxASSERT( !paramName.IsEmpty() );
|
|
||||||
// TODO: Shouldn't be named "...fromSpiceCode" here...
|
|
||||||
setParamFromSpiceCode( paramName, node->string(), SIM_VALUE_GRAMMAR::NOTATION::SI );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxFAIL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::setParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for(; i < GetParamCount(); ++i )
|
|
||||||
{
|
|
||||||
if( GetParam( i ).info.name == aParamName.Lower() )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( i == GetParamCount() )
|
|
||||||
return false; // No parameter with this name exists.
|
|
||||||
|
|
||||||
return SetParamValue( i, wxString( aParamValue ), aNotation );
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <lib_field.h>
|
#include <lib_field.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
class SIM_LIBRARY;
|
class SIM_LIBRARY;
|
||||||
|
|
||||||
|
@ -40,6 +39,8 @@ namespace SIM_MODEL_GRAMMAR
|
||||||
{
|
{
|
||||||
using namespace SPICE_GRAMMAR;
|
using namespace SPICE_GRAMMAR;
|
||||||
|
|
||||||
|
struct sep : plus<space> {};
|
||||||
|
|
||||||
|
|
||||||
struct pinNumber : sor<digits, one<'X'>> {};
|
struct pinNumber : sor<digits, one<'X'>> {};
|
||||||
struct pinSequence : seq<opt<pinNumber,
|
struct pinSequence : seq<opt<pinNumber,
|
||||||
|
@ -51,11 +52,29 @@ namespace SIM_MODEL_GRAMMAR
|
||||||
opt<sep>,
|
opt<sep>,
|
||||||
eof> {};
|
eof> {};
|
||||||
|
|
||||||
template <NOTATION Notation>
|
struct unquotedString : plus<not_at<space>, any> {};
|
||||||
struct paramValuePairsGrammar : must<opt<sep>,
|
struct quotedString : seq<one<'"'>,
|
||||||
paramValuePairs<Notation>,
|
until<seq<not_at<string<'\\',
|
||||||
opt<sep>,
|
'"'>>,
|
||||||
eof> {};
|
one<'"'>>>> {};
|
||||||
|
|
||||||
|
struct fieldParamValuePair : seq<param,
|
||||||
|
opt<sep>,
|
||||||
|
one<'='>,
|
||||||
|
opt<sep>,
|
||||||
|
sor<number<SIM_VALUE::TYPE::FLOAT, NOTATION::SI>,
|
||||||
|
number<SIM_VALUE::TYPE::INT, NOTATION::SI>,
|
||||||
|
quotedString,
|
||||||
|
unquotedString>> {};
|
||||||
|
|
||||||
|
struct fieldParamValuePairs : seq<opt<fieldParamValuePair>,
|
||||||
|
star<sep,
|
||||||
|
fieldParamValuePair>> {};
|
||||||
|
|
||||||
|
struct fieldParamValuePairsGrammar : must<opt<sep>,
|
||||||
|
fieldParamValuePairs,
|
||||||
|
opt<sep>,
|
||||||
|
eof> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,7 +289,7 @@ public:
|
||||||
|
|
||||||
struct SPICE_INFO
|
struct SPICE_INFO
|
||||||
{
|
{
|
||||||
wxString primitive;
|
wxString itemType;
|
||||||
wxString modelType = "";
|
wxString modelType = "";
|
||||||
wxString inlineTypeString = "";
|
wxString inlineTypeString = "";
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
@ -284,7 +303,7 @@ public:
|
||||||
static constexpr auto NOT_CONNECTED = 0;
|
static constexpr auto NOT_CONNECTED = 0;
|
||||||
|
|
||||||
const wxString name;
|
const wxString name;
|
||||||
int symbolPinNumber;
|
unsigned symbolPinNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,14 +337,14 @@ public:
|
||||||
struct INFO
|
struct INFO
|
||||||
{
|
{
|
||||||
wxString name;
|
wxString name;
|
||||||
unsigned int id = 0; // Legacy.
|
unsigned id = 0; // Legacy (don't remove).
|
||||||
DIR dir = DIR::INOUT;
|
DIR dir = DIR::INOUT;
|
||||||
SIM_VALUE::TYPE type = SIM_VALUE::TYPE::FLOAT;
|
SIM_VALUE::TYPE type = SIM_VALUE::TYPE::FLOAT;
|
||||||
FLAGS flags = {}; // Legacy
|
FLAGS flags = {}; // Legacy (don't remove).
|
||||||
wxString unit = "";
|
wxString unit = "";
|
||||||
CATEGORY category = CATEGORY::PRINCIPAL;
|
CATEGORY category = CATEGORY::PRINCIPAL;
|
||||||
wxString defaultValue = "";
|
wxString defaultValue = "";
|
||||||
wxString defaultValueOfOtherVariant = ""; // Legacy.
|
wxString defaultValueOfOtherVariant = ""; // Legacy (don't remove).
|
||||||
wxString description = "";
|
wxString description = "";
|
||||||
bool isInstanceParam = false;
|
bool isInstanceParam = false;
|
||||||
};
|
};
|
||||||
|
@ -352,16 +371,22 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static TYPE ReadTypeFromFields( const std::vector<T>& aFields );
|
static TYPE ReadTypeFromFields( const std::vector<T>& aFields );
|
||||||
|
|
||||||
|
static TYPE InferTypeFromRef( const wxString& aRef );
|
||||||
|
|
||||||
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, int aSymbolPinCount = 0 );
|
template <typename T>
|
||||||
|
static TYPE InferTypeFromLegacyFields( const std::vector<T>& aFields );
|
||||||
|
|
||||||
|
|
||||||
|
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, unsigned aSymbolPinCount = 0 );
|
||||||
static std::unique_ptr<SIM_MODEL> Create( const std::string& aSpiceCode );
|
static std::unique_ptr<SIM_MODEL> Create( const std::string& aSpiceCode );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL& aBaseModel, int aSymbolPinCount,
|
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL& aBaseModel, unsigned aSymbolPinCount,
|
||||||
const std::vector<T>& aFields );
|
const std::vector<T>& aFields );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static std::unique_ptr<SIM_MODEL> Create( int aSymbolPinCount, const std::vector<T>& aFields );
|
static std::unique_ptr<SIM_MODEL> Create( unsigned aSymbolPinCount,
|
||||||
|
const std::vector<T>& aFields );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static wxString GetFieldValue( const std::vector<T>* aFields, const wxString& aFieldName );
|
static wxString GetFieldValue( const std::vector<T>* aFields, const wxString& aFieldName );
|
||||||
|
@ -383,19 +408,19 @@ public:
|
||||||
virtual bool ReadSpiceCode( const std::string& aSpiceCode );
|
virtual bool ReadSpiceCode( const std::string& aSpiceCode );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ReadDataFields( int aSymbolPinCount, const std::vector<T>* aFields );
|
void ReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
||||||
// C++ doesn't allow virtual template methods, so we do this:
|
// C++ doesn't allow virtual template methods, so we do this:
|
||||||
virtual void ReadDataSchFields( int aSymbolPinCount, const std::vector<SCH_FIELD>* aFields );
|
virtual void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields );
|
||||||
virtual void ReadDataLibFields( int aSymbolPinCount, const std::vector<LIB_FIELD>* aFields );
|
virtual void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields );
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void WriteFields( std::vector<T>& aFields );
|
void WriteFields( std::vector<T>& aFields ) const;
|
||||||
|
|
||||||
// C++ doesn't allow virtual template methods, so we do this:
|
// C++ doesn't allow virtual template methods, so we do this:
|
||||||
virtual void WriteDataSchFields( std::vector<SCH_FIELD>& aFields );
|
virtual void WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const;
|
||||||
virtual void WriteDataLibFields( std::vector<LIB_FIELD>& aFields );
|
virtual void WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const;
|
||||||
|
|
||||||
|
|
||||||
virtual bool HasToIncludeSpiceLibrary() const { return GetBaseModel() && !HasOverrides(); }
|
virtual bool HasToIncludeSpiceLibrary() const { return GetBaseModel() && !HasOverrides(); }
|
||||||
|
@ -415,10 +440,8 @@ public:
|
||||||
SPICE_INFO GetSpiceInfo() const;
|
SPICE_INFO GetSpiceInfo() const;
|
||||||
virtual std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const;
|
virtual std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const;
|
||||||
|
|
||||||
bool ParsePinsField( int aSymbolPinCount, const wxString& aPinsField );
|
|
||||||
|
|
||||||
void AddPin( const PIN& aPin );
|
void AddPin( const PIN& aPin );
|
||||||
int FindModelPinNumber( int aSymbolPinNumber );
|
unsigned FindModelPinNumber( unsigned aSymbolPinNumber );
|
||||||
void AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant = false );
|
void AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant = false );
|
||||||
|
|
||||||
DEVICE_TYPE GetDeviceType() const { return TypeInfo( GetType() ).deviceType; }
|
DEVICE_TYPE GetDeviceType() const { return TypeInfo( GetType() ).deviceType; }
|
||||||
|
@ -427,8 +450,10 @@ public:
|
||||||
const SIM_MODEL* GetBaseModel() const { return m_baseModel; }
|
const SIM_MODEL* GetBaseModel() const { return m_baseModel; }
|
||||||
virtual void SetBaseModel( const SIM_MODEL& aBaseModel ) { m_baseModel = &aBaseModel; }
|
virtual void SetBaseModel( const SIM_MODEL& aBaseModel ) { m_baseModel = &aBaseModel; }
|
||||||
|
|
||||||
int GetPinCount() const { return static_cast<int>( m_pins.size() ); }
|
unsigned GetPinCount() const { return m_pins.size(); }
|
||||||
const PIN& GetPin( int aIndex ) const { return m_pins.at( aIndex ); }
|
const PIN& GetPin( unsigned aIndex ) const { return m_pins.at( aIndex ); }
|
||||||
|
|
||||||
|
std::vector<std::reference_wrapper<const PIN>> GetPins() const;
|
||||||
|
|
||||||
void SetPinSymbolPinNumber( int aIndex, int aSymbolPinNumber )
|
void SetPinSymbolPinNumber( int aIndex, int aSymbolPinNumber )
|
||||||
{
|
{
|
||||||
|
@ -436,11 +461,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GetParamCount() const { return static_cast<int>( m_params.size() ); }
|
unsigned GetParamCount() const { return m_params.size(); }
|
||||||
const PARAM& GetParam( int aParamIndex ) const; // Return base parameter unless it's overridden.
|
const PARAM& GetParam( unsigned aParamIndex ) const; // Return base parameter unless it's overridden.
|
||||||
const PARAM& GetUnderlyingParam( int aParamIndex ) const; // Return the actual parameter.
|
|
||||||
const PARAM& GetBaseParam( int aParamIndex ) const; // Always return base parameter if it exists.
|
std::vector<std::reference_wrapper<const PARAM>> GetParams() const;
|
||||||
virtual bool SetParamValue( int aParamIndex, const wxString& aValue,
|
|
||||||
|
const PARAM& GetUnderlyingParam( unsigned aParamIndex ) const; // Return the actual parameter.
|
||||||
|
const PARAM& GetBaseParam( unsigned aParamIndex ) const; // Always return base parameter if it exists.
|
||||||
|
virtual bool SetParamValue( unsigned aParamIndex, const wxString& aValue,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
||||||
= SIM_VALUE_GRAMMAR::NOTATION::SI );
|
= SIM_VALUE_GRAMMAR::NOTATION::SI );
|
||||||
|
|
||||||
|
@ -450,10 +478,28 @@ public:
|
||||||
// Can modifying a model parameter also modify other parameters?
|
// Can modifying a model parameter also modify other parameters?
|
||||||
virtual bool HasAutofill() const { return false; }
|
virtual bool HasAutofill() const { return false; }
|
||||||
|
|
||||||
|
wxString GetErrorMessage() { return m_errorMessage; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SIM_MODEL( TYPE aType );
|
SIM_MODEL( TYPE aType );
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void WriteInferredDataFields( std::vector<T>& aFields, const wxString& aValue ) const;
|
||||||
|
|
||||||
|
virtual wxString GenerateParamValuePair( const PARAM& aParam, bool& aIsFirst ) const;
|
||||||
|
|
||||||
|
wxString GenerateParamsField( const wxString& aPairSeparator ) const;
|
||||||
|
bool ParseParamsField( const wxString& aParamsField );
|
||||||
|
|
||||||
|
bool ParsePinsField( unsigned aSymbolPinCount, const wxString& aPinsField );
|
||||||
|
|
||||||
|
// TODO: Rename.
|
||||||
|
virtual bool SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
||||||
|
= SIM_VALUE_GRAMMAR::NOTATION::SPICE );
|
||||||
|
|
||||||
wxString m_spiceCode;
|
wxString m_spiceCode;
|
||||||
|
wxString m_errorMessage;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<SIM_MODEL> create( TYPE aType );
|
static std::unique_ptr<SIM_MODEL> create( TYPE aType );
|
||||||
|
@ -461,10 +507,10 @@ private:
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void doReadDataFields( int aSymbolPinCount, const std::vector<T>* aFields );
|
void doReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void doWriteFields( std::vector<T>& aFields );
|
void doWriteFields( std::vector<T>& aFields ) const;
|
||||||
|
|
||||||
|
|
||||||
virtual std::vector<wxString> getPinNames() const { return {}; }
|
virtual std::vector<wxString> getPinNames() const { return {}; }
|
||||||
|
@ -474,15 +520,6 @@ private:
|
||||||
|
|
||||||
wxString generatePinsField() const;
|
wxString generatePinsField() const;
|
||||||
|
|
||||||
|
|
||||||
wxString generateParamsField( const wxString& aPairSeparator ) const;
|
|
||||||
bool parseParamsField( const wxString& aParamsField );
|
|
||||||
|
|
||||||
// TODO: Rename.
|
|
||||||
virtual bool setParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
|
||||||
= SIM_VALUE_GRAMMAR::NOTATION::SPICE );
|
|
||||||
|
|
||||||
|
|
||||||
const SIM_MODEL* m_baseModel;
|
const SIM_MODEL* m_baseModel;
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
SIM_MODEL_BEHAVIORAL::SIM_MODEL_BEHAVIORAL( TYPE aType )
|
SIM_MODEL_BEHAVIORAL::SIM_MODEL_BEHAVIORAL( TYPE aType )
|
||||||
: SIM_MODEL( aType )
|
: SIM_MODEL( aType )
|
||||||
{
|
{
|
||||||
static PARAM::INFO resistor = makeParamInfo( "r", "Expression for resistance", "ohm" );
|
static PARAM::INFO resistor = makeParams( "r", "Expression for resistance", "ohm" );
|
||||||
static PARAM::INFO capacitor = makeParamInfo( "c", "Expression for capacitance", "F" );
|
static PARAM::INFO capacitor = makeParams( "c", "Expression for capacitance", "F" );
|
||||||
static PARAM::INFO inductor = makeParamInfo( "l", "Expression for inductance", "H" );
|
static PARAM::INFO inductor = makeParams( "l", "Expression for inductance", "H" );
|
||||||
static PARAM::INFO vsource = makeParamInfo( "v", "Expression for voltage", "V" );
|
static PARAM::INFO vsource = makeParams( "v", "Expression for voltage", "V" );
|
||||||
static PARAM::INFO isource = makeParamInfo( "i", "Expression for current", "A" );
|
static PARAM::INFO isource = makeParams( "i", "Expression for current", "A" );
|
||||||
|
|
||||||
switch( aType )
|
switch( aType )
|
||||||
{
|
{
|
||||||
|
@ -84,16 +84,16 @@ wxString SIM_MODEL_BEHAVIORAL::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIM_MODEL::PARAM::INFO SIM_MODEL_BEHAVIORAL::makeParamInfo( wxString name, wxString description,
|
SIM_MODEL::PARAM::INFO SIM_MODEL_BEHAVIORAL::makeParams( wxString aName, wxString aDescription,
|
||||||
wxString unit )
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
SIM_MODEL::PARAM::INFO paramInfo = {};
|
PARAM::INFO paramInfo = {};
|
||||||
|
|
||||||
paramInfo.name = name;
|
paramInfo.name = aName;
|
||||||
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
paramInfo.unit = unit;
|
paramInfo.unit = aUnit;
|
||||||
paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
|
paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
|
||||||
paramInfo.description = description;
|
paramInfo.description = aDescription;
|
||||||
|
|
||||||
return paramInfo;
|
return paramInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
private:
|
private:
|
||||||
std::vector<wxString> getPinNames() const override { return { "+", "-" }; }
|
std::vector<wxString> getPinNames() const override { return { "+", "-" }; }
|
||||||
|
|
||||||
static PARAM::INFO makeParamInfo( wxString name, wxString description, wxString unit );
|
static PARAM::INFO makeParams( wxString aName, wxString aDescription, wxString aUnit );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIM_MODEL_BEHAVIORAL_H
|
#endif // SIM_MODEL_BEHAVIORAL_H
|
||||||
|
|
|
@ -28,7 +28,8 @@ using PARAM = SIM_MODEL::PARAM;
|
||||||
|
|
||||||
|
|
||||||
SIM_MODEL_IDEAL::SIM_MODEL_IDEAL( TYPE aType )
|
SIM_MODEL_IDEAL::SIM_MODEL_IDEAL( TYPE aType )
|
||||||
: SIM_MODEL( aType )
|
: SIM_MODEL( aType ),
|
||||||
|
m_isInferred( false )
|
||||||
{
|
{
|
||||||
static PARAM::INFO resistor = makeParamInfo( "r", "Resistance", "ohm" );
|
static PARAM::INFO resistor = makeParamInfo( "r", "Resistance", "ohm" );
|
||||||
static PARAM::INFO capacitor = makeParamInfo( "c", "Capacitance", "F" );
|
static PARAM::INFO capacitor = makeParamInfo( "c", "Capacitance", "F" );
|
||||||
|
@ -36,40 +37,50 @@ SIM_MODEL_IDEAL::SIM_MODEL_IDEAL( TYPE aType )
|
||||||
|
|
||||||
switch( aType )
|
switch( aType )
|
||||||
{
|
{
|
||||||
case TYPE::R: AddParam( resistor ); break;
|
case TYPE::R: AddParam( resistor ); break;
|
||||||
case TYPE::C: AddParam( capacitor ); break;
|
case TYPE::C: AddParam( capacitor ); break;
|
||||||
case TYPE::L: AddParam( inductor ); break;
|
case TYPE::L: AddParam( inductor ); break;
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_IDEAL" );
|
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_IDEAL" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL_IDEAL::ReadDataSchFields( int aSymbolPinCount,
|
void SIM_MODEL_IDEAL::ReadDataSchFields( unsigned aSymbolPinCount,
|
||||||
const std::vector<SCH_FIELD>* aFields )
|
const std::vector<SCH_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
||||||
SIM_MODEL::ReadDataSchFields( aSymbolPinCount, aFields );
|
SIM_MODEL::ReadDataSchFields( aSymbolPinCount, aFields );
|
||||||
else
|
else
|
||||||
{
|
inferredReadDataFields( aSymbolPinCount, aFields );
|
||||||
// Inferred model.
|
|
||||||
ParsePinsField( aSymbolPinCount, PINS_FIELD );
|
|
||||||
SetParamValue( 0, GetFieldValue( aFields, VALUE_FIELD ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL_IDEAL::ReadDataLibFields( int aSymbolPinCount,
|
void SIM_MODEL_IDEAL::ReadDataLibFields( unsigned aSymbolPinCount,
|
||||||
const std::vector<LIB_FIELD>* aFields )
|
const std::vector<LIB_FIELD>* aFields )
|
||||||
{
|
{
|
||||||
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
||||||
SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields );
|
SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields );
|
||||||
else
|
else
|
||||||
{
|
inferredReadDataFields( aSymbolPinCount, aFields );
|
||||||
// Inferred model.
|
}
|
||||||
ParsePinsField( aSymbolPinCount, PINS_FIELD );
|
|
||||||
SetParamValue( 0, GetFieldValue( aFields, VALUE_FIELD ) );
|
|
||||||
}
|
void SIM_MODEL_IDEAL::WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataSchFields( aFields );
|
||||||
|
|
||||||
|
if( m_isInferred )
|
||||||
|
inferredWriteDataFields( aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_IDEAL::WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataLibFields( aFields );
|
||||||
|
|
||||||
|
if( m_isInferred )
|
||||||
|
inferredWriteDataFields( aFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,11 +94,38 @@ wxString SIM_MODEL_IDEAL::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
const wxString& aModelName,
|
const wxString& aModelName,
|
||||||
const std::vector<wxString>& aPinNetNames ) const
|
const std::vector<wxString>& aPinNetNames ) const
|
||||||
{
|
{
|
||||||
return SIM_MODEL::GenerateSpiceItemLine( aRefName, GetParam( 0 ).value->ToString(),
|
return SIM_MODEL::GenerateSpiceItemLine( aRefName,
|
||||||
|
GetParam( 0 ).value->ToString( SIM_VALUE::NOTATION::SPICE ),
|
||||||
aPinNetNames );
|
aPinNetNames );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL_IDEAL::inferredReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields )
|
||||||
|
{
|
||||||
|
ParsePinsField( aSymbolPinCount, PINS_FIELD );
|
||||||
|
|
||||||
|
if( ( InferTypeFromRef( GetFieldValue( aFields, REFERENCE_FIELD ) ) == GetType()
|
||||||
|
&& SetParamValue( 0, GetFieldValue( aFields, VALUE_FIELD ) ) )
|
||||||
|
|| GetFieldValue( aFields, VALUE_FIELD ) == DeviceTypeInfo( GetDeviceType() ).fieldValue )
|
||||||
|
{
|
||||||
|
m_isInferred = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL_IDEAL::inferredWriteDataFields( std::vector<T>& aFields ) const
|
||||||
|
{
|
||||||
|
wxString value = GetParam( 0 ).value->ToString();
|
||||||
|
|
||||||
|
if( value.IsEmpty() )
|
||||||
|
value = DeviceTypeInfo( GetDeviceType() ).fieldValue;
|
||||||
|
|
||||||
|
WriteInferredDataFields( aFields, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PARAM::INFO SIM_MODEL_IDEAL::makeParamInfo( wxString aName, wxString aDescription, wxString aUnit )
|
PARAM::INFO SIM_MODEL_IDEAL::makeParamInfo( wxString aName, wxString aDescription, wxString aUnit )
|
||||||
{
|
{
|
||||||
SIM_MODEL::PARAM::INFO paramInfo = {};
|
SIM_MODEL::PARAM::INFO paramInfo = {};
|
||||||
|
|
|
@ -33,8 +33,11 @@ class SIM_MODEL_IDEAL : public SIM_MODEL
|
||||||
public:
|
public:
|
||||||
SIM_MODEL_IDEAL( TYPE aType );
|
SIM_MODEL_IDEAL( TYPE aType );
|
||||||
|
|
||||||
void ReadDataSchFields( int aSymbolPinCount, const std::vector<SCH_FIELD>* aFields ) override;
|
void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields ) override;
|
||||||
void ReadDataLibFields( int aSymbolPinCount, const std::vector<LIB_FIELD>* aFields ) override;
|
void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields ) override;
|
||||||
|
|
||||||
|
void WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const override;
|
||||||
|
void WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const override;
|
||||||
|
|
||||||
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
||||||
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
|
@ -43,9 +46,17 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
template <typename T>
|
||||||
|
void inferredReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void inferredWriteDataFields( std::vector<T>& aFields ) const;
|
||||||
|
|
||||||
std::vector<wxString> getPinNames() const override { return { "+", "-" }; }
|
std::vector<wxString> getPinNames() const override { return { "+", "-" }; }
|
||||||
|
|
||||||
static PARAM::INFO makeParamInfo( wxString aName, wxString aDescription, wxString aUnit );
|
static PARAM::INFO makeParamInfo( wxString aName, wxString aDescription, wxString aUnit );
|
||||||
|
|
||||||
|
bool m_isInferred;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIM_MODEL_IDEAL_H
|
#endif // SIM_MODEL_IDEAL_H
|
||||||
|
|
|
@ -36,8 +36,8 @@ SIM_MODEL_NGSPICE::SIM_MODEL_NGSPICE( TYPE aType )
|
||||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams )
|
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams )
|
||||||
AddParam( paramInfo, getIsOtherVariant() );
|
AddParam( paramInfo, getIsOtherVariant() );
|
||||||
|
|
||||||
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.instanceParams )
|
/*for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.instanceParams )
|
||||||
AddParam( paramInfo, getIsOtherVariant() );
|
AddParam( paramInfo, getIsOtherVariant() );*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,6 +76,52 @@ std::vector<wxString> SIM_MODEL_NGSPICE::GenerateSpiceCurrentNames( const wxStri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL_NGSPICE::SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
|
{
|
||||||
|
// One Spice param can have multiple names, we need to take this into account.
|
||||||
|
|
||||||
|
std::vector<std::reference_wrapper<const PARAM>> params = GetParams();
|
||||||
|
|
||||||
|
auto paramIt = std::find_if( params.begin(), params.end(),
|
||||||
|
[aParamName]( const PARAM& param )
|
||||||
|
{
|
||||||
|
return param.info.category != PARAM::CATEGORY::SUPERFLUOUS
|
||||||
|
&& param.info.name == aParamName.Lower();
|
||||||
|
} );
|
||||||
|
|
||||||
|
if( paramIt != params.end() )
|
||||||
|
return SetParamValue( paramIt - params.begin(), aParamValue, aNotation );
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<PARAM::INFO> ngspiceParams = NGSPICE::ModelInfo( getModelType() ).modelParams;
|
||||||
|
|
||||||
|
auto ngspiceParamIt = std::find_if( ngspiceParams.begin(), ngspiceParams.end(),
|
||||||
|
[aParamName]( const PARAM& param )
|
||||||
|
{
|
||||||
|
return param.info.name == aParamName.Lower();
|
||||||
|
} );
|
||||||
|
|
||||||
|
if( ngspiceParamIt == ngspiceParams.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// We obtain the id of the Ngspice param that is to be set.
|
||||||
|
unsigned id = ngspiceParamIt->id;
|
||||||
|
|
||||||
|
// Find an actual parameter with the same id.
|
||||||
|
paramIt = std::find_if( params.begin(), params.end(),
|
||||||
|
[id]( const PARAM& param )
|
||||||
|
{
|
||||||
|
return param.info.id == id;
|
||||||
|
} );
|
||||||
|
|
||||||
|
if( paramIt == params.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SetParamValue( paramIt - params.begin(), aParamValue, aNotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<wxString> SIM_MODEL_NGSPICE::getPinNames() const
|
std::vector<wxString> SIM_MODEL_NGSPICE::getPinNames() const
|
||||||
{
|
{
|
||||||
return NGSPICE::ModelInfo( getModelType() ).pinNames;
|
return NGSPICE::ModelInfo( getModelType() ).pinNames;
|
||||||
|
@ -86,24 +132,24 @@ NGSPICE::MODEL_TYPE SIM_MODEL_NGSPICE::getModelType() const
|
||||||
{
|
{
|
||||||
switch( GetType() )
|
switch( GetType() )
|
||||||
{
|
{
|
||||||
case TYPE::NONE: return NGSPICE::MODEL_TYPE::NONE;
|
case TYPE::NONE: return NGSPICE::MODEL_TYPE::NONE;
|
||||||
case TYPE::R_ADV: return NGSPICE::MODEL_TYPE::RESISTOR;
|
//case TYPE::R_ADV: return NGSPICE::MODEL_TYPE::RESISTOR;
|
||||||
case TYPE::C_ADV: return NGSPICE::MODEL_TYPE::CAPACITOR;
|
//case TYPE::C_ADV: return NGSPICE::MODEL_TYPE::CAPACITOR;
|
||||||
case TYPE::L_ADV: return NGSPICE::MODEL_TYPE::INDUCTOR;
|
//case TYPE::L_ADV: return NGSPICE::MODEL_TYPE::INDUCTOR;
|
||||||
case TYPE::TLINE_LOSSY: return NGSPICE::MODEL_TYPE::LTRA;
|
case TYPE::TLINE_LOSSY: return NGSPICE::MODEL_TYPE::LTRA;
|
||||||
case TYPE::TLINE_LOSSLESS: return NGSPICE::MODEL_TYPE::TRANLINE;
|
case TYPE::TLINE_LOSSLESS: return NGSPICE::MODEL_TYPE::TRANLINE;
|
||||||
case TYPE::TLINE_URC: return NGSPICE::MODEL_TYPE::URC;
|
case TYPE::TLINE_URC: return NGSPICE::MODEL_TYPE::URC;
|
||||||
//case TYPE::TLINE_KSPICE: return NGSPICE::MODEL_TYPE::TRANSLINE;
|
//case TYPE::TLINE_KSPICE: return NGSPICE::MODEL_TYPE::TRANSLINE;
|
||||||
case TYPE::SW_V: return NGSPICE::MODEL_TYPE::SWITCH;
|
case TYPE::SW_V: return NGSPICE::MODEL_TYPE::SWITCH;
|
||||||
case TYPE::SW_I: return NGSPICE::MODEL_TYPE::CSWITCH;
|
case TYPE::SW_I: return NGSPICE::MODEL_TYPE::CSWITCH;
|
||||||
case TYPE::D: return NGSPICE::MODEL_TYPE::DIODE;
|
case TYPE::D: return NGSPICE::MODEL_TYPE::DIODE;
|
||||||
|
|
||||||
case TYPE::NPN_GUMMELPOON:
|
case TYPE::NPN_GUMMELPOON:
|
||||||
case TYPE::PNP_GUMMELPOON: return NGSPICE::MODEL_TYPE::BJT;
|
case TYPE::PNP_GUMMELPOON: return NGSPICE::MODEL_TYPE::BJT;
|
||||||
case TYPE::NPN_VBIC:
|
case TYPE::NPN_VBIC:
|
||||||
case TYPE::PNP_VBIC: return NGSPICE::MODEL_TYPE::VBIC;
|
case TYPE::PNP_VBIC: return NGSPICE::MODEL_TYPE::VBIC;
|
||||||
case TYPE::NPN_HICUML2:
|
case TYPE::NPN_HICUML2:
|
||||||
case TYPE::PNP_HICUML2: return NGSPICE::MODEL_TYPE::HICUM2;
|
case TYPE::PNP_HICUML2: return NGSPICE::MODEL_TYPE::HICUM2;
|
||||||
|
|
||||||
case TYPE::NJFET_SHICHMANHODGES:
|
case TYPE::NJFET_SHICHMANHODGES:
|
||||||
case TYPE::PJFET_SHICHMANHODGES: return NGSPICE::MODEL_TYPE::JFET;
|
case TYPE::PJFET_SHICHMANHODGES: return NGSPICE::MODEL_TYPE::JFET;
|
||||||
|
@ -111,46 +157,46 @@ NGSPICE::MODEL_TYPE SIM_MODEL_NGSPICE::getModelType() const
|
||||||
case TYPE::PJFET_PARKERSKELLERN: return NGSPICE::MODEL_TYPE::JFET2;
|
case TYPE::PJFET_PARKERSKELLERN: return NGSPICE::MODEL_TYPE::JFET2;
|
||||||
|
|
||||||
case TYPE::NMES_STATZ:
|
case TYPE::NMES_STATZ:
|
||||||
case TYPE::PMES_STATZ: return NGSPICE::MODEL_TYPE::MES;
|
case TYPE::PMES_STATZ: return NGSPICE::MODEL_TYPE::MES;
|
||||||
case TYPE::NMES_YTTERDAL:
|
case TYPE::NMES_YTTERDAL:
|
||||||
case TYPE::PMES_YTTERDAL: return NGSPICE::MODEL_TYPE::MESA;
|
case TYPE::PMES_YTTERDAL: return NGSPICE::MODEL_TYPE::MESA;
|
||||||
case TYPE::NMES_HFET1:
|
case TYPE::NMES_HFET1:
|
||||||
case TYPE::PMES_HFET1: return NGSPICE::MODEL_TYPE::HFET1;
|
case TYPE::PMES_HFET1: return NGSPICE::MODEL_TYPE::HFET1;
|
||||||
case TYPE::PMES_HFET2:
|
case TYPE::PMES_HFET2:
|
||||||
case TYPE::NMES_HFET2: return NGSPICE::MODEL_TYPE::HFET2;
|
case TYPE::NMES_HFET2: return NGSPICE::MODEL_TYPE::HFET2;
|
||||||
|
|
||||||
case TYPE::NMOS_MOS1:
|
case TYPE::NMOS_MOS1:
|
||||||
case TYPE::PMOS_MOS1: return NGSPICE::MODEL_TYPE::MOS1;
|
case TYPE::PMOS_MOS1: return NGSPICE::MODEL_TYPE::MOS1;
|
||||||
case TYPE::NMOS_MOS2:
|
case TYPE::NMOS_MOS2:
|
||||||
case TYPE::PMOS_MOS2: return NGSPICE::MODEL_TYPE::MOS2;
|
case TYPE::PMOS_MOS2: return NGSPICE::MODEL_TYPE::MOS2;
|
||||||
case TYPE::NMOS_MOS3:
|
case TYPE::NMOS_MOS3:
|
||||||
case TYPE::PMOS_MOS3: return NGSPICE::MODEL_TYPE::MOS3;
|
case TYPE::PMOS_MOS3: return NGSPICE::MODEL_TYPE::MOS3;
|
||||||
case TYPE::NMOS_BSIM1:
|
case TYPE::NMOS_BSIM1:
|
||||||
case TYPE::PMOS_BSIM1: return NGSPICE::MODEL_TYPE::BSIM1;
|
case TYPE::PMOS_BSIM1: return NGSPICE::MODEL_TYPE::BSIM1;
|
||||||
case TYPE::NMOS_BSIM2:
|
case TYPE::NMOS_BSIM2:
|
||||||
case TYPE::PMOS_BSIM2: return NGSPICE::MODEL_TYPE::BSIM2;
|
case TYPE::PMOS_BSIM2: return NGSPICE::MODEL_TYPE::BSIM2;
|
||||||
case TYPE::NMOS_MOS6:
|
case TYPE::NMOS_MOS6:
|
||||||
case TYPE::PMOS_MOS6: return NGSPICE::MODEL_TYPE::MOS6;
|
case TYPE::PMOS_MOS6: return NGSPICE::MODEL_TYPE::MOS6;
|
||||||
case TYPE::NMOS_BSIM3:
|
case TYPE::NMOS_BSIM3:
|
||||||
case TYPE::PMOS_BSIM3: return NGSPICE::MODEL_TYPE::BSIM3;
|
case TYPE::PMOS_BSIM3: return NGSPICE::MODEL_TYPE::BSIM3;
|
||||||
case TYPE::NMOS_MOS9:
|
case TYPE::NMOS_MOS9:
|
||||||
case TYPE::PMOS_MOS9: return NGSPICE::MODEL_TYPE::MOS9;
|
case TYPE::PMOS_MOS9: return NGSPICE::MODEL_TYPE::MOS9;
|
||||||
case TYPE::NMOS_B4SOI:
|
case TYPE::NMOS_B4SOI:
|
||||||
case TYPE::PMOS_B4SOI: return NGSPICE::MODEL_TYPE::B4SOI;
|
case TYPE::PMOS_B4SOI: return NGSPICE::MODEL_TYPE::B4SOI;
|
||||||
case TYPE::NMOS_BSIM4:
|
case TYPE::NMOS_BSIM4:
|
||||||
case TYPE::PMOS_BSIM4: return NGSPICE::MODEL_TYPE::BSIM4;
|
case TYPE::PMOS_BSIM4: return NGSPICE::MODEL_TYPE::BSIM4;
|
||||||
case TYPE::NMOS_B3SOIFD:
|
case TYPE::NMOS_B3SOIFD:
|
||||||
case TYPE::PMOS_B3SOIFD: return NGSPICE::MODEL_TYPE::B3SOIFD;
|
case TYPE::PMOS_B3SOIFD: return NGSPICE::MODEL_TYPE::B3SOIFD;
|
||||||
case TYPE::NMOS_B3SOIDD:
|
case TYPE::NMOS_B3SOIDD:
|
||||||
case TYPE::PMOS_B3SOIDD: return NGSPICE::MODEL_TYPE::B3SOIDD;
|
case TYPE::PMOS_B3SOIDD: return NGSPICE::MODEL_TYPE::B3SOIDD;
|
||||||
case TYPE::NMOS_B3SOIPD:
|
case TYPE::NMOS_B3SOIPD:
|
||||||
case TYPE::PMOS_B3SOIPD: return NGSPICE::MODEL_TYPE::B3SOIPD;
|
case TYPE::PMOS_B3SOIPD: return NGSPICE::MODEL_TYPE::B3SOIPD;
|
||||||
case TYPE::NMOS_HISIM2:
|
case TYPE::NMOS_HISIM2:
|
||||||
case TYPE::PMOS_HISIM2: return NGSPICE::MODEL_TYPE::HISIM2;
|
case TYPE::PMOS_HISIM2: return NGSPICE::MODEL_TYPE::HISIM2;
|
||||||
case TYPE::NMOS_HISIMHV1:
|
case TYPE::NMOS_HISIMHV1:
|
||||||
case TYPE::PMOS_HISIMHV1: return NGSPICE::MODEL_TYPE::HISIMHV1;
|
case TYPE::PMOS_HISIMHV1: return NGSPICE::MODEL_TYPE::HISIMHV1;
|
||||||
case TYPE::NMOS_HISIMHV2:
|
case TYPE::NMOS_HISIMHV2:
|
||||||
case TYPE::PMOS_HISIMHV2: return NGSPICE::MODEL_TYPE::HISIMHV2;
|
case TYPE::PMOS_HISIMHV2: return NGSPICE::MODEL_TYPE::HISIMHV2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_NGSPICE" );
|
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_NGSPICE" );
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
|
|
||||||
std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const override;
|
std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const override;
|
||||||
|
|
||||||
|
bool SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<wxString> getPinNames() const override;
|
std::vector<wxString> getPinNames() const override;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,206 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Mikolaj Wielgus
|
||||||
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sim/sim_model_passive.h>
|
||||||
|
|
||||||
|
using PARAM = SIM_MODEL::PARAM;
|
||||||
|
|
||||||
|
|
||||||
|
SIM_MODEL_PASSIVE::SIM_MODEL_PASSIVE( TYPE aType )
|
||||||
|
: SIM_MODEL( aType )
|
||||||
|
{
|
||||||
|
static std::vector<PARAM::INFO> resistor = makeParamInfos( "r", "Resistance", "ohm" );
|
||||||
|
static std::vector<PARAM::INFO> capacitor = makeParamInfos( "c", "Capacitance", "F" );
|
||||||
|
static std::vector<PARAM::INFO> inductor = makeParamInfos( "l", "Inductance", "H" );
|
||||||
|
|
||||||
|
switch( aType )
|
||||||
|
{
|
||||||
|
case TYPE::R_ADV:
|
||||||
|
for( const PARAM::INFO& paramInfo : resistor )
|
||||||
|
AddParam( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE::C_ADV:
|
||||||
|
for( const PARAM::INFO& paramInfo : capacitor )
|
||||||
|
AddParam( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE::L_ADV:
|
||||||
|
for( const PARAM::INFO& paramInfo : inductor )
|
||||||
|
AddParam( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( "Unhandled SIM_MODEL type in SIM_MODEL_PASSIVE" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL_PASSIVE::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
|
const wxString& aModelName,
|
||||||
|
const std::vector<wxString>& aPinNetNames ) const
|
||||||
|
{
|
||||||
|
wxString result = "";
|
||||||
|
result << GenerateSpiceItemName( aRefName ) << " ";
|
||||||
|
|
||||||
|
for( const PIN& pin : GetPins() )
|
||||||
|
{
|
||||||
|
for( unsigned i = 0; i < aPinNetNames.size(); ++i )
|
||||||
|
{
|
||||||
|
unsigned symbolPinNumber = i + 1;
|
||||||
|
|
||||||
|
if( symbolPinNumber == pin.symbolPinNumber )
|
||||||
|
result << aPinNetNames[i] << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The model name is preceded by the principal value for resistors.
|
||||||
|
//if( GetType() == TYPE::R_ADV )
|
||||||
|
//result << GetParam( 0 ).value->ToString( SIM_VALUE::NOTATION::SPICE ) << " ";
|
||||||
|
|
||||||
|
result << aModelName << " ";
|
||||||
|
|
||||||
|
for( const PARAM& param : GetParams() )
|
||||||
|
{
|
||||||
|
if( param.info.isInstanceParam )
|
||||||
|
result << param.info.name << "=" << param.value->ToString() << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
result << "\n";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL_PASSIVE::SetParamFromSpiceCode( const wxString& aParamName,
|
||||||
|
const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
|
{
|
||||||
|
if( aParamName.Lower() == "tc" )
|
||||||
|
return SetParamFromSpiceCode( "tc1", aParamValue, aNotation );
|
||||||
|
|
||||||
|
switch( GetType() )
|
||||||
|
{
|
||||||
|
case TYPE::R_ADV:
|
||||||
|
if( aParamName.Lower() == "tc1r" )
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( "tc1", aParamValue, aNotation );
|
||||||
|
|
||||||
|
if( aParamName.Lower() == "tc2r" )
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( "tc2", aParamValue, aNotation );
|
||||||
|
|
||||||
|
if( aParamName.Lower() == "res" )
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( "r", aParamValue, aNotation );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE::C_ADV:
|
||||||
|
if( aParamName.Lower() == "cap" )
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( "c", aParamValue, aNotation );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE::L_ADV:
|
||||||
|
if( aParamName.Lower() == "ind" )
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( "l", aParamValue, aNotation );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SIM_MODEL::SetParamFromSpiceCode( aParamName, aParamValue, aNotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<PARAM::INFO> SIM_MODEL_PASSIVE::makeParamInfos( wxString aName,
|
||||||
|
wxString aDescription,
|
||||||
|
wxString aUnit )
|
||||||
|
{
|
||||||
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
|
PARAM::INFO paramInfo = {};
|
||||||
|
|
||||||
|
paramInfo.name = aName;
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = aUnit;
|
||||||
|
paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
|
||||||
|
paramInfo.defaultValue = "";
|
||||||
|
paramInfo.description = aDescription;
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "temp";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = "deg C";
|
||||||
|
paramInfo.category = PARAM::CATEGORY::PRINCIPAL;
|
||||||
|
paramInfo.defaultValue = "27";
|
||||||
|
paramInfo.description = "Temperature";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "tnom";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = "deg C";
|
||||||
|
paramInfo.category = PARAM::CATEGORY::TEMPERATURE;
|
||||||
|
paramInfo.defaultValue = "27";
|
||||||
|
paramInfo.description = "Nominal temperature";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "tc1";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = aUnit;
|
||||||
|
paramInfo.category = PARAM::CATEGORY::TEMPERATURE;
|
||||||
|
paramInfo.defaultValue = "0";
|
||||||
|
paramInfo.description = "1st order temperature coefficient";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "tc2";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = aUnit;
|
||||||
|
paramInfo.category = PARAM::CATEGORY::TEMPERATURE;
|
||||||
|
paramInfo.defaultValue = "0";
|
||||||
|
paramInfo.description = "2nd order temperature coefficient";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
/*if( aName != "l" )
|
||||||
|
{
|
||||||
|
paramInfo.name = "bv_max";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::FLOAT;
|
||||||
|
paramInfo.unit = aUnit;
|
||||||
|
paramInfo.category = PARAM::CATEGORY::LIMITING_VALUES;
|
||||||
|
paramInfo.defaultValue = "";
|
||||||
|
paramInfo.description = "Max. safe operating voltage";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if( aName == "r" )
|
||||||
|
{
|
||||||
|
paramInfo.name = "noisy";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::BOOL;
|
||||||
|
paramInfo.unit = "";
|
||||||
|
paramInfo.category = PARAM::CATEGORY::NOISE;
|
||||||
|
paramInfo.defaultValue = "True";
|
||||||
|
paramInfo.description = "Enable thermal noise";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
return paramInfos;
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Mikolaj Wielgus
|
||||||
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
|
*
|
||||||
|
* 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_PASSIVE_H
|
||||||
|
#define SIM_MODEL_PASSIVE_H
|
||||||
|
|
||||||
|
#include <sim/sim_model.h>
|
||||||
|
|
||||||
|
|
||||||
|
class SIM_MODEL_PASSIVE : public SIM_MODEL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SIM_MODEL_PASSIVE( TYPE aType );
|
||||||
|
|
||||||
|
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
|
const wxString& aModelName,
|
||||||
|
const std::vector<wxString>& aPinNetNames ) const override;
|
||||||
|
|
||||||
|
bool SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
||||||
|
= SIM_VALUE_GRAMMAR::NOTATION::SPICE ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::vector<PARAM::INFO> makeParamInfos( wxString aName, wxString aDescription,
|
||||||
|
wxString aUnit );
|
||||||
|
|
||||||
|
std::vector<wxString> getPinNames() const override { return { "+", "-" }; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SIM_MODEL_PASSIVE_H
|
|
@ -28,13 +28,52 @@ using PARAM = SIM_MODEL::PARAM;
|
||||||
|
|
||||||
|
|
||||||
SIM_MODEL_SOURCE::SIM_MODEL_SOURCE( TYPE aType )
|
SIM_MODEL_SOURCE::SIM_MODEL_SOURCE( TYPE aType )
|
||||||
: SIM_MODEL( aType )
|
: SIM_MODEL( aType ),
|
||||||
|
m_isInferred( false )
|
||||||
{
|
{
|
||||||
for( const PARAM::INFO& paramInfo : makeParams( aType ) )
|
for( const PARAM::INFO& paramInfo : makeParamInfos( aType ) )
|
||||||
AddParam( paramInfo );
|
AddParam( paramInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SOURCE::ReadDataSchFields( unsigned aSymbolPinCount,
|
||||||
|
const std::vector<SCH_FIELD>* aFields )
|
||||||
|
{
|
||||||
|
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
||||||
|
SIM_MODEL::ReadDataSchFields( aSymbolPinCount, aFields );
|
||||||
|
else
|
||||||
|
inferredReadDataFields( aSymbolPinCount, aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SOURCE::ReadDataLibFields( unsigned aSymbolPinCount,
|
||||||
|
const std::vector<LIB_FIELD>* aFields )
|
||||||
|
{
|
||||||
|
if( !GetFieldValue( aFields, PARAMS_FIELD ).IsEmpty() )
|
||||||
|
SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields );
|
||||||
|
else
|
||||||
|
inferredReadDataFields( aSymbolPinCount, aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SOURCE::WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataSchFields( aFields );
|
||||||
|
|
||||||
|
if( m_isInferred )
|
||||||
|
inferredWriteDataFields( aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SOURCE::WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataLibFields( aFields );
|
||||||
|
|
||||||
|
if( m_isInferred )
|
||||||
|
inferredWriteDataFields( aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SIM_MODEL_SOURCE::GenerateSpiceModelLine( const wxString& aModelName ) const
|
wxString SIM_MODEL_SOURCE::GenerateSpiceModelLine( const wxString& aModelName ) const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
@ -47,7 +86,7 @@ wxString SIM_MODEL_SOURCE::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
{
|
{
|
||||||
wxString argList = "";
|
wxString argList = "";
|
||||||
|
|
||||||
for( int i = 0; i < GetParamCount(); ++i )
|
for( unsigned i = 0; i < GetParamCount(); ++i )
|
||||||
argList << GetParam( i ).value->ToString() << " ";
|
argList << GetParam( i ).value->ToString() << " ";
|
||||||
|
|
||||||
wxString model = wxString::Format( GetSpiceInfo().inlineTypeString + "( %s)", argList );
|
wxString model = wxString::Format( GetSpiceInfo().inlineTypeString + "( %s)", argList );
|
||||||
|
@ -56,49 +95,49 @@ wxString SIM_MODEL_SOURCE::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<PARAM::INFO>& SIM_MODEL_SOURCE::makeParams( TYPE aType )
|
const std::vector<PARAM::INFO>& SIM_MODEL_SOURCE::makeParamInfos( TYPE aType )
|
||||||
{
|
{
|
||||||
static std::vector<PARAM::INFO> vdc = makeDc( "v", "V" );
|
static std::vector<PARAM::INFO> vdc = makeDcParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> idc = makeDc( "i", "A" );
|
static std::vector<PARAM::INFO> idc = makeDcParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vsin = makeSin( "v", "V" );
|
static std::vector<PARAM::INFO> vsin = makeSinParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> isin = makeSin( "i", "A" );
|
static std::vector<PARAM::INFO> isin = makeSinParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vpulse = makePulse( "v", "V" );
|
static std::vector<PARAM::INFO> vpulse = makePulseParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> ipulse = makePulse( "i", "A" );
|
static std::vector<PARAM::INFO> ipulse = makePulseParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vexp = makeExp( "v", "V" );
|
static std::vector<PARAM::INFO> vexp = makeExpParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> iexp = makeExp( "i", "A" );
|
static std::vector<PARAM::INFO> iexp = makeExpParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vsfam = makeSfam( "v", "V" );
|
static std::vector<PARAM::INFO> vsfam = makeSfamParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> isfam = makeSfam( "i", "A" );
|
static std::vector<PARAM::INFO> isfam = makeSfamParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vsffm = makeSffm( "v", "V" );
|
static std::vector<PARAM::INFO> vsffm = makeSffmParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> isffm = makeSffm( "i", "A" );
|
static std::vector<PARAM::INFO> isffm = makeSffmParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vpwl = makePwl( "v", "Voltage", "V" );
|
static std::vector<PARAM::INFO> vpwl = makePwlParamInfos( "v", "Voltage", "V" );
|
||||||
static std::vector<PARAM::INFO> ipwl = makePwl( "i", "Current", "A" );
|
static std::vector<PARAM::INFO> ipwl = makePwlParamInfos( "i", "Current", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoise( "v", "V" );
|
static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoiseParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> iwhitenoise = makeWhiteNoise( "i", "A" );
|
static std::vector<PARAM::INFO> iwhitenoise = makeWhiteNoiseParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vpinknoise = makePinkNoise( "v", "V" );
|
static std::vector<PARAM::INFO> vpinknoise = makePinkNoiseParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> ipinknoise = makePinkNoise( "i", "A" );
|
static std::vector<PARAM::INFO> ipinknoise = makePinkNoiseParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vburstnoise = makeBurstNoise( "v", "V" );
|
static std::vector<PARAM::INFO> vburstnoise = makeBurstNoiseParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> iburstnoise = makeBurstNoise( "i", "A" );
|
static std::vector<PARAM::INFO> iburstnoise = makeBurstNoiseParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vrandomuniform = makeRandomUniform( "v", "V" );
|
static std::vector<PARAM::INFO> vrandomuniform = makeRandomUniformParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> irandomuniform = makeRandomUniform( "i", "A" );
|
static std::vector<PARAM::INFO> irandomuniform = makeRandomUniformParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vrandomnormal = makeRandomNormal( "v", "V" );
|
static std::vector<PARAM::INFO> vrandomnormal = makeRandomNormalParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> irandomnormal = makeRandomNormal( "i", "A" );
|
static std::vector<PARAM::INFO> irandomnormal = makeRandomNormalParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vrandomexp = makeRandomExp( "v", "V" );
|
static std::vector<PARAM::INFO> vrandomexp = makeRandomExpParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> irandomexp = makeRandomExp( "i", "A" );
|
static std::vector<PARAM::INFO> irandomexp = makeRandomExpParamInfos( "i", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vrandompoisson = makeRandomPoisson( "v", "V" );
|
static std::vector<PARAM::INFO> vrandompoisson = makeRandomPoissonParamInfos( "v", "V" );
|
||||||
static std::vector<PARAM::INFO> irandompoisson = makeRandomPoisson( "i", "A" );
|
static std::vector<PARAM::INFO> irandompoisson = makeRandomPoissonParamInfos( "i", "A" );
|
||||||
|
|
||||||
switch( aType )
|
switch( aType )
|
||||||
{
|
{
|
||||||
|
@ -138,19 +177,19 @@ const std::vector<PARAM::INFO>& SIM_MODEL_SOURCE::makeParams( TYPE aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL_SOURCE::SetParamValue( int aParamIndex, const wxString& aValue,
|
bool SIM_MODEL_SOURCE::SetParamValue( unsigned aParamIndex, const wxString& aValue,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
{
|
{
|
||||||
// Sources are special. All preceding parameter values must be filled. If they are not, fill
|
// Sources are special. All preceding parameter values must be filled. If they are not, fill
|
||||||
// them out automatically. If a value is nulled, delete everything after it.
|
// them out automatically. If a value is nulled, delete everything after it.
|
||||||
if( aValue.IsEmpty() )
|
if( aValue.IsEmpty() )
|
||||||
{
|
{
|
||||||
for( int i = aParamIndex; i < GetParamCount(); ++i )
|
for( unsigned i = aParamIndex; i < GetParamCount(); ++i )
|
||||||
SIM_MODEL::SetParamValue( i, "", aNotation );
|
SIM_MODEL::SetParamValue( i, "", aNotation );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( int i = 0; i < aParamIndex; ++i )
|
for( unsigned i = 0; i < aParamIndex; ++i )
|
||||||
{
|
{
|
||||||
if( GetParam( i ).value->ToString().IsEmpty() )
|
if( GetParam( i ).value->ToString().IsEmpty() )
|
||||||
SIM_MODEL::SetParamValue( i, "0", aNotation );
|
SIM_MODEL::SetParamValue( i, "0", aNotation );
|
||||||
|
@ -161,13 +200,48 @@ bool SIM_MODEL_SOURCE::SetParamValue( int aParamIndex, const wxString& aValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL_SOURCE::GenerateParamValuePair( const PARAM& aParam, bool& aIsFirst ) const
|
||||||
|
{
|
||||||
|
if( aParam.value->ToString() == "0" )
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return SIM_MODEL::GenerateParamValuePair( aParam, aIsFirst );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL_SOURCE::inferredReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields )
|
||||||
|
{
|
||||||
|
ParsePinsField( aSymbolPinCount, PINS_FIELD );
|
||||||
|
|
||||||
|
if( ( InferTypeFromRef( GetFieldValue( aFields, REFERENCE_FIELD ) ) == GetType()
|
||||||
|
&& ParseParamsField( GetFieldValue( aFields, VALUE_FIELD ) ) )
|
||||||
|
|| GetFieldValue( aFields, VALUE_FIELD ) == DeviceTypeInfo( GetDeviceType() ).fieldValue )
|
||||||
|
{
|
||||||
|
m_isInferred = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL_SOURCE::inferredWriteDataFields( std::vector<T>& aFields ) const
|
||||||
|
{
|
||||||
|
wxString value = GetFieldValue( &aFields, PARAMS_FIELD );
|
||||||
|
|
||||||
|
if( value.IsEmpty() )
|
||||||
|
value = DeviceTypeInfo( GetDeviceType() ).fieldValue;
|
||||||
|
|
||||||
|
WriteInferredDataFields( aFields, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<wxString> SIM_MODEL_SOURCE::getPinNames() const
|
std::vector<wxString> SIM_MODEL_SOURCE::getPinNames() const
|
||||||
{
|
{
|
||||||
return { "+", "-" };
|
return { "+", "-" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeDc( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeDcParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -184,7 +258,7 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeDc( wxString aPrefix, wxString aU
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSin( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSinParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -241,7 +315,7 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSin( wxString aPrefix, wxString a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePulse( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePulseParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -314,7 +388,7 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePulse( wxString aPrefix, wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeExp( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeExpParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -371,7 +445,7 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeExp( wxString aPrefix, wxString a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSfam( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSfamParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -419,7 +493,7 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSfam( wxString aPrefix, wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSffm( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSffmParamInfos( wxString aPrefix, wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -484,8 +558,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeSffm( wxString aPrefix, wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePwl( wxString aPrefix, wxString aQuantity,
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePwlParamInfos( wxString aPrefix, wxString aQuantity,
|
||||||
wxString aUnit )
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -526,7 +600,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePwl( wxString aPrefix, wxString a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeWhiteNoise( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeWhiteNoiseParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -559,7 +634,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeWhiteNoise( wxString aPrefix, wxS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePinkNoise( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePinkNoiseParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -600,7 +676,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makePinkNoise( wxString aPrefix, wxSt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeBurstNoise( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeBurstNoiseParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -641,7 +718,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeBurstNoise( wxString aPrefix, wxS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomUniform( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomUniformParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -674,7 +752,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomUniform( wxString aPrefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomNormal( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomNormalParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -707,7 +786,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomNormal( wxString aPrefix, w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomExp( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomExpParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
@ -740,7 +820,8 @@ std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomExp( wxString aPrefix, wxSt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomPoisson( wxString aPrefix, wxString aUnit )
|
std::vector<PARAM::INFO> SIM_MODEL_SOURCE::makeRandomPoissonParamInfos( wxString aPrefix,
|
||||||
|
wxString aUnit )
|
||||||
{
|
{
|
||||||
std::vector<PARAM::INFO> paramInfos;
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
PARAM::INFO paramInfo;
|
PARAM::INFO paramInfo;
|
||||||
|
|
|
@ -33,35 +33,53 @@ class SIM_MODEL_SOURCE : public SIM_MODEL
|
||||||
public:
|
public:
|
||||||
SIM_MODEL_SOURCE( TYPE aType );
|
SIM_MODEL_SOURCE( TYPE aType );
|
||||||
|
|
||||||
|
void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields ) override;
|
||||||
|
void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields ) override;
|
||||||
|
|
||||||
|
void WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const override;
|
||||||
|
void WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const override;
|
||||||
|
|
||||||
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
||||||
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
const wxString& aModelName,
|
const wxString& aModelName,
|
||||||
const std::vector<wxString>& aPinNetNames ) const override;
|
const std::vector<wxString>& aPinNetNames ) const override;
|
||||||
|
|
||||||
bool SetParamValue( int aParamIndex, const wxString& aValue,
|
bool SetParamValue( unsigned aParamIndex, const wxString& aValue,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation ) override;
|
SIM_VALUE_GRAMMAR::NOTATION aNotation ) override;
|
||||||
|
|
||||||
bool HasAutofill() const override { return true; }
|
bool HasAutofill() const override { return true; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString GenerateParamValuePair( const PARAM& aParam, bool& aIsFirst ) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
template <typename T>
|
||||||
|
void inferredReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void inferredWriteDataFields( std::vector<T>& aFields ) const;
|
||||||
|
|
||||||
std::vector<wxString> getPinNames() const override;
|
std::vector<wxString> getPinNames() const override;
|
||||||
|
|
||||||
static const std::vector<PARAM::INFO>& makeParams( TYPE aType );
|
static const std::vector<PARAM::INFO>& makeParamInfos( TYPE aType );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> makeDc( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeDcParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeSin( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeSinParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makePulse( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makePulseParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeExp( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeExpParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeSfam( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeSfamParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeSffm( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeSffmParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makePwl( wxString aPrefix, wxString aQuantity, wxString aUnit );
|
static std::vector<PARAM::INFO> makePwlParamInfos( wxString aPrefix, wxString aQuantity,
|
||||||
static std::vector<PARAM::INFO> makeWhiteNoise( wxString aPrefix, wxString aUnit );
|
wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makePinkNoise( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeWhiteNoiseParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeBurstNoise( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makePinkNoiseParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeRandomUniform( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeBurstNoiseParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeRandomNormal( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeRandomUniformParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeRandomExp( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeRandomNormalParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
static std::vector<PARAM::INFO> makeRandomPoisson( wxString aPrefix, wxString aUnit );
|
static std::vector<PARAM::INFO> makeRandomExpParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
|
static std::vector<PARAM::INFO> makeRandomPoissonParamInfos( wxString aPrefix, wxString aUnit );
|
||||||
|
|
||||||
|
bool m_isInferred;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIM_MODEL_SOURCE_H
|
#endif // SIM_MODEL_SOURCE_H
|
||||||
|
|
|
@ -25,19 +25,107 @@
|
||||||
#include <sim/sim_model_spice.h>
|
#include <sim/sim_model_spice.h>
|
||||||
#include <pegtl.hpp>
|
#include <pegtl.hpp>
|
||||||
#include <pegtl/contrib/parse_tree.hpp>
|
#include <pegtl/contrib/parse_tree.hpp>
|
||||||
|
#include <locale_io.h>
|
||||||
|
|
||||||
|
|
||||||
SIM_MODEL_RAWSPICE::SIM_MODEL_RAWSPICE( TYPE aType )
|
SIM_MODEL_SPICE::SIM_MODEL_SPICE( TYPE aType )
|
||||||
: SIM_MODEL( aType )
|
: SIM_MODEL( aType )
|
||||||
{
|
{
|
||||||
|
static std::vector<PARAM::INFO> paramInfos = makeParamInfos();
|
||||||
|
|
||||||
|
for( const PARAM::INFO& paramInfo : paramInfos )
|
||||||
|
AddParam( paramInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL_RAWSPICE::setParamFromSpiceCode( const wxString& aParamName,
|
void SIM_MODEL_SPICE::ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields )
|
||||||
const wxString& aParamValue,
|
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < aSymbolPinCount; ++i )
|
||||||
|
AddPin( { wxString::Format( "%d", i + 1 ), i + 1 } );
|
||||||
|
|
||||||
|
SIM_MODEL::ReadDataSchFields( aSymbolPinCount, aFields );
|
||||||
|
readLegacyDataFields( aSymbolPinCount, aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SPICE::ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields )
|
||||||
|
{
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < aSymbolPinCount; ++i )
|
||||||
|
AddPin( { wxString::Format( "%d", i + 1 ), i + 1 } );
|
||||||
|
|
||||||
|
SIM_MODEL::ReadDataLibFields( aSymbolPinCount, aFields );
|
||||||
|
readLegacyDataFields( aSymbolPinCount, aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SPICE::WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataSchFields( aFields );
|
||||||
|
|
||||||
|
// Erase the legacy fields.
|
||||||
|
SetFieldValue( aFields, LEGACY_TYPE_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, LEGACY_PINS_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, LEGACY_MODEL_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, LEGACY_ENABLED_FIELD, "" );
|
||||||
|
SetFieldValue( aFields, LEGACY_LIB_FIELD, "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_MODEL_SPICE::WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const
|
||||||
|
{
|
||||||
|
SIM_MODEL::WriteDataLibFields( aFields );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL_SPICE::GenerateSpiceModelLine( const wxString& aModelName ) const
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL_SPICE::GenerateSpiceItemName( const wxString& aRefName ) const
|
||||||
|
{
|
||||||
|
wxString elementType = GetParam( static_cast<int>( SPICE_PARAM::TYPE ) ).value->ToString();
|
||||||
|
|
||||||
|
if( !aRefName.IsEmpty() && aRefName.StartsWith( elementType ) )
|
||||||
|
return aRefName;
|
||||||
|
else
|
||||||
|
return elementType + aRefName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SIM_MODEL_SPICE::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
|
const wxString& aModelName,
|
||||||
|
const std::vector<wxString>& aPinNetNames ) const
|
||||||
|
{
|
||||||
|
wxString result = "";
|
||||||
|
result << GenerateSpiceItemName( aRefName ) << " ";
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < GetPinCount(); ++i )
|
||||||
|
{
|
||||||
|
for( unsigned j = 0; j < aPinNetNames.size(); ++j )
|
||||||
|
{
|
||||||
|
unsigned symbolPinNumber = j + 1;
|
||||||
|
|
||||||
|
if( symbolPinNumber == GetPin( i ).symbolPinNumber )
|
||||||
|
result << aPinNetNames[j] << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result << GetParam( static_cast<unsigned>( SPICE_PARAM::MODEL ) ).value->ToString() << "\n";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL_SPICE::SetParamFromSpiceCode( const wxString& aParamName,
|
||||||
|
const wxString& aParamValue,
|
||||||
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
|
{
|
||||||
|
unsigned i = 0;
|
||||||
|
|
||||||
for(; i < GetParamCount(); ++i )
|
for(; i < GetParamCount(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -45,7 +133,6 @@ bool SIM_MODEL_RAWSPICE::setParamFromSpiceCode( const wxString& aParamName,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( i == GetParamCount() )
|
if( i == GetParamCount() )
|
||||||
{
|
{
|
||||||
// No parameter with this name found. Create a new one.
|
// No parameter with this name found. Create a new one.
|
||||||
|
@ -58,15 +145,92 @@ bool SIM_MODEL_RAWSPICE::setParamFromSpiceCode( const wxString& aParamName,
|
||||||
AddParam( *m_paramInfos.back() );
|
AddParam( *m_paramInfos.back() );
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return GetParam( i ).value->FromString( wxString( aParamValue ), aNotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SPICE::makeParamInfos()
|
||||||
|
{
|
||||||
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
|
|
||||||
|
for( SPICE_PARAM spiceParam : SPICE_PARAM_ITERATOR() )
|
||||||
{
|
{
|
||||||
GetParam( i ).value->FromString( wxString( aParamValue ), aNotation );
|
PARAM::INFO paramInfo;
|
||||||
}
|
|
||||||
catch( const KI_PARAM_ERROR& e )
|
switch( spiceParam )
|
||||||
{
|
{
|
||||||
// Shouldn't happen since it's TYPE::STRING.
|
case SPICE_PARAM::TYPE:
|
||||||
return false;
|
paramInfo.name = "type";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::STRING;
|
||||||
|
paramInfo.unit = "";
|
||||||
|
paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
|
||||||
|
paramInfo.defaultValue = "";
|
||||||
|
paramInfo.description = "Spice element type";
|
||||||
|
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPICE_PARAM::MODEL:
|
||||||
|
paramInfo.name = "model";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::STRING;
|
||||||
|
paramInfo.unit = "";
|
||||||
|
paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
|
||||||
|
paramInfo.defaultValue = "";
|
||||||
|
paramInfo.description = "Model name or value";
|
||||||
|
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPICE_PARAM::LIB:
|
||||||
|
paramInfo.name = "lib";
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE::STRING;
|
||||||
|
paramInfo.unit = "";
|
||||||
|
paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL;
|
||||||
|
paramInfo.defaultValue = "";
|
||||||
|
paramInfo.description = "Library path to include";
|
||||||
|
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPICE_PARAM::_ENUM_END:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return paramInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SIM_MODEL_SPICE::readLegacyDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields )
|
||||||
|
{
|
||||||
|
// Fill in the blanks with the legacy parameters.
|
||||||
|
|
||||||
|
if( GetParam( static_cast<int>( SPICE_PARAM::TYPE ) ).value->ToString().IsEmpty() )
|
||||||
|
{
|
||||||
|
SetParamValue( static_cast<int>( SPICE_PARAM::TYPE ),
|
||||||
|
GetFieldValue( aFields, LEGACY_TYPE_FIELD ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GetFieldValue( aFields, PINS_FIELD ).IsEmpty() )
|
||||||
|
ParsePinsField( aSymbolPinCount, GetFieldValue( aFields, LEGACY_PINS_FIELD ) );
|
||||||
|
|
||||||
|
if( GetParam( static_cast<int>( SPICE_PARAM::MODEL ) ).value->ToString().IsEmpty() )
|
||||||
|
{
|
||||||
|
SetParamValue( static_cast<int>( SPICE_PARAM::MODEL ),
|
||||||
|
GetFieldValue( aFields, LEGACY_MODEL_FIELD ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If model param is still empty, then use Value field.
|
||||||
|
if( GetParam( static_cast<int>( SPICE_PARAM::MODEL ) ).value->ToString().IsEmpty() )
|
||||||
|
{
|
||||||
|
SetParamValue( static_cast<int>( SPICE_PARAM::MODEL ),
|
||||||
|
GetFieldValue( aFields, SIM_MODEL::VALUE_FIELD ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GetParam( static_cast<int>( SPICE_PARAM::LIB ) ).value->ToString().IsEmpty() )
|
||||||
|
{
|
||||||
|
SetParamValue( static_cast<int>( SPICE_PARAM::LIB ),
|
||||||
|
GetFieldValue( aFields, LEGACY_LIB_FIELD ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,56 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SIM_MODEL_RAWSPICE_H
|
#ifndef SIM_MODEL_SPICE_H
|
||||||
#define SIM_MODEL_RAWSPICE_H
|
#define SIM_MODEL_SPICE_H
|
||||||
|
|
||||||
#include <sim/sim_model.h>
|
#include <sim/sim_model.h>
|
||||||
|
|
||||||
|
|
||||||
class SIM_MODEL_RAWSPICE : public SIM_MODEL
|
class SIM_MODEL_SPICE : public SIM_MODEL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SIM_MODEL_RAWSPICE( TYPE aType );
|
DEFINE_ENUM_CLASS_WITH_ITERATOR( SPICE_PARAM,
|
||||||
|
TYPE,
|
||||||
|
MODEL,
|
||||||
|
LIB
|
||||||
|
)
|
||||||
|
|
||||||
|
static constexpr auto LEGACY_TYPE_FIELD = "Spice_Primitive";
|
||||||
|
static constexpr auto LEGACY_PINS_FIELD = "Spice_Node_Sequence";
|
||||||
|
static constexpr auto LEGACY_MODEL_FIELD = "Spice_Model";
|
||||||
|
static constexpr auto LEGACY_ENABLED_FIELD = "Spice_Netlist_Enabled";
|
||||||
|
static constexpr auto LEGACY_LIB_FIELD = "Spice_Lib_File";
|
||||||
|
|
||||||
|
|
||||||
|
SIM_MODEL_SPICE( TYPE aType );
|
||||||
|
|
||||||
//bool ReadSpiceCode( const std::string& aSpiceCode ) override;
|
//bool ReadSpiceCode( const std::string& aSpiceCode ) override;
|
||||||
|
void ReadDataSchFields( unsigned aSymbolPinCount, const std::vector<SCH_FIELD>* aFields ) override;
|
||||||
|
void ReadDataLibFields( unsigned aSymbolPinCount, const std::vector<LIB_FIELD>* aFields ) override;
|
||||||
|
|
||||||
private:
|
void WriteDataSchFields( std::vector<SCH_FIELD>& aFields ) const override;
|
||||||
bool setParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
void WriteDataLibFields( std::vector<LIB_FIELD>& aFields ) const override;
|
||||||
|
|
||||||
|
|
||||||
|
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
||||||
|
wxString GenerateSpiceItemName( const wxString& aRefName ) const override;
|
||||||
|
wxString GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
|
const wxString& aModelName,
|
||||||
|
const std::vector<wxString>& aPinNetNames ) const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
||||||
= SIM_VALUE_GRAMMAR::NOTATION::SPICE ) override;
|
= SIM_VALUE_GRAMMAR::NOTATION::SPICE ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<PARAM::INFO> makeParamInfos();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void readLegacyDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SIM_MODEL_RAWSPICE_H
|
#endif // SIM_MODEL_SPICE_H
|
||||||
|
|
|
@ -123,7 +123,7 @@ std::vector<wxString> SIM_MODEL_SUBCKT::GenerateSpiceCurrentNames( const wxStrin
|
||||||
{
|
{
|
||||||
std::vector<wxString> currentNames;
|
std::vector<wxString> currentNames;
|
||||||
|
|
||||||
for( int i = 0; i < GetPinCount(); ++i )
|
for( unsigned i = 0; i < GetPinCount(); ++i )
|
||||||
currentNames.push_back( wxString::Format( "I(%s:%s)",
|
currentNames.push_back( wxString::Format( "I(%s:%s)",
|
||||||
GenerateSpiceItemName( aRefName ),
|
GenerateSpiceItemName( aRefName ),
|
||||||
GetPin( i ).name ) );
|
GetPin( i ).name ) );
|
||||||
|
@ -137,10 +137,10 @@ void SIM_MODEL_SUBCKT::SetBaseModel( const SIM_MODEL& aBaseModel )
|
||||||
SIM_MODEL::SetBaseModel( aBaseModel );
|
SIM_MODEL::SetBaseModel( aBaseModel );
|
||||||
|
|
||||||
// Pins aren't constant for subcircuits, so they need to be copied from the base model.
|
// Pins aren't constant for subcircuits, so they need to be copied from the base model.
|
||||||
for( int i = 0; i < GetBaseModel()->GetPinCount(); ++i )
|
for( unsigned i = 0; i < GetBaseModel()->GetPinCount(); ++i )
|
||||||
AddPin( GetBaseModel()->GetPin( i ) );
|
AddPin( GetBaseModel()->GetPin( i ) );
|
||||||
|
|
||||||
// Same for parameters.
|
// Same for parameters.
|
||||||
for( int i = 0; i < GetBaseModel()->GetParamCount(); ++i )
|
for( unsigned i = 0; i < GetBaseModel()->GetParamCount(); ++i )
|
||||||
AddParam( GetBaseModel()->GetParam( i ).info );
|
AddParam( GetBaseModel()->GetParam( i ).info );
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,32 +293,32 @@ wxString SIM_VALUE_PARSER::ExponentToMetricSuffix( double aExponent, long& aRedu
|
||||||
aReductionExponent = -18;
|
aReductionExponent = -18;
|
||||||
return "a";
|
return "a";
|
||||||
}
|
}
|
||||||
else if( aExponent > -15 && aExponent <= -12 )
|
else if( aExponent >= -15 && aExponent < -12 )
|
||||||
{
|
{
|
||||||
aReductionExponent = -15;
|
aReductionExponent = -15;
|
||||||
return "f";
|
return "f";
|
||||||
}
|
}
|
||||||
else if( aExponent > -12 && aExponent <= -9 )
|
else if( aExponent >= -12 && aExponent < -9 )
|
||||||
{
|
{
|
||||||
aReductionExponent = -12;
|
aReductionExponent = -12;
|
||||||
return "p";
|
return "p";
|
||||||
}
|
}
|
||||||
else if( aExponent > -9 && aExponent <= -6 )
|
else if( aExponent >= -9 && aExponent < -6 )
|
||||||
{
|
{
|
||||||
aReductionExponent = -9;
|
aReductionExponent = -9;
|
||||||
return "n";
|
return "n";
|
||||||
}
|
}
|
||||||
else if( aExponent > -6 && aExponent <= -3 )
|
else if( aExponent >= -6 && aExponent < -3 )
|
||||||
{
|
{
|
||||||
aReductionExponent = -6;
|
aReductionExponent = -6;
|
||||||
return "u";
|
return "u";
|
||||||
}
|
}
|
||||||
else if( aExponent > -3 && aExponent < 0 )
|
else if( aExponent >= -3 && aExponent < 0 )
|
||||||
{
|
{
|
||||||
aReductionExponent = -3;
|
aReductionExponent = -3;
|
||||||
return "m";
|
return "m";
|
||||||
}
|
}
|
||||||
else if( aExponent > 0 && aExponent < 3 )
|
else if( aExponent >= 0 && aExponent < 3 )
|
||||||
{
|
{
|
||||||
aReductionExponent = 0;
|
aReductionExponent = 0;
|
||||||
return "";
|
return "";
|
||||||
|
@ -529,7 +529,7 @@ wxString SIM_VALUE_INSTANCE<bool>::ToString( NOTATION aNotation ) const
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
return wxString::Format( "%d", *m_value );
|
return wxString::Format( "%d", *m_value );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -541,12 +541,12 @@ wxString SIM_VALUE_INSTANCE<long>::ToString( NOTATION aNotation ) const
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
{
|
{
|
||||||
long value = *m_value;
|
long value = *m_value;
|
||||||
long exponent = 0;
|
long exponent = 0;
|
||||||
|
|
||||||
while( value % 1000 == 0 )
|
while( value != 0 && value % 1000 == 0 )
|
||||||
{
|
{
|
||||||
exponent += 3;
|
exponent += 3;
|
||||||
value /= 1000;
|
value /= 1000;
|
||||||
|
@ -567,7 +567,7 @@ wxString SIM_VALUE_INSTANCE<double>::ToString( NOTATION aNotation ) const
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
{
|
{
|
||||||
double exponent = std::log10( *m_value );
|
double exponent = std::log10( *m_value );
|
||||||
long reductionExponent = 0;
|
long reductionExponent = 0;
|
||||||
|
@ -588,7 +588,7 @@ wxString SIM_VALUE_INSTANCE<std::complex<double>>::ToString( NOTATION aNotation
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
return wxString::Format( "%g+%gi", m_value->real(), m_value->imag() );
|
return wxString::Format( "%g+%gi", m_value->real(), m_value->imag() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -600,7 +600,7 @@ wxString SIM_VALUE_INSTANCE<wxString>::ToString( NOTATION aNotation ) const
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
return *m_value;
|
return *m_value;
|
||||||
|
|
||||||
return ""; // Empty string is completely equivalent to null string.
|
return ""; // Empty string is completely equivalent to null string.
|
||||||
|
@ -610,7 +610,7 @@ wxString SIM_VALUE_INSTANCE<wxString>::ToString( NOTATION aNotation ) const
|
||||||
template <typename T>
|
template <typename T>
|
||||||
wxString SIM_VALUE_INSTANCE<T>::ToSimpleString() const
|
wxString SIM_VALUE_INSTANCE<T>::ToSimpleString() const
|
||||||
{
|
{
|
||||||
if( m_value.has_value() )
|
if( m_value )
|
||||||
{
|
{
|
||||||
wxString result = "";
|
wxString result = "";
|
||||||
result << *m_value;
|
result << *m_value;
|
||||||
|
|
|
@ -154,10 +154,10 @@ namespace SIM_VALUE_GRAMMAR
|
||||||
TAO_PEGTL_ISTRING( "p" ),
|
TAO_PEGTL_ISTRING( "p" ),
|
||||||
TAO_PEGTL_ISTRING( "n" ),
|
TAO_PEGTL_ISTRING( "n" ),
|
||||||
TAO_PEGTL_ISTRING( "u" ),
|
TAO_PEGTL_ISTRING( "u" ),
|
||||||
|
TAO_PEGTL_ISTRING( "Meg" ), // "Meg" must be before "m".
|
||||||
TAO_PEGTL_ISTRING( "m" ),
|
TAO_PEGTL_ISTRING( "m" ),
|
||||||
//TAO_PEGTL_ISTRING( "mil" ),
|
//TAO_PEGTL_ISTRING( "mil" ),
|
||||||
TAO_PEGTL_ISTRING( "k" ),
|
TAO_PEGTL_ISTRING( "k" ),
|
||||||
TAO_PEGTL_ISTRING( "Meg" ),
|
|
||||||
TAO_PEGTL_ISTRING( "G" ),
|
TAO_PEGTL_ISTRING( "G" ),
|
||||||
TAO_PEGTL_ISTRING( "T" )> {};
|
TAO_PEGTL_ISTRING( "T" )> {};
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ namespace SIM_VALUE_GRAMMAR
|
||||||
template <SIM_VALUE::TYPE ValueType, NOTATION Notation>
|
template <SIM_VALUE::TYPE ValueType, NOTATION Notation>
|
||||||
struct number : seq<significand<ValueType>,
|
struct number : seq<significand<ValueType>,
|
||||||
opt<exponentWithPrefix>,
|
opt<exponentWithPrefix>,
|
||||||
opt<metricSuffix<ValueType, Notation>>> {};
|
sor<metricSuffix<ValueType, Notation>, not_at<alnum>>> {};
|
||||||
|
|
||||||
template <SIM_VALUE::TYPE ValueType, NOTATION Notation>
|
template <SIM_VALUE::TYPE ValueType, NOTATION Notation>
|
||||||
struct numberGrammar : must<opt<number<ValueType, Notation>>, eof> {};
|
struct numberGrammar : must<opt<number<ValueType, Notation>>, eof> {};
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace SPICE_GRAMMAR
|
||||||
/*seq<alpha,
|
/*seq<alpha,
|
||||||
star<sor<alnum,
|
star<sor<alnum,
|
||||||
one<'!', '#', '$', '%', '[', ']', '_'>>>> {};*/
|
one<'!', '#', '$', '%', '[', ']', '_'>>>> {};*/
|
||||||
struct dotModelType : sor<TAO_PEGTL_ISTRING( "R" ),
|
/*struct dotModelType : sor<TAO_PEGTL_ISTRING( "R" ),
|
||||||
TAO_PEGTL_ISTRING( "C" ),
|
TAO_PEGTL_ISTRING( "C" ),
|
||||||
TAO_PEGTL_ISTRING( "L" ),
|
TAO_PEGTL_ISTRING( "L" ),
|
||||||
TAO_PEGTL_ISTRING( "SW" ),
|
TAO_PEGTL_ISTRING( "SW" ),
|
||||||
|
@ -92,7 +92,8 @@ namespace SPICE_GRAMMAR
|
||||||
TAO_PEGTL_ISTRING( "PMOS" ),
|
TAO_PEGTL_ISTRING( "PMOS" ),
|
||||||
TAO_PEGTL_ISTRING( "NMF" ),
|
TAO_PEGTL_ISTRING( "NMF" ),
|
||||||
TAO_PEGTL_ISTRING( "PMF" ),
|
TAO_PEGTL_ISTRING( "PMF" ),
|
||||||
TAO_PEGTL_ISTRING( "VDMOS" )> {};
|
TAO_PEGTL_ISTRING( "VDMOS" )> {};*/
|
||||||
|
struct dotModelType : plus<alpha> {};
|
||||||
struct dotModel : seq<opt<sep>,
|
struct dotModel : seq<opt<sep>,
|
||||||
TAO_PEGTL_ISTRING( ".model" ),
|
TAO_PEGTL_ISTRING( ".model" ),
|
||||||
sep,
|
sep,
|
||||||
|
|
|
@ -315,7 +315,7 @@
|
||||||
(uuid 55368b74-95a7-4cf2-8f86-415db816907d)
|
(uuid 55368b74-95a7-4cf2-8f86-415db816907d)
|
||||||
)
|
)
|
||||||
|
|
||||||
(text ".tran 10u 10m" (at 138.43 86.36 0)
|
(text ".tran 10u 10m" (at 146.05 123.19 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left bottom))
|
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||||
(uuid be48cb8e-7c9f-4216-838e-ee151aaeb3f9)
|
(uuid be48cb8e-7c9f-4216-838e-ee151aaeb3f9)
|
||||||
)
|
)
|
||||||
|
@ -341,10 +341,10 @@
|
||||||
(symbol (lib_id "Simulation_SPICE:VSIN") (at 142.24 96.52 0) (unit 1)
|
(symbol (lib_id "Simulation_SPICE:VSIN") (at 142.24 96.52 0) (unit 1)
|
||||||
(in_bom yes) (on_board yes)
|
(in_bom yes) (on_board yes)
|
||||||
(uuid 10f44001-5f65-44eb-a535-b7b3c67d5b83)
|
(uuid 10f44001-5f65-44eb-a535-b7b3c67d5b83)
|
||||||
(property "Reference" "V1" (id 0) (at 146.05 94.615 0)
|
(property "Reference" "VSIN1" (id 0) (at 121.92 95.25 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Value" "VSIN" (id 1) (at 146.05 97.155 0)
|
(property "Value" "ampl=100m f=1k" (id 1) (at 121.92 97.79 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Footprint" "" (id 2) (at 142.24 96.52 0)
|
(property "Footprint" "" (id 2) (at 142.24 96.52 0)
|
||||||
|
@ -353,18 +353,6 @@
|
||||||
(property "Datasheet" "~" (id 3) (at 142.24 96.52 0)
|
(property "Datasheet" "~" (id 3) (at 142.24 96.52 0)
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
)
|
)
|
||||||
(property "Model_Device" "V" (id 4) (at 142.24 96.52 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Type" "SIN" (id 5) (at 142.24 96.52 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Pins" "1 2" (id 6) (at 142.24 96.52 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Params" "dc=0 ampl=100m f=1k" (id 7) (at 129.54 92.71 0)
|
|
||||||
(effects (font (size 1.27 1.27)))
|
|
||||||
)
|
|
||||||
(pin "1" (uuid 27dbfa5d-bb20-468f-9a81-7737a5e908fc))
|
(pin "1" (uuid 27dbfa5d-bb20-468f-9a81-7737a5e908fc))
|
||||||
(pin "2" (uuid 63677ebb-93e3-49bb-8bf1-14fce6c8137d))
|
(pin "2" (uuid 63677ebb-93e3-49bb-8bf1-14fce6c8137d))
|
||||||
)
|
)
|
||||||
|
@ -375,7 +363,7 @@
|
||||||
(property "Reference" "R2" (id 0) (at 156.21 116.205 90)
|
(property "Reference" "R2" (id 0) (at 156.21 116.205 90)
|
||||||
(effects (font (size 1.27 1.27)))
|
(effects (font (size 1.27 1.27)))
|
||||||
)
|
)
|
||||||
(property "Value" "10K" (id 1) (at 156.21 118.745 90)
|
(property "Value" "10k" (id 1) (at 156.21 118.745 90)
|
||||||
(effects (font (size 1.27 1.27)))
|
(effects (font (size 1.27 1.27)))
|
||||||
)
|
)
|
||||||
(property "Footprint" "" (id 2) (at 156.21 115.443 90)
|
(property "Footprint" "" (id 2) (at 156.21 115.443 90)
|
||||||
|
@ -544,7 +532,7 @@
|
||||||
(property "Reference" "R1" (id 0) (at 148.59 116.205 90)
|
(property "Reference" "R1" (id 0) (at 148.59 116.205 90)
|
||||||
(effects (font (size 1.27 1.27)))
|
(effects (font (size 1.27 1.27)))
|
||||||
)
|
)
|
||||||
(property "Value" "10K" (id 1) (at 148.59 118.745 90)
|
(property "Value" "10k" (id 1) (at 148.59 118.745 90)
|
||||||
(effects (font (size 1.27 1.27)))
|
(effects (font (size 1.27 1.27)))
|
||||||
)
|
)
|
||||||
(property "Footprint" "" (id 2) (at 148.59 115.443 90)
|
(property "Footprint" "" (id 2) (at 148.59 115.443 90)
|
||||||
|
@ -575,22 +563,22 @@
|
||||||
(reference "#PWR04") (unit 1) (value "GND") (footprint "")
|
(reference "#PWR04") (unit 1) (value "GND") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/fbe00ebb-3cab-46ea-988c-9e8169e9708f"
|
(path "/fbe00ebb-3cab-46ea-988c-9e8169e9708f"
|
||||||
(reference "R1") (unit 1) (value "10K") (footprint "")
|
(reference "R1") (unit 1) (value "10k") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/2a5b0448-42a8-4fa4-9a14-267dc34f9ff7"
|
(path "/2a5b0448-42a8-4fa4-9a14-267dc34f9ff7"
|
||||||
(reference "R2") (unit 1) (value "10K") (footprint "")
|
(reference "R2") (unit 1) (value "10k") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/3dd58d42-1028-4fbc-adf4-32d03de981a6"
|
(path "/3dd58d42-1028-4fbc-adf4-32d03de981a6"
|
||||||
(reference "U1") (unit 1) (value "OPAMP") (footprint "")
|
(reference "U1") (unit 1) (value "OPAMP") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/10f44001-5f65-44eb-a535-b7b3c67d5b83"
|
|
||||||
(reference "V1") (unit 1) (value "VSIN") (footprint "")
|
|
||||||
)
|
|
||||||
(path "/383ea298-1cb3-473e-8fce-19d3c7ac3912"
|
(path "/383ea298-1cb3-473e-8fce-19d3c7ac3912"
|
||||||
(reference "V2") (unit 1) (value "VDC") (footprint "")
|
(reference "V2") (unit 1) (value "VDC") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/d2018f30-5def-453e-85fe-dac327cfbe9b"
|
(path "/d2018f30-5def-453e-85fe-dac327cfbe9b"
|
||||||
(reference "V3") (unit 1) (value "VDC") (footprint "")
|
(reference "V3") (unit 1) (value "VDC") (footprint "")
|
||||||
)
|
)
|
||||||
|
(path "/10f44001-5f65-44eb-a535-b7b3c67d5b83"
|
||||||
|
(reference "VSIN1") (unit 1) (value "ampl=100m f=1k") (footprint "")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
(kicad_pcb (version 20220308) (generator pcbnew)
|
||||||
|
)
|
|
@ -0,0 +1,331 @@
|
||||||
|
{
|
||||||
|
"board": {
|
||||||
|
"design_settings": {
|
||||||
|
"defaults": {
|
||||||
|
"board_outline_line_width": 0.1,
|
||||||
|
"copper_line_width": 0.2,
|
||||||
|
"copper_text_size_h": 1.5,
|
||||||
|
"copper_text_size_v": 1.5,
|
||||||
|
"copper_text_thickness": 0.3,
|
||||||
|
"other_line_width": 0.15,
|
||||||
|
"silk_line_width": 0.15,
|
||||||
|
"silk_text_size_h": 1.0,
|
||||||
|
"silk_text_size_v": 1.0,
|
||||||
|
"silk_text_thickness": 0.15
|
||||||
|
},
|
||||||
|
"diff_pair_dimensions": [],
|
||||||
|
"drc_exclusions": [],
|
||||||
|
"rules": {
|
||||||
|
"min_copper_edge_clearance": 0.0,
|
||||||
|
"solder_mask_clearance": 0.0,
|
||||||
|
"solder_mask_min_width": 0.0
|
||||||
|
},
|
||||||
|
"track_widths": [],
|
||||||
|
"via_dimensions": []
|
||||||
|
},
|
||||||
|
"layer_presets": [],
|
||||||
|
"viewports": []
|
||||||
|
},
|
||||||
|
"boards": [],
|
||||||
|
"cvpcb": {
|
||||||
|
"equivalence_files": []
|
||||||
|
},
|
||||||
|
"erc": {
|
||||||
|
"erc_exclusions": [],
|
||||||
|
"meta": {
|
||||||
|
"version": 0
|
||||||
|
},
|
||||||
|
"pin_map": [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"rule_severities": {
|
||||||
|
"bus_definition_conflict": "error",
|
||||||
|
"bus_entry_needed": "error",
|
||||||
|
"bus_label_syntax": "error",
|
||||||
|
"bus_to_bus_conflict": "error",
|
||||||
|
"bus_to_net_conflict": "error",
|
||||||
|
"different_unit_footprint": "error",
|
||||||
|
"different_unit_net": "error",
|
||||||
|
"duplicate_reference": "error",
|
||||||
|
"duplicate_sheet_names": "error",
|
||||||
|
"extra_units": "error",
|
||||||
|
"global_label_dangling": "warning",
|
||||||
|
"hier_label_mismatch": "error",
|
||||||
|
"label_dangling": "error",
|
||||||
|
"lib_symbol_issues": "warning",
|
||||||
|
"multiple_net_names": "warning",
|
||||||
|
"net_not_bus_member": "warning",
|
||||||
|
"no_connect_connected": "warning",
|
||||||
|
"no_connect_dangling": "warning",
|
||||||
|
"pin_not_connected": "error",
|
||||||
|
"pin_not_driven": "error",
|
||||||
|
"pin_to_pin": "warning",
|
||||||
|
"power_pin_not_driven": "error",
|
||||||
|
"similar_labels": "warning",
|
||||||
|
"unannotated": "error",
|
||||||
|
"unit_value_mismatch": "error",
|
||||||
|
"unresolved_variable": "error",
|
||||||
|
"wire_dangling": "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"pinned_footprint_libs": [],
|
||||||
|
"pinned_symbol_libs": []
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"filename": "passives.kicad_pro",
|
||||||
|
"version": 1
|
||||||
|
},
|
||||||
|
"net_settings": {
|
||||||
|
"classes": [
|
||||||
|
{
|
||||||
|
"bus_width": 12.0,
|
||||||
|
"clearance": 0.2,
|
||||||
|
"diff_pair_gap": 0.25,
|
||||||
|
"diff_pair_via_gap": 0.25,
|
||||||
|
"diff_pair_width": 0.2,
|
||||||
|
"line_style": 0,
|
||||||
|
"microvia_diameter": 0.3,
|
||||||
|
"microvia_drill": 0.1,
|
||||||
|
"name": "Default",
|
||||||
|
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"track_width": 0.25,
|
||||||
|
"via_diameter": 0.8,
|
||||||
|
"via_drill": 0.4,
|
||||||
|
"wire_width": 6.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"net_colors": null
|
||||||
|
},
|
||||||
|
"pcbnew": {
|
||||||
|
"last_paths": {
|
||||||
|
"gencad": "",
|
||||||
|
"idf": "",
|
||||||
|
"netlist": "",
|
||||||
|
"specctra_dsn": "",
|
||||||
|
"step": "",
|
||||||
|
"vrml": ""
|
||||||
|
},
|
||||||
|
"page_layout_descr_file": ""
|
||||||
|
},
|
||||||
|
"schematic": {
|
||||||
|
"annotate_start_num": 0,
|
||||||
|
"drawing": {
|
||||||
|
"dashed_lines_dash_length_ratio": 12.0,
|
||||||
|
"dashed_lines_gap_length_ratio": 3.0,
|
||||||
|
"default_line_thickness": 6.0,
|
||||||
|
"default_text_size": 50.0,
|
||||||
|
"field_names": [],
|
||||||
|
"intersheets_ref_own_page": false,
|
||||||
|
"intersheets_ref_prefix": "",
|
||||||
|
"intersheets_ref_short": false,
|
||||||
|
"intersheets_ref_show": false,
|
||||||
|
"intersheets_ref_suffix": "",
|
||||||
|
"junction_size_choice": 3,
|
||||||
|
"label_size_ratio": 0.375,
|
||||||
|
"pin_symbol_size": 25.0,
|
||||||
|
"text_offset_ratio": 0.15
|
||||||
|
},
|
||||||
|
"legacy_lib_dir": "",
|
||||||
|
"legacy_lib_list": [],
|
||||||
|
"meta": {
|
||||||
|
"version": 1
|
||||||
|
},
|
||||||
|
"net_format_name": "",
|
||||||
|
"ngspice": {
|
||||||
|
"fix_include_paths": true,
|
||||||
|
"fix_passive_vals": false,
|
||||||
|
"meta": {
|
||||||
|
"version": 0
|
||||||
|
},
|
||||||
|
"model_mode": 0,
|
||||||
|
"workbook_filename": ""
|
||||||
|
},
|
||||||
|
"page_layout_descr_file": "",
|
||||||
|
"plot_directory": "",
|
||||||
|
"spice_adjust_passive_values": false,
|
||||||
|
"spice_external_command": "spice \"%I\"",
|
||||||
|
"spice_save_all_currents": false,
|
||||||
|
"spice_save_all_voltages": false,
|
||||||
|
"subpart_first_id": 65,
|
||||||
|
"subpart_id_separator": 0
|
||||||
|
},
|
||||||
|
"sheets": [
|
||||||
|
[
|
||||||
|
"24a3b022-7ece-4686-93db-0efadfbf9409",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"text_variables": {}
|
||||||
|
}
|
|
@ -0,0 +1,681 @@
|
||||||
|
(kicad_sch (version 20220331) (generator eeschema)
|
||||||
|
|
||||||
|
(uuid 24a3b022-7ece-4686-93db-0efadfbf9409)
|
||||||
|
|
||||||
|
(paper "A4")
|
||||||
|
|
||||||
|
(lib_symbols
|
||||||
|
(symbol "Device:C" (pin_numbers hide) (pin_names (offset 0.254)) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "C" (id 0) (at 0.635 2.54 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "C" (id 1) (at 0.635 -2.54 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 0.9652 -3.81 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "cap capacitor" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Unpolarized capacitor" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_fp_filters" "C_*" (id 6) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "C_0_1"
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy -2.032 -0.762)
|
||||||
|
(xy 2.032 -0.762)
|
||||||
|
)
|
||||||
|
(stroke (width 0.508) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy -2.032 0.762)
|
||||||
|
(xy 2.032 0.762)
|
||||||
|
)
|
||||||
|
(stroke (width 0.508) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "C_1_1"
|
||||||
|
(pin passive line (at 0 3.81 270) (length 2.794)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
(pin passive line (at 0 -3.81 90) (length 2.794)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "2" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "Device:L" (pin_numbers hide) (pin_names (offset 1.016) hide) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "L" (id 0) (at -1.27 0 90)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Value" "L" (id 1) (at 1.905 0 90)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "inductor choke coil reactor magnetic" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Inductor" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_fp_filters" "Choke_* *Coil* Inductor_* L_*" (id 6) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "L_0_1"
|
||||||
|
(arc (start 0 -2.54) (mid 0.635 -1.905) (end 0 -1.27)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(arc (start 0 -1.27) (mid 0.635 -0.635) (end 0 0)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(arc (start 0 0) (mid 0.635 0.635) (end 0 1.27)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(arc (start 0 1.27) (mid 0.635 1.905) (end 0 2.54)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "L_1_1"
|
||||||
|
(pin passive line (at 0 3.81 270) (length 1.27)
|
||||||
|
(name "1" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
(pin passive line (at 0 -3.81 90) (length 1.27)
|
||||||
|
(name "2" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "2" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "R" (id 0) (at 2.032 0 90)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Value" "R" (id 1) (at 0 0 90)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at -1.778 0 90)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "R res resistor" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Resistor" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_fp_filters" "R_*" (id 6) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "R_0_1"
|
||||||
|
(rectangle (start -1.016 -2.54) (end 1.016 2.54)
|
||||||
|
(stroke (width 0.254) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "R_1_1"
|
||||||
|
(pin passive line (at 0 3.81 270) (length 1.27)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
(pin passive line (at 0 -3.81 90) (length 1.27)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "2" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "Simulation_SPICE:VDC" (pin_numbers hide) (pin_names (offset 0.0254)) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "V" (id 0) (at 2.54 2.54 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "VDC" (id 1) (at 2.54 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Spice_Netlist_Enabled" "Y" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left) hide)
|
||||||
|
)
|
||||||
|
(property "Spice_Primitive" "V" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left) hide)
|
||||||
|
)
|
||||||
|
(property "Spice_Model" "dc(1)" (id 6) (at 2.54 -2.54 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "simulation" (id 7) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Voltage source, DC" (id 8) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "VDC_0_0"
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy -1.27 0.254)
|
||||||
|
(xy 1.27 0.254)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy -0.762 -0.254)
|
||||||
|
(xy -1.27 -0.254)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy 0.254 -0.254)
|
||||||
|
(xy -0.254 -0.254)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy 1.27 -0.254)
|
||||||
|
(xy 0.762 -0.254)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(text "+" (at 0 1.905 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "VDC_0_1"
|
||||||
|
(circle (center 0 0) (radius 2.54)
|
||||||
|
(stroke (width 0.254) (type default))
|
||||||
|
(fill (type background))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "VDC_1_1"
|
||||||
|
(pin passive line (at 0 5.08 270) (length 2.54)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
(pin passive line (at 0 -5.08 90) (length 2.54)
|
||||||
|
(name "~" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "2" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "#PWR" (id 0) (at 0 -6.35 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "GND" (id 1) (at 0 -3.81 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "power-flag" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Power symbol creates a global label with name \"GND\" , ground" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "GND_0_1"
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy 0 0)
|
||||||
|
(xy 0 -1.27)
|
||||||
|
(xy 1.27 -1.27)
|
||||||
|
(xy 0 -2.54)
|
||||||
|
(xy -1.27 -1.27)
|
||||||
|
(xy 0 -1.27)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "GND_1_1"
|
||||||
|
(pin power_in line (at 0 0 270) (length 0) hide
|
||||||
|
(name "GND" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "power:VCC" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
|
||||||
|
(property "Reference" "#PWR" (id 0) (at 0 -3.81 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "VCC" (id 1) (at 0 3.81 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_keywords" "power-flag" (id 4) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "ki_description" "Power symbol creates a global label with name \"VCC\"" (id 5) (at 0 0 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(symbol "VCC_0_1"
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy -0.762 1.27)
|
||||||
|
(xy 0 2.54)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy 0 0)
|
||||||
|
(xy 0 2.54)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
(polyline
|
||||||
|
(pts
|
||||||
|
(xy 0 2.54)
|
||||||
|
(xy 0.762 1.27)
|
||||||
|
)
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(fill (type none))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(symbol "VCC_1_1"
|
||||||
|
(pin power_in line (at 0 0 90) (length 0) hide
|
||||||
|
(name "VCC" (effects (font (size 1.27 1.27))))
|
||||||
|
(number "1" (effects (font (size 1.27 1.27))))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(junction (at 190.5 114.2622) (diameter 0) (color 0 0 0 0)
|
||||||
|
(uuid eafda027-8fd2-40c0-b082-f15f04050481)
|
||||||
|
)
|
||||||
|
|
||||||
|
(wire (pts (xy 190.5 101.6) (xy 190.5 104.14))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid 03e5d1ef-95c5-418e-822d-d942eb7eea5f)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 165.1 101.6) (xy 165.1 104.14))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid 215ca15f-8dc1-4558-b14d-ce81bdd98add)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 190.5 114.2622) (xy 190.5 114.3))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid 35f870a7-448a-4ca6-9dc9-3095aaefc3f9)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 165.1 111.76) (xy 165.1 114.3))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid 8c444764-4ee8-4e6a-b678-fea30fbd1bdb)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 139.7 111.76) (xy 139.7 114.3))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid a5287d05-b271-47b7-b485-2abae8ee6bda)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 139.7 101.6) (xy 139.7 104.14))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid af29e35f-ad8e-42ad-92d8-dab3c77b10f7)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 114.3 101.6) (xy 114.3 102.87))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid c8381c0e-870a-4b60-a370-665e41cc0a82)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 190.5 111.76) (xy 190.5 114.2622))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid c96a0874-8a88-41d8-8fc9-4f44b9a77308)
|
||||||
|
)
|
||||||
|
(wire (pts (xy 114.3 113.03) (xy 114.3 114.3))
|
||||||
|
(stroke (width 0) (type default))
|
||||||
|
(uuid e4efd56a-f328-4d4d-b131-d2bd4285571c)
|
||||||
|
)
|
||||||
|
|
||||||
|
(text ".dc TEMP -40 125 1" (at 114.3 127 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left bottom))
|
||||||
|
(uuid 7375d298-3734-4861-a3c5-951d900d6e42)
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:VCC") (at 139.7 101.6 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 0b5a77ca-f3ff-42b7-8572-0eefa9011bf1)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 139.7 105.41 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "VCC" (id 1) (at 139.7 97.79 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 139.7 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 139.7 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 80684c7b-5b8f-4fa5-a22a-6c3e25ecf03a))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:VCC") (at 190.5 101.6 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 2f62470a-49dd-4c2d-89e9-a2acc60c442d)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 190.5 105.41 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "VCC" (id 1) (at 190.5 97.79 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 190.5 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 190.5 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid d3b8058c-41bf-4fda-9fb7-d5dd8c40209d))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:GND") (at 165.1 114.3 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 438ece8c-3eb3-4d7e-9271-8a8e8aeb6d3c)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 165.1 120.65 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "GND" (id 1) (at 165.1 119.38 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 165.1 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 165.1 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid d4f9c990-709a-4cab-83e6-f03cac3e330c))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:VCC") (at 165.1 101.6 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 613737e0-8030-4980-b87e-8290b8a61eaf)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 165.1 105.41 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "VCC" (id 1) (at 165.1 97.79 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 165.1 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 165.1 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 4e31b1ca-d4bc-4891-b37e-bc167f16d091))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "Device:C") (at 165.1 107.95 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 6566e118-05df-4951-a19e-df5ca72becf1)
|
||||||
|
(property "Reference" "C1" (id 0) (at 168.91 107.315 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "100u" (id 1) (at 168.91 109.855 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 166.0652 111.76 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 165.1 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Name" "AVX_12066D107MAT4A" (id 4) (at 165.1 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Library" "passives.lib" (id 5) (at 165.1 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Device" "C" (id 6) (at 165.1 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Type" "ADV" (id 7) (at 165.1 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid b036b9d3-38c0-48ea-9a7e-5c57025637b1))
|
||||||
|
(pin "2" (uuid 35151b75-27a9-4e4d-b0b5-cdabe4516193))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "Device:L") (at 190.5 107.95 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 65be26d9-e694-445c-9a01-797abd973f29)
|
||||||
|
(property "Reference" "L1" (id 0) (at 191.77 107.315 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "220n" (id 1) (at 191.77 109.855 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Name" "AVX_0603WL221GT" (id 4) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Library" "passives.lib" (id 5) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Device" "L" (id 6) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Type" "ADV" (id 7) (at 190.5 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 31abb371-b97b-4c10-a4b3-748d55802214))
|
||||||
|
(pin "2" (uuid c9d49533-c142-4cb7-8d54-6a6d51b458e7))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "Device:R") (at 139.7 107.95 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 698024ab-bd78-4be5-8cb1-c09eef71c67f)
|
||||||
|
(property "Reference" "R1" (id 0) (at 142.24 107.315 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "10M" (id 1) (at 142.24 109.855 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 137.922 107.95 90)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 139.7 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Name" "VISHAY_CRCW060310M0FKTABC" (id 4) (at 139.7 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Library" "passives.lib" (id 5) (at 139.7 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Device" "R" (id 6) (at 139.7 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Type" "ADV" (id 7) (at 139.7 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 9258bd9f-6e64-48cb-b10a-9f0ab959f571))
|
||||||
|
(pin "2" (uuid f024f933-67b5-408d-9af7-d6ece6042782))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "Simulation_SPICE:VDC") (at 114.3 107.95 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid 83608f1c-11c0-46f8-ae54-fcb488541f6a)
|
||||||
|
(property "Reference" "VDC" (id 0) (at 118.11 106.045 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Value" "1" (id 1) (at 118.11 108.585 0)
|
||||||
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "~" (id 3) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Device" "V" (id 7) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Pins" "1 2" (id 8) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Params" "dc=1" (id 9) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Model_Type" "DC" (id 10) (at 114.3 107.95 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid de407df0-899c-4dfc-8493-f9d50583d17a))
|
||||||
|
(pin "2" (uuid 77371cba-8f4b-45a2-91a6-f825ae3f9546))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:GND") (at 190.5 114.2622 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid aa1c725b-e908-4ffe-a8e1-dbe74874ec0b)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 190.5 120.6122 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "GND" (id 1) (at 190.5 119.3422 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 190.5 114.2622 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 190.5 114.2622 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 08083956-7f80-48fc-a073-d7e31be1dea5))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:VCC") (at 114.3 101.6 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid b60fd0ca-97bd-4e20-9a27-3046f059d2b9)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 114.3 105.41 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "VCC" (id 1) (at 114.3 97.79 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 114.3 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 114.3 101.6 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 03c6ace1-caf1-4775-b684-3e857b918919))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:GND") (at 114.3 114.3 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid cae1a2a0-561b-4729-802f-81c375ac4c1e)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 114.3 120.65 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "GND" (id 1) (at 114.3 119.38 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 114.3 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 114.3 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid b4bef1f0-ad5b-4c59-87c6-a3d88d776adf))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol (lib_id "power:GND") (at 139.7 114.3 0) (unit 1)
|
||||||
|
(in_bom yes) (on_board yes) (fields_autoplaced)
|
||||||
|
(uuid d829b2e0-05c9-40a0-815e-35a8d1f6cecd)
|
||||||
|
(property "Reference" "#PWR?" (id 0) (at 139.7 120.65 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Value" "GND" (id 1) (at 139.7 119.38 0)
|
||||||
|
(effects (font (size 1.27 1.27)))
|
||||||
|
)
|
||||||
|
(property "Footprint" "" (id 2) (at 139.7 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(property "Datasheet" "" (id 3) (at 139.7 114.3 0)
|
||||||
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
|
)
|
||||||
|
(pin "1" (uuid 924cf866-e3b9-4af1-895c-792ddd27e24d))
|
||||||
|
)
|
||||||
|
|
||||||
|
(sheet_instances
|
||||||
|
(path "/" (page "1"))
|
||||||
|
)
|
||||||
|
|
||||||
|
(symbol_instances
|
||||||
|
(path "/0b5a77ca-f3ff-42b7-8572-0eefa9011bf1"
|
||||||
|
(reference "#PWR?") (unit 1) (value "VCC") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/2f62470a-49dd-4c2d-89e9-a2acc60c442d"
|
||||||
|
(reference "#PWR?") (unit 1) (value "VCC") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/438ece8c-3eb3-4d7e-9271-8a8e8aeb6d3c"
|
||||||
|
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/613737e0-8030-4980-b87e-8290b8a61eaf"
|
||||||
|
(reference "#PWR?") (unit 1) (value "VCC") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/aa1c725b-e908-4ffe-a8e1-dbe74874ec0b"
|
||||||
|
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/b60fd0ca-97bd-4e20-9a27-3046f059d2b9"
|
||||||
|
(reference "#PWR?") (unit 1) (value "VCC") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/cae1a2a0-561b-4729-802f-81c375ac4c1e"
|
||||||
|
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/d829b2e0-05c9-40a0-815e-35a8d1f6cecd"
|
||||||
|
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/6566e118-05df-4951-a19e-df5ca72becf1"
|
||||||
|
(reference "C1") (unit 1) (value "100u") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/65be26d9-e694-445c-9a01-797abd973f29"
|
||||||
|
(reference "L1") (unit 1) (value "220n") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/698024ab-bd78-4be5-8cb1-c09eef71c67f"
|
||||||
|
(reference "R1") (unit 1) (value "10M") (footprint "")
|
||||||
|
)
|
||||||
|
(path "/83608f1c-11c0-46f8-ae54-fcb488541f6a"
|
||||||
|
(reference "VDC") (unit 1) (value "1") (footprint "")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
|
@ -0,0 +1,11 @@
|
||||||
|
*
|
||||||
|
* Resistors
|
||||||
|
.model PT100 R(R=100 Tnom=0 tc1=3.85m noisy=0)
|
||||||
|
.model VISHAY_CRCW060310M0FKTABC R(R=10Meg Tnom=20 tc1=100u) ; bv_max=75 - idk if we should include that
|
||||||
|
|
||||||
|
* Capacitors
|
||||||
|
.model AVX_12066D107MAT4A C(C=100u Tnom=15 tc1=21.4u)
|
||||||
|
|
||||||
|
* Inductors
|
||||||
|
.model AVX_0603WL221GT L(ind=220n Tnom=20 tc1=125u)
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
.MODEL DIODE1 D (IS=100E-15 RS=10 CJO=1P TT=12N BV=120 IBV=100E-15)
|
.MODEL DIODE1 D (IS=100E-15 RS=10 CJO=1P TT=12N BV=120 IBV=100E-15)
|
||||||
|
|
||||||
* Diode 2
|
* Diode 2
|
||||||
.MODEL DIODE2 D (IS=100E-15 RS=8 CJO=1.5P TT=11N BV=100 IBV=100E-15)
|
.MODEL DIODE2 D (JS=100E-15 RS=8 CJ0=1.5P TT=11N BV=100 IBV=100E-15)
|
||||||
|
|
|
@ -320,12 +320,12 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(symbol (lib_id "Simulation_SPICE:VSIN") (at 134.62 101.6 0) (unit 1)
|
(symbol (lib_id "Simulation_SPICE:VSIN") (at 134.62 101.6 0) (unit 1)
|
||||||
(in_bom yes) (on_board yes) (fields_autoplaced)
|
(in_bom yes) (on_board yes)
|
||||||
(uuid 2f4ce84c-7613-4135-9bc6-7662b55052cf)
|
(uuid 2f4ce84c-7613-4135-9bc6-7662b55052cf)
|
||||||
(property "Reference" "V1" (id 0) (at 138.43 99.695 0)
|
(property "Reference" "VSIN" (id 0) (at 118.11 99.06 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Value" "VSIN" (id 1) (at 138.43 102.235 0)
|
(property "Value" "" (id 1) (at 118.11 101.6 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Footprint" "" (id 2) (at 134.62 101.6 0)
|
(property "Footprint" "" (id 2) (at 134.62 101.6 0)
|
||||||
|
@ -334,18 +334,6 @@
|
||||||
(property "Datasheet" "~" (id 3) (at 134.62 101.6 0)
|
(property "Datasheet" "~" (id 3) (at 134.62 101.6 0)
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
(effects (font (size 1.27 1.27)) hide)
|
||||||
)
|
)
|
||||||
(property "Model_Device" "V" (id 4) (at 134.62 101.6 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Type" "SIN" (id 5) (at 134.62 101.6 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Pins" "1 2" (id 6) (at 134.62 101.6 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(property "Model_Params" "dc=0 ampl=5 f=10k" (id 7) (at 134.62 101.6 0)
|
|
||||||
(effects (font (size 1.27 1.27)) hide)
|
|
||||||
)
|
|
||||||
(pin "1" (uuid a29d8f63-65fa-4d69-b0d4-cfa5c00fc5ab))
|
(pin "1" (uuid a29d8f63-65fa-4d69-b0d4-cfa5c00fc5ab))
|
||||||
(pin "2" (uuid 8bfe05fb-6889-4435-80ba-ab2128b151d8))
|
(pin "2" (uuid 8bfe05fb-6889-4435-80ba-ab2128b151d8))
|
||||||
)
|
)
|
||||||
|
@ -406,7 +394,7 @@
|
||||||
(property "Reference" "R1" (id 0) (at 167.64 99.695 0)
|
(property "Reference" "R1" (id 0) (at 167.64 99.695 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Value" "100K" (id 1) (at 167.64 102.235 0)
|
(property "Value" "" (id 1) (at 167.64 102.235 0)
|
||||||
(effects (font (size 1.27 1.27)) (justify left))
|
(effects (font (size 1.27 1.27)) (justify left))
|
||||||
)
|
)
|
||||||
(property "Footprint" "" (id 2) (at 163.322 100.33 90)
|
(property "Footprint" "" (id 2) (at 163.322 100.33 90)
|
||||||
|
@ -458,10 +446,10 @@
|
||||||
(reference "D1") (unit 1) (value "D") (footprint "")
|
(reference "D1") (unit 1) (value "D") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/7ae05049-58f1-4d14-9a95-35ba665c7986"
|
(path "/7ae05049-58f1-4d14-9a95-35ba665c7986"
|
||||||
(reference "R1") (unit 1) (value "100K") (footprint "")
|
(reference "R1") (unit 1) (value "10K") (footprint "")
|
||||||
)
|
)
|
||||||
(path "/2f4ce84c-7613-4135-9bc6-7662b55052cf"
|
(path "/2f4ce84c-7613-4135-9bc6-7662b55052cf"
|
||||||
(reference "V1") (unit 1) (value "VSIN") (footprint "")
|
(reference "VSIN") (unit 1) (value "ampl=5 f=1k") (footprint "")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,8 +34,8 @@ BOOST_AUTO_TEST_CASE( Models )
|
||||||
|
|
||||||
for( NGSPICE::MODEL_TYPE type : NGSPICE::MODEL_TYPE_ITERATOR() )
|
for( NGSPICE::MODEL_TYPE type : NGSPICE::MODEL_TYPE_ITERATOR() )
|
||||||
{
|
{
|
||||||
unsigned int modelParamCount = NGSPICE::ModelInfo( type ).modelParams.size();
|
unsigned modelParamCount = NGSPICE::ModelInfo( type ).modelParams.size();
|
||||||
unsigned int instanceParamCount = NGSPICE::ModelInfo( type ).instanceParams.size();
|
unsigned instanceParamCount = NGSPICE::ModelInfo( type ).instanceParams.size();
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE( Models )
|
||||||
case NGSPICE::MODEL_TYPE::_ENUM_END:
|
case NGSPICE::MODEL_TYPE::_ENUM_END:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NGSPICE::MODEL_TYPE::RESISTOR:
|
/*case NGSPICE::MODEL_TYPE::RESISTOR:
|
||||||
BOOST_CHECK_EQUAL( modelParamCount, 22 );
|
BOOST_CHECK_EQUAL( modelParamCount, 22 );
|
||||||
BOOST_CHECK_EQUAL( instanceParamCount, 25 );
|
BOOST_CHECK_EQUAL( instanceParamCount, 25 );
|
||||||
break;
|
break;
|
||||||
|
@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE( Models )
|
||||||
case NGSPICE::MODEL_TYPE::INDUCTOR:
|
case NGSPICE::MODEL_TYPE::INDUCTOR:
|
||||||
BOOST_CHECK_EQUAL( modelParamCount, 9 );
|
BOOST_CHECK_EQUAL( modelParamCount, 9 );
|
||||||
BOOST_CHECK_EQUAL( instanceParamCount, 20 );
|
BOOST_CHECK_EQUAL( instanceParamCount, 20 );
|
||||||
break;
|
break;*/
|
||||||
|
|
||||||
case NGSPICE::MODEL_TYPE::LTRA:
|
case NGSPICE::MODEL_TYPE::LTRA:
|
||||||
BOOST_CHECK_EQUAL( modelParamCount, 18 );
|
BOOST_CHECK_EQUAL( modelParamCount, 18 );
|
||||||
|
|
|
@ -109,4 +109,10 @@ BOOST_AUTO_TEST_CASE( NpnCeAmp )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( Passives )
|
||||||
|
{
|
||||||
|
TestNetlist( "passives" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
Loading…
Reference in New Issue