ADDED voltage- & current-controlled voltage & current sources
Added GUI support for ngspice VCVS, VCCS, CCVS and CCCS.
This commit is contained in:
parent
24b04795fd
commit
58f4943597
|
@ -47,6 +47,15 @@
|
||||||
using CATEGORY = SIM_MODEL::PARAM::CATEGORY;
|
using CATEGORY = SIM_MODEL::PARAM::CATEGORY;
|
||||||
|
|
||||||
|
|
||||||
|
bool equivalent( SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b )
|
||||||
|
{
|
||||||
|
// A helper to handle SPICE's use of 'E' and 'H' for voltage sources and 'F' and 'G' for
|
||||||
|
// current sources
|
||||||
|
return a == b
|
||||||
|
|| SIM_MODEL::DeviceInfo( a ).description == SIM_MODEL::DeviceInfo( b ).description;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T_symbol, typename T_field>
|
template <typename T_symbol, typename T_field>
|
||||||
DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symbol& aSymbol,
|
DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symbol& aSymbol,
|
||||||
std::vector<T_field>& aFields )
|
std::vector<T_field>& aFields )
|
||||||
|
@ -430,12 +439,12 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::updateInstanceWidgets( SIM_MODEL* aMod
|
||||||
{
|
{
|
||||||
for( SIM_MODEL::DEVICE_T deviceType : SIM_MODEL::DEVICE_T_ITERATOR() )
|
for( SIM_MODEL::DEVICE_T deviceType : SIM_MODEL::DEVICE_T_ITERATOR() )
|
||||||
{
|
{
|
||||||
if( !SIM_MODEL::DeviceInfo( deviceType ).isBuiltin )
|
if( !SIM_MODEL::DeviceInfo( deviceType ).showInMenu )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_deviceTypeChoice->Append( SIM_MODEL::DeviceInfo( deviceType ).description );
|
m_deviceTypeChoice->Append( SIM_MODEL::DeviceInfo( deviceType ).description );
|
||||||
|
|
||||||
if( deviceType == aModel->GetDeviceType() )
|
if( equivalent( deviceType, aModel->GetDeviceType() ) )
|
||||||
m_deviceTypeChoice->SetSelection( m_deviceTypeChoice->GetCount() - 1 );
|
m_deviceTypeChoice->SetSelection( m_deviceTypeChoice->GetCount() - 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +453,10 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::updateInstanceWidgets( SIM_MODEL* aMod
|
||||||
|
|
||||||
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
|
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
|
||||||
{
|
{
|
||||||
if( SIM_MODEL::TypeInfo( type ).deviceType == aModel->GetDeviceType() )
|
SIM_MODEL::DEVICE_T deviceType = SIM_MODEL::TypeInfo( type ).deviceType;
|
||||||
|
|
||||||
|
if( deviceType == aModel->GetDeviceType()
|
||||||
|
|| SIM_MODEL::DeviceInfo( deviceType ).description == aModel->GetDeviceInfo().description )
|
||||||
{
|
{
|
||||||
m_typeChoice->Append( SIM_MODEL::TypeInfo( type ).description );
|
m_typeChoice->Append( SIM_MODEL::TypeInfo( type ).description );
|
||||||
|
|
||||||
|
@ -1203,7 +1215,7 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onTypeChoice( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
|
for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
|
||||||
{
|
{
|
||||||
if( deviceType == SIM_MODEL::TypeInfo( type ).deviceType
|
if( equivalent( deviceType, SIM_MODEL::TypeInfo( type ).deviceType )
|
||||||
&& typeDescription == SIM_MODEL::TypeInfo( type ).description )
|
&& typeDescription == SIM_MODEL::TypeInfo( type ).description )
|
||||||
{
|
{
|
||||||
if( isIbisLoaded()
|
if( isIbisLoaded()
|
||||||
|
|
|
@ -79,6 +79,10 @@ SIM_MODEL::DEVICE_INFO SIM_MODEL::DeviceInfo( DEVICE_T aDeviceType )
|
||||||
|
|
||||||
case DEVICE_T::V: return { "V", "Voltage Source", true };
|
case DEVICE_T::V: return { "V", "Voltage Source", true };
|
||||||
case DEVICE_T::I: return { "I", "Current Source", true };
|
case DEVICE_T::I: return { "I", "Current Source", true };
|
||||||
|
case DEVICE_T::E: return { "E", "Voltage Source", false };
|
||||||
|
case DEVICE_T::F: return { "F", "Current Source", false };
|
||||||
|
case DEVICE_T::G: return { "G", "Current Source", false };
|
||||||
|
case DEVICE_T::H: return { "H", "Voltage Source", false };
|
||||||
|
|
||||||
case DEVICE_T::KIBIS: return { "IBIS", "IBIS Model", false };
|
case DEVICE_T::KIBIS: return { "IBIS", "IBIS Model", false };
|
||||||
|
|
||||||
|
@ -184,8 +188,10 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType )
|
||||||
case TYPE::V_SIN: return { DEVICE_T::V, "SIN", "Sine" };
|
case TYPE::V_SIN: return { DEVICE_T::V, "SIN", "Sine" };
|
||||||
case TYPE::V_PULSE: return { DEVICE_T::V, "PULSE", "Pulse" };
|
case TYPE::V_PULSE: return { DEVICE_T::V, "PULSE", "Pulse" };
|
||||||
case TYPE::V_EXP: return { DEVICE_T::V, "EXP", "Exponential" };
|
case TYPE::V_EXP: return { DEVICE_T::V, "EXP", "Exponential" };
|
||||||
//case TYPE::V_SFAM: return { DEVICE_TYPE::V, "SFAM", "Single-frequency AM" };
|
//case TYPE::V_SFAM: return { DEVICE_T::V, "SFAM", "Single-frequency AM" };
|
||||||
//case TYPE::V_SFFM: return { DEVICE_TYPE::V, "SFFM", "Single-frequency FM" };
|
//case TYPE::V_SFFM: return { DEVICE_T::V, "SFFM", "Single-frequency FM" };
|
||||||
|
case TYPE::V_VCL: return { DEVICE_T::E, "", "Voltage-controlled" };
|
||||||
|
case TYPE::V_CCL: return { DEVICE_T::H, "", "Current-controlled" };
|
||||||
case TYPE::V_PWL: return { DEVICE_T::V, "PWL", "Piecewise linear" };
|
case TYPE::V_PWL: return { DEVICE_T::V, "PWL", "Piecewise linear" };
|
||||||
case TYPE::V_WHITENOISE: return { DEVICE_T::V, "WHITENOISE", "White noise" };
|
case TYPE::V_WHITENOISE: return { DEVICE_T::V, "WHITENOISE", "White noise" };
|
||||||
case TYPE::V_PINKNOISE: return { DEVICE_T::V, "PINKNOISE", "Pink noise (1/f)" };
|
case TYPE::V_PINKNOISE: return { DEVICE_T::V, "PINKNOISE", "Pink noise (1/f)" };
|
||||||
|
@ -193,15 +199,17 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType )
|
||||||
case TYPE::V_RANDUNIFORM: return { DEVICE_T::V, "RANDUNIFORM", "Random uniform" };
|
case TYPE::V_RANDUNIFORM: return { DEVICE_T::V, "RANDUNIFORM", "Random uniform" };
|
||||||
case TYPE::V_RANDNORMAL: return { DEVICE_T::V, "RANDNORMAL", "Random normal" };
|
case TYPE::V_RANDNORMAL: return { DEVICE_T::V, "RANDNORMAL", "Random normal" };
|
||||||
case TYPE::V_RANDEXP: return { DEVICE_T::V, "RANDEXP", "Random exponential" };
|
case TYPE::V_RANDEXP: return { DEVICE_T::V, "RANDEXP", "Random exponential" };
|
||||||
//case TYPE::V_RANDPOISSON: return { DEVICE_TYPE::V, "RANDPOISSON", "Random Poisson" };
|
//case TYPE::V_RANDPOISSON: return { DEVICE_T::V, "RANDPOISSON", "Random Poisson" };
|
||||||
case TYPE::V_BEHAVIORAL: return { DEVICE_T::V, "=", "Behavioral" };
|
case TYPE::V_BEHAVIORAL: return { DEVICE_T::V, "=", "Behavioral" };
|
||||||
|
|
||||||
case TYPE::I: return { DEVICE_T::I, "DC", "DC", };
|
case TYPE::I: return { DEVICE_T::I, "DC", "DC", };
|
||||||
case TYPE::I_SIN: return { DEVICE_T::I, "SIN", "Sine" };
|
case TYPE::I_SIN: return { DEVICE_T::I, "SIN", "Sine" };
|
||||||
case TYPE::I_PULSE: return { DEVICE_T::I, "PULSE", "Pulse" };
|
case TYPE::I_PULSE: return { DEVICE_T::I, "PULSE", "Pulse" };
|
||||||
case TYPE::I_EXP: return { DEVICE_T::I, "EXP", "Exponential" };
|
case TYPE::I_EXP: return { DEVICE_T::I, "EXP", "Exponential" };
|
||||||
//case TYPE::I_SFAM: return { DEVICE_TYPE::I, "SFAM", "Single-frequency AM" };
|
//case TYPE::I_SFAM: return { DEVICE_T::I, "SFAM", "Single-frequency AM" };
|
||||||
//case TYPE::I_SFFM: return { DEVICE_TYPE::I, "SFFM", "Single-frequency FM" };
|
//case TYPE::I_SFFM: return { DEVICE_T::I, "SFFM", "Single-frequency FM" };
|
||||||
|
case TYPE::I_VCL: return { DEVICE_T::G, "", "Voltage-controlled" };
|
||||||
|
case TYPE::I_CCL: return { DEVICE_T::F, "", "Current-controlled" };
|
||||||
case TYPE::I_PWL: return { DEVICE_T::I, "PWL", "Piecewise linear" };
|
case TYPE::I_PWL: return { DEVICE_T::I, "PWL", "Piecewise linear" };
|
||||||
case TYPE::I_WHITENOISE: return { DEVICE_T::I, "WHITENOISE", "White noise" };
|
case TYPE::I_WHITENOISE: return { DEVICE_T::I, "WHITENOISE", "White noise" };
|
||||||
case TYPE::I_PINKNOISE: return { DEVICE_T::I, "PINKNOISE", "Pink noise (1/f)" };
|
case TYPE::I_PINKNOISE: return { DEVICE_T::I, "PINKNOISE", "Pink noise (1/f)" };
|
||||||
|
@ -209,7 +217,7 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType )
|
||||||
case TYPE::I_RANDUNIFORM: return { DEVICE_T::I, "RANDUNIFORM", "Random uniform" };
|
case TYPE::I_RANDUNIFORM: return { DEVICE_T::I, "RANDUNIFORM", "Random uniform" };
|
||||||
case TYPE::I_RANDNORMAL: return { DEVICE_T::I, "RANDNORMAL", "Random normal" };
|
case TYPE::I_RANDNORMAL: return { DEVICE_T::I, "RANDNORMAL", "Random normal" };
|
||||||
case TYPE::I_RANDEXP: return { DEVICE_T::I, "RANDEXP", "Random exponential" };
|
case TYPE::I_RANDEXP: return { DEVICE_T::I, "RANDEXP", "Random exponential" };
|
||||||
//case TYPE::I_RANDPOISSON: return { DEVICE_TYPE::I, "RANDPOISSON", "Random Poisson" };
|
//case TYPE::I_RANDPOISSON: return { DEVICE_T::I, "RANDPOISSON", "Random Poisson" };
|
||||||
case TYPE::I_BEHAVIORAL: return { DEVICE_T::I, "=", "Behavioral" };
|
case TYPE::I_BEHAVIORAL: return { DEVICE_T::I, "=", "Behavioral" };
|
||||||
|
|
||||||
case TYPE::SUBCKT: return { DEVICE_T::SUBCKT, "", "Subcircuit" };
|
case TYPE::SUBCKT: return { DEVICE_T::SUBCKT, "", "Subcircuit" };
|
||||||
|
@ -319,6 +327,8 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
||||||
case TYPE::V_EXP: return { "V", "", "EXP" };
|
case TYPE::V_EXP: return { "V", "", "EXP" };
|
||||||
//case TYPE::V_SFAM: return { "V", "", "AM" };
|
//case TYPE::V_SFAM: return { "V", "", "AM" };
|
||||||
//case TYPE::V_SFFM: return { "V", "", "SFFM" };
|
//case TYPE::V_SFFM: return { "V", "", "SFFM" };
|
||||||
|
case TYPE::V_VCL: return { "E", "", "" };
|
||||||
|
case TYPE::V_CCL: return { "H", "", "" };
|
||||||
case TYPE::V_PWL: return { "V", "", "PWL" };
|
case TYPE::V_PWL: return { "V", "", "PWL" };
|
||||||
case TYPE::V_WHITENOISE: return { "V", "", "TRNOISE" };
|
case TYPE::V_WHITENOISE: return { "V", "", "TRNOISE" };
|
||||||
case TYPE::V_PINKNOISE: return { "V", "", "TRNOISE" };
|
case TYPE::V_PINKNOISE: return { "V", "", "TRNOISE" };
|
||||||
|
@ -335,6 +345,8 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
||||||
case TYPE::I_EXP: return { "I", "", "EXP" };
|
case TYPE::I_EXP: return { "I", "", "EXP" };
|
||||||
//case TYPE::I_SFAM: return { "V", "", "AM" };
|
//case TYPE::I_SFAM: return { "V", "", "AM" };
|
||||||
//case TYPE::I_SFFM: return { "V", "", "SFFM" };
|
//case TYPE::I_SFFM: return { "V", "", "SFFM" };
|
||||||
|
case TYPE::I_VCL: return { "G", "", "" };
|
||||||
|
case TYPE::I_CCL: return { "F", "", "" };
|
||||||
case TYPE::I_PWL: return { "I", "", "PWL" };
|
case TYPE::I_PWL: return { "I", "", "PWL" };
|
||||||
case TYPE::I_WHITENOISE: return { "I", "", "TRNOISE" };
|
case TYPE::I_WHITENOISE: return { "I", "", "TRNOISE" };
|
||||||
case TYPE::I_PINKNOISE: return { "I", "", "TRNOISE" };
|
case TYPE::I_PINKNOISE: return { "I", "", "TRNOISE" };
|
||||||
|
@ -910,7 +922,11 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType )
|
||||||
case TYPE::I_SFAM:
|
case TYPE::I_SFAM:
|
||||||
case TYPE::V_SFFM:
|
case TYPE::V_SFFM:
|
||||||
case TYPE::I_SFFM:*/
|
case TYPE::I_SFFM:*/
|
||||||
|
case TYPE::V_VCL:
|
||||||
|
case TYPE::V_CCL:
|
||||||
case TYPE::V_PWL:
|
case TYPE::V_PWL:
|
||||||
|
case TYPE::I_VCL:
|
||||||
|
case TYPE::I_CCL:
|
||||||
case TYPE::I_PWL:
|
case TYPE::I_PWL:
|
||||||
case TYPE::V_WHITENOISE:
|
case TYPE::V_WHITENOISE:
|
||||||
case TYPE::I_WHITENOISE:
|
case TYPE::I_WHITENOISE:
|
||||||
|
|
|
@ -92,6 +92,10 @@ public:
|
||||||
|
|
||||||
V,
|
V,
|
||||||
I,
|
I,
|
||||||
|
E,
|
||||||
|
F,
|
||||||
|
G,
|
||||||
|
H,
|
||||||
|
|
||||||
SUBCKT,
|
SUBCKT,
|
||||||
XSPICE,
|
XSPICE,
|
||||||
|
@ -105,7 +109,7 @@ public:
|
||||||
{
|
{
|
||||||
std::string fieldValue;
|
std::string fieldValue;
|
||||||
std::string description;
|
std::string description;
|
||||||
bool isBuiltin;
|
bool showInMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,8 +231,10 @@ public:
|
||||||
V_SIN,
|
V_SIN,
|
||||||
V_PULSE,
|
V_PULSE,
|
||||||
V_EXP,
|
V_EXP,
|
||||||
/*V_SFAM,
|
//V_SFAM,
|
||||||
V_SFFM,*/
|
//V_SFFM,
|
||||||
|
V_VCL,
|
||||||
|
V_CCL,
|
||||||
V_PWL,
|
V_PWL,
|
||||||
V_WHITENOISE,
|
V_WHITENOISE,
|
||||||
V_PINKNOISE,
|
V_PINKNOISE,
|
||||||
|
@ -243,8 +249,10 @@ public:
|
||||||
I_SIN,
|
I_SIN,
|
||||||
I_PULSE,
|
I_PULSE,
|
||||||
I_EXP,
|
I_EXP,
|
||||||
/*I_SFAM,
|
//I_SFAM,
|
||||||
I_SFFM,*/
|
//I_SFFM,
|
||||||
|
I_VCL,
|
||||||
|
I_CCL,
|
||||||
I_PWL,
|
I_PWL,
|
||||||
I_WHITENOISE,
|
I_WHITENOISE,
|
||||||
I_PINKNOISE,
|
I_PINKNOISE,
|
||||||
|
|
|
@ -110,17 +110,17 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR
|
||||||
|
|
||||||
KIBIS_PARAMETER kparams;
|
KIBIS_PARAMETER kparams;
|
||||||
|
|
||||||
if ( m_model.FindParam( "vcc" ) )
|
if( const SIM_MODEL::PARAM* vcc = m_model.FindParam( "vcc" ) )
|
||||||
kparams.SetCornerFromString( kparams.m_supply, m_model.FindParam( "vcc" )->value );
|
kparams.SetCornerFromString( kparams.m_supply, vcc->value );
|
||||||
|
|
||||||
if ( m_model.FindParam( "rpin" ) )
|
if( const SIM_MODEL::PARAM* rpin = m_model.FindParam( "rpin" ) )
|
||||||
kparams.SetCornerFromString( kparams.m_Rpin, m_model.FindParam( "rpin" )->value );
|
kparams.SetCornerFromString( kparams.m_Rpin, rpin->value );
|
||||||
|
|
||||||
if ( m_model.FindParam( "lpin" ) )
|
if( const SIM_MODEL::PARAM* lpin = m_model.FindParam( "lpin" ) )
|
||||||
kparams.SetCornerFromString( kparams.m_Lpin, m_model.FindParam( "lpin" )->value );
|
kparams.SetCornerFromString( kparams.m_Lpin, lpin->value );
|
||||||
|
|
||||||
if ( m_model.FindParam( "cpin" ) )
|
if( const SIM_MODEL::PARAM* cpin = m_model.FindParam( "cpin" ) )
|
||||||
kparams.SetCornerFromString( kparams.m_Cpin, m_model.FindParam( "cpin" )->value );
|
kparams.SetCornerFromString( kparams.m_Cpin, cpin->value );
|
||||||
|
|
||||||
//kparams.SetCornerFromString( kparams.m_Ccomp, FindParam( "ccomp" )->value );
|
//kparams.SetCornerFromString( kparams.m_Ccomp, FindParam( "ccomp" )->value );
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR
|
||||||
{
|
{
|
||||||
std::string paramValue = "";
|
std::string paramValue = "";
|
||||||
|
|
||||||
if ( m_model.FindParam( "dc" ) )
|
if( const SIM_MODEL::PARAM* dc = m_model.FindParam( "dc" ) )
|
||||||
paramValue = m_model.FindParam( "dc" )->value;
|
paramValue = dc->value;
|
||||||
|
|
||||||
if( paramValue == "hi-Z" )
|
if( paramValue == "hi-Z" )
|
||||||
{
|
{
|
||||||
|
@ -166,17 +166,17 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR
|
||||||
{
|
{
|
||||||
KIBIS_WAVEFORM_RECTANGULAR* waveform = new KIBIS_WAVEFORM_RECTANGULAR( &kibis );
|
KIBIS_WAVEFORM_RECTANGULAR* waveform = new KIBIS_WAVEFORM_RECTANGULAR( &kibis );
|
||||||
|
|
||||||
if ( m_model.FindParam( "ton" ) )
|
if( const SIM_MODEL::PARAM* ton = m_model.FindParam( "ton" ) )
|
||||||
waveform->m_ton = SIM_VALUE::ToDouble( m_model.FindParam( "ton" )->value, 1 );
|
waveform->m_ton = SIM_VALUE::ToDouble( ton->value, 1 );
|
||||||
|
|
||||||
if ( m_model.FindParam( "toff" ) )
|
if( const SIM_MODEL::PARAM* toff = m_model.FindParam( "toff" ) )
|
||||||
waveform->m_toff = SIM_VALUE::ToDouble( m_model.FindParam( "toff" )->value, 1 );
|
waveform->m_toff = SIM_VALUE::ToDouble( toff->value, 1 );
|
||||||
|
|
||||||
if ( m_model.FindParam( "td" ) )
|
if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
|
||||||
waveform->m_delay = SIM_VALUE::ToDouble( m_model.FindParam( "td" )->value, 0 );
|
waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
|
||||||
|
|
||||||
if ( m_model.FindParam( "n" ) )
|
if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
|
||||||
waveform->m_cycles = SIM_VALUE::ToInt( m_model.FindParam( "n" )->value, 1 );
|
waveform->m_cycles = SIM_VALUE::ToInt( n->value, 1 );
|
||||||
|
|
||||||
kparams.m_waveform = waveform;
|
kparams.m_waveform = waveform;
|
||||||
|
|
||||||
|
@ -191,14 +191,14 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const PR
|
||||||
{
|
{
|
||||||
KIBIS_WAVEFORM_PRBS* waveform = new KIBIS_WAVEFORM_PRBS( &kibis );
|
KIBIS_WAVEFORM_PRBS* waveform = new KIBIS_WAVEFORM_PRBS( &kibis );
|
||||||
|
|
||||||
if ( m_model.FindParam( "f0" ) )
|
if( const SIM_MODEL::PARAM* f0 = m_model.FindParam( "f0" ) )
|
||||||
waveform->m_bitrate = SIM_VALUE::ToDouble( m_model.FindParam( "f0" )->value, 0 );
|
waveform->m_bitrate = SIM_VALUE::ToDouble( f0->value, 0 );
|
||||||
|
|
||||||
if ( m_model.FindParam( "td" ) )
|
if( const SIM_MODEL::PARAM* td = m_model.FindParam( "td" ) )
|
||||||
waveform->m_delay = SIM_VALUE::ToDouble( m_model.FindParam( "td" )->value, 0 );
|
waveform->m_delay = SIM_VALUE::ToDouble( td->value, 0 );
|
||||||
|
|
||||||
if ( m_model.FindParam( "n" ) )
|
if( const SIM_MODEL::PARAM* n = m_model.FindParam( "n" ) )
|
||||||
waveform->m_bits = SIM_VALUE::ToInt( m_model.FindParam( "n" )->value, 0 );
|
waveform->m_bits = SIM_VALUE::ToInt( n->value, 0 );
|
||||||
|
|
||||||
kparams.m_waveform = waveform;
|
kparams.m_waveform = waveform;
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ std::string SPICE_GENERATOR_R_POT::ModelLine( const SPICE_ITEM& aItem ) const
|
||||||
std::string r = "0";
|
std::string r = "0";
|
||||||
std::string position = "";
|
std::string position = "";
|
||||||
|
|
||||||
if ( m_model.FindParam( "r" ) )
|
if( const SIM_MODEL::PARAM* r_param = m_model.FindParam( "r" ) )
|
||||||
r = SIM_VALUE::ToSpice( m_model.FindParam( "r" )->value );
|
r = SIM_VALUE::ToSpice( r_param->value );
|
||||||
|
|
||||||
if ( m_model.FindParam( "pos" ) )
|
if( const SIM_MODEL::PARAM* pos_param = m_model.FindParam( "pos" ) )
|
||||||
position = SIM_VALUE::ToSpice( m_model.FindParam( "pos" )->value );
|
position = SIM_VALUE::ToSpice( pos_param->value );
|
||||||
|
|
||||||
if( position != "" )
|
if( position != "" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,10 +52,10 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
|
||||||
std::string ac = "";
|
std::string ac = "";
|
||||||
std::string dc = "";
|
std::string dc = "";
|
||||||
|
|
||||||
if( m_model.FindParam( "ac" ) )
|
if( const SIM_MODEL::PARAM* ac_param = m_model.FindParam( "ac" ) )
|
||||||
ac = SIM_VALUE::ToSpice( m_model.FindParam( "ac" )->value );
|
ac = SIM_VALUE::ToSpice( ac_param->value );
|
||||||
if( m_model.FindParam( "dc" ) )
|
if( const SIM_MODEL::PARAM* dc_param = m_model.FindParam( "dc" ) )
|
||||||
dc = SIM_VALUE::ToSpice( m_model.FindParam( "dc" )->value );
|
dc = SIM_VALUE::ToSpice( dc_param->value );
|
||||||
|
|
||||||
bool emptyLine = true;
|
bool emptyLine = true;
|
||||||
item.modelName = "";
|
item.modelName = "";
|
||||||
|
@ -140,7 +140,7 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
|
||||||
case SIM_MODEL::TYPE::V_RANDUNIFORM:
|
case SIM_MODEL::TYPE::V_RANDUNIFORM:
|
||||||
case SIM_MODEL::TYPE::I_RANDUNIFORM:
|
case SIM_MODEL::TYPE::I_RANDUNIFORM:
|
||||||
{
|
{
|
||||||
/* JEY TODO
|
/* TODO
|
||||||
args.append( "1 " );
|
args.append( "1 " );
|
||||||
args.append( getParamValueString( "dt", "0" ) + " " );
|
args.append( getParamValueString( "dt", "0" ) + " " );
|
||||||
args.append( getParamValueString( "td", "0" ) + " " );
|
args.append( getParamValueString( "td", "0" ) + " " );
|
||||||
|
@ -182,14 +182,16 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
|
||||||
args.append( getParamValueString( "offset", "0" ) + " " );
|
args.append( getParamValueString( "offset", "0" ) + " " );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*case SIM_MODEL::TYPE::V_RANDPOISSON:
|
/*
|
||||||
|
case SIM_MODEL::TYPE::V_RANDPOISSON:
|
||||||
case SIM_MODEL::TYPE::I_RANDPOISSON:
|
case SIM_MODEL::TYPE::I_RANDPOISSON:
|
||||||
args.append( "4 " );
|
args.append( "4 " );
|
||||||
args.append( FindParam( "dt" )->value->ToSpiceString() + " " );
|
args.append( getParamValueString( "dt", "0" ) + " " );
|
||||||
args.append( FindParam( "td" )->value->ToSpiceString() + " " );
|
args.append( getParamValueString( "td", "0" ) + " " );
|
||||||
args.append( FindParam( "lambda" )->value->ToSpiceString() + " " );
|
args.append( getParamValueString( "lambda", "0" ) + " " );
|
||||||
args.append( FindParam( "offset" )->value->ToSpiceString() + " " );
|
args.append( getParamValueString( "offset", "0" ) + " " );
|
||||||
break;*/
|
break;
|
||||||
|
*/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
for( const SIM_MODEL::PARAM& param : m_model.GetParams() )
|
for( const SIM_MODEL::PARAM& param : m_model.GetParams() )
|
||||||
|
@ -206,13 +208,39 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
|
||||||
emptyLine = false;
|
emptyLine = false;
|
||||||
item.modelName += fmt::format( "{}( {}) ", m_model.GetSpiceInfo().inlineTypeString, args );
|
item.modelName += fmt::format( "{}( {}) ", m_model.GetSpiceInfo().inlineTypeString, args );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch( m_model.GetType() )
|
||||||
|
case SIM_MODEL::TYPE::V_VCL:
|
||||||
|
case SIM_MODEL::TYPE::I_VCL:
|
||||||
|
{
|
||||||
|
item.modelName += fmt::format( "{} ", getParamValueString( "gain", "1.0" ) );
|
||||||
|
emptyLine = false;
|
||||||
|
|
||||||
|
if( const SIM_MODEL::PARAM* ic = m_model.FindParam( "ic" ) )
|
||||||
|
item.modelName += fmt::format( "ic={}", SIM_VALUE::ToSpice( ic->value ) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIM_MODEL::TYPE::V_CCL:
|
||||||
|
case SIM_MODEL::TYPE::I_CCL:
|
||||||
|
item.modelName += fmt::format( "{} {} ",
|
||||||
|
getParamValueString( "control", "V?" ),
|
||||||
|
getParamValueString( "gain", "1.0" ) );
|
||||||
|
emptyLine = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( ac != "" )
|
if( ac != "" )
|
||||||
{
|
{
|
||||||
std::string ph = "";
|
std::string ph = "";
|
||||||
|
|
||||||
if( m_model.FindParam( "ph" ) )
|
if( const SIM_MODEL::PARAM* ph_param = m_model.FindParam( "ph" ) )
|
||||||
ph = SIM_VALUE::ToSpice( m_model.FindParam( "ph" )->value );
|
ph = SIM_VALUE::ToSpice( ph_param->value );
|
||||||
|
|
||||||
emptyLine = false;
|
emptyLine = false;
|
||||||
item.modelName += fmt::format( "AC {} {}", ac, ph );
|
item.modelName += fmt::format( "AC {} {}", ac, ph );
|
||||||
|
@ -300,7 +328,12 @@ const std::vector<SIM_MODEL::PARAM::INFO>& SIM_MODEL_SOURCE::makeParamInfos( TYP
|
||||||
static std::vector<PARAM::INFO> vsffm = makeSffmParamInfos( "y", "V" );
|
static std::vector<PARAM::INFO> vsffm = makeSffmParamInfos( "y", "V" );
|
||||||
static std::vector<PARAM::INFO> isffm = makeSffmParamInfos( "y", "A" );*/
|
static std::vector<PARAM::INFO> isffm = makeSffmParamInfos( "y", "A" );*/
|
||||||
|
|
||||||
|
static std::vector<PARAM::INFO> vcvs = makeVcParamInfos( "" );
|
||||||
|
static std::vector<PARAM::INFO> ccvs = makeCcParamInfos( "ohm" );
|
||||||
static std::vector<PARAM::INFO> vpwl = makePwlParamInfos( "y", "Voltage", "V" );
|
static std::vector<PARAM::INFO> vpwl = makePwlParamInfos( "y", "Voltage", "V" );
|
||||||
|
|
||||||
|
static std::vector<PARAM::INFO> vccs = makeVcParamInfos( "S" );
|
||||||
|
static std::vector<PARAM::INFO> cccs = makeCcParamInfos( "" );
|
||||||
static std::vector<PARAM::INFO> ipwl = makePwlParamInfos( "y", "Current", "A" );
|
static std::vector<PARAM::INFO> ipwl = makePwlParamInfos( "y", "Current", "A" );
|
||||||
|
|
||||||
static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoiseParamInfos( "y", "V" );
|
static std::vector<PARAM::INFO> vwhitenoise = makeWhiteNoiseParamInfos( "y", "V" );
|
||||||
|
@ -334,11 +367,15 @@ const std::vector<SIM_MODEL::PARAM::INFO>& SIM_MODEL_SOURCE::makeParamInfos( TYP
|
||||||
case TYPE::I_PULSE: return ipulse;
|
case TYPE::I_PULSE: return ipulse;
|
||||||
case TYPE::V_EXP: return vexp;
|
case TYPE::V_EXP: return vexp;
|
||||||
case TYPE::I_EXP: return iexp;
|
case TYPE::I_EXP: return iexp;
|
||||||
/*case TYPE::V_SFAM: return vsfam;
|
//case TYPE::V_SFAM: return vsfam;
|
||||||
case TYPE::I_SFAM: return isfam;
|
//case TYPE::I_SFAM: return isfam;
|
||||||
case TYPE::V_SFFM: return vsffm;
|
//case TYPE::V_SFFM: return vsffm;
|
||||||
case TYPE::I_SFFM: return isffm;*/
|
//case TYPE::I_SFFM: return isffm;
|
||||||
|
case TYPE::V_VCL: return vcvs;
|
||||||
|
case TYPE::V_CCL: return ccvs;
|
||||||
case TYPE::V_PWL: return vpwl;
|
case TYPE::V_PWL: return vpwl;
|
||||||
|
case TYPE::I_VCL: return vccs;
|
||||||
|
case TYPE::I_CCL: return cccs;
|
||||||
case TYPE::I_PWL: return ipwl;
|
case TYPE::I_PWL: return ipwl;
|
||||||
case TYPE::V_WHITENOISE: return vwhitenoise;
|
case TYPE::V_WHITENOISE: return vwhitenoise;
|
||||||
case TYPE::I_WHITENOISE: return iwhitenoise;
|
case TYPE::I_WHITENOISE: return iwhitenoise;
|
||||||
|
@ -689,6 +726,51 @@ std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeSffmParamInfos( std::s
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeCcParamInfos( std::string aGainUnit )
|
||||||
|
{
|
||||||
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
|
PARAM::INFO paramInfo;
|
||||||
|
|
||||||
|
paramInfo.name = "gain";
|
||||||
|
paramInfo.id = 1;
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE_FLOAT;
|
||||||
|
paramInfo.unit = aGainUnit;
|
||||||
|
paramInfo.description = "Gain";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "control";
|
||||||
|
paramInfo.id = 2;
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE_STRING;
|
||||||
|
paramInfo.description = "Controlling voltage source";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
return paramInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makeVcParamInfos( std::string aGainUnit )
|
||||||
|
{
|
||||||
|
std::vector<PARAM::INFO> paramInfos;
|
||||||
|
PARAM::INFO paramInfo;
|
||||||
|
|
||||||
|
paramInfo.name = "gain";
|
||||||
|
paramInfo.id = 1;
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE_FLOAT;
|
||||||
|
paramInfo.unit = aGainUnit;
|
||||||
|
paramInfo.description = "Gain";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
paramInfo.name = "ic";
|
||||||
|
paramInfo.id = 7;
|
||||||
|
paramInfo.type = SIM_VALUE::TYPE_FLOAT;
|
||||||
|
paramInfo.unit = "V";
|
||||||
|
paramInfo.description = "Initial condition of controlling source (ic)";
|
||||||
|
paramInfos.push_back( paramInfo );
|
||||||
|
|
||||||
|
return paramInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePwlParamInfos( std::string aPrefix,
|
std::vector<SIM_MODEL::PARAM::INFO> SIM_MODEL_SOURCE::makePwlParamInfos( std::string aPrefix,
|
||||||
std::string aQuantity,
|
std::string aQuantity,
|
||||||
std::string aUnit )
|
std::string aUnit )
|
||||||
|
@ -1051,3 +1133,12 @@ void SIM_MODEL_SOURCE::appendAcParamInfos( std::vector<PARAM::INFO>& aParamInfos
|
||||||
paramInfo.description = "AC phase";
|
paramInfo.description = "AC phase";
|
||||||
aParamInfos.push_back( paramInfo );
|
aParamInfos.push_back( paramInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::string> SIM_MODEL_SOURCE::GetPinNames() const
|
||||||
|
{
|
||||||
|
if( GetDeviceType() == SIM_MODEL::DEVICE_T::E || GetDeviceType() == SIM_MODEL::DEVICE_T::G )
|
||||||
|
return { "+", "-", "C+", "C-" };
|
||||||
|
else
|
||||||
|
return { "+", "-" };
|
||||||
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
bool HasAutofill() const override { return true; }
|
bool HasAutofill() const override { return true; }
|
||||||
bool HasPrimaryValue() const override { return GetType() == TYPE::V || GetType() == TYPE::I; }
|
bool HasPrimaryValue() const override { return GetType() == TYPE::V || GetType() == TYPE::I; }
|
||||||
|
|
||||||
std::vector<std::string> GetPinNames() const override { return { "+", "-" }; }
|
std::vector<std::string> GetPinNames() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doSetParamValue( int aParamIndex, const std::string& aValue ) override;
|
void doSetParamValue( int aParamIndex, const std::string& aValue ) override;
|
||||||
|
@ -88,6 +88,8 @@ private:
|
||||||
static std::vector<PARAM::INFO> makeExpParamInfos( std::string aPrefix, std::string aUnit );
|
static std::vector<PARAM::INFO> makeExpParamInfos( std::string aPrefix, std::string aUnit );
|
||||||
//static std::vector<PARAM::INFO> makeSfamParamInfos( std::string aPrefix, std::string aUnit );
|
//static std::vector<PARAM::INFO> makeSfamParamInfos( std::string aPrefix, std::string aUnit );
|
||||||
//static std::vector<PARAM::INFO> makeSffmParamInfos( std::string aPrefix, std::string aUnit );
|
//static std::vector<PARAM::INFO> makeSffmParamInfos( std::string aPrefix, std::string aUnit );
|
||||||
|
static std::vector<SIM_MODEL::PARAM::INFO> makeVcParamInfos( std::string aGainUnit );
|
||||||
|
static std::vector<SIM_MODEL::PARAM::INFO> makeCcParamInfos( std::string aGainUnit );
|
||||||
static std::vector<PARAM::INFO> makePwlParamInfos( std::string aPrefix, std::string aQuantity,
|
static std::vector<PARAM::INFO> makePwlParamInfos( std::string aPrefix, std::string aQuantity,
|
||||||
std::string aUnit );
|
std::string aUnit );
|
||||||
static std::vector<PARAM::INFO> makeWhiteNoiseParamInfos( std::string aPrefix, std::string aUnit );
|
static std::vector<PARAM::INFO> makeWhiteNoiseParamInfos( std::string aPrefix, std::string aUnit );
|
||||||
|
|
Loading…
Reference in New Issue