Only write included models if they have overridden parameters.
Fixes https://gitlab.com/kicad/code/kicad/issues/13953
(cherry picked from commit 5a12e5ee76
)
This commit is contained in:
parent
eccf9eb4a4
commit
f604bcb557
|
@ -883,42 +883,6 @@ void SIM_MODEL::SetParamValue( const std::string& aParamName, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::HasOverrides() const
|
|
||||||
{
|
|
||||||
for( const PARAM& param : m_params )
|
|
||||||
{
|
|
||||||
if( param.value != "" )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::HasNonInstanceOverrides() const
|
|
||||||
{
|
|
||||||
for( const PARAM& param : m_params )
|
|
||||||
{
|
|
||||||
if( !param.info.isInstanceParam && param.value != "" )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL::HasSpiceNonInstanceOverrides() const
|
|
||||||
{
|
|
||||||
for( const PARAM& param : m_params )
|
|
||||||
{
|
|
||||||
if( !param.info.isSpiceInstanceParam && param.value != "" )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType )
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType )
|
||||||
{
|
{
|
||||||
switch( aType )
|
switch( aType )
|
||||||
|
|
|
@ -480,10 +480,6 @@ public:
|
||||||
void SetParamValue( const std::string& aParamName, const std::string& aValue,
|
void SetParamValue( const std::string& aParamName, const std::string& aValue,
|
||||||
SIM_VALUE::NOTATION aNotation = SIM_VALUE::NOTATION::SI );
|
SIM_VALUE::NOTATION aNotation = SIM_VALUE::NOTATION::SI );
|
||||||
|
|
||||||
bool HasOverrides() const;
|
|
||||||
bool HasNonInstanceOverrides() const;
|
|
||||||
bool HasSpiceNonInstanceOverrides() const;
|
|
||||||
|
|
||||||
// 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; }
|
||||||
virtual bool HasPrimaryValue() const { return false; }
|
virtual bool HasPrimaryValue() const { return false; }
|
||||||
|
|
|
@ -215,6 +215,43 @@ bool SIM_MODEL_NGSPICE::canSilentlyIgnoreParam( const std::string& aParamName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SIM_MODEL_NGSPICE::requiresSpiceModelLine() const
|
||||||
|
{
|
||||||
|
for( int ii = 0; ii < GetParamCount(); ++ii )
|
||||||
|
{
|
||||||
|
const PARAM& param = m_params[ii];
|
||||||
|
|
||||||
|
// Instance parameters are written in item lines
|
||||||
|
if( param.info.isSpiceInstanceParam )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Empty parameters are interpreted as default-value
|
||||||
|
if ( param.value == "" )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Any non-empty parameter must be written if there's no base model
|
||||||
|
if( !m_baseModel )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const SIM_MODEL_NGSPICE* baseModel = dynamic_cast<const SIM_MODEL_NGSPICE*>( m_baseModel );
|
||||||
|
std::string baseValue = baseModel->m_params[ii].value;
|
||||||
|
|
||||||
|
if( param.value == baseValue )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// One more check for equivalence, mostly for early 7.0 files which wrote all parameters
|
||||||
|
// to the Sim.Params field in normalized format
|
||||||
|
if( param.value == SIM_VALUE::Normalize( SIM_VALUE::ToDouble( baseValue ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Overrides must be written
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> SIM_MODEL_NGSPICE::GetPinNames() const
|
std::vector<std::string> SIM_MODEL_NGSPICE::GetPinNames() const
|
||||||
{
|
{
|
||||||
return ModelInfo( getModelType() ).pinNames;
|
return ModelInfo( getModelType() ).pinNames;
|
||||||
|
@ -289,41 +326,3 @@ SIM_MODEL_NGSPICE::MODEL_TYPE SIM_MODEL_NGSPICE::getModelType() const
|
||||||
return MODEL_TYPE::NONE;
|
return MODEL_TYPE::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL_NGSPICE::getIsOtherVariant()
|
|
||||||
{
|
|
||||||
switch( GetType() )
|
|
||||||
{
|
|
||||||
case TYPE::PNP_GUMMELPOON:
|
|
||||||
case TYPE::PNP_VBIC:
|
|
||||||
case TYPE::PNP_HICUM2:
|
|
||||||
case TYPE::PJFET_SHICHMANHODGES:
|
|
||||||
case TYPE::PJFET_PARKERSKELLERN:
|
|
||||||
case TYPE::PMES_STATZ:
|
|
||||||
case TYPE::PMES_YTTERDAL:
|
|
||||||
case TYPE::PMES_HFET1:
|
|
||||||
case TYPE::PMES_HFET2:
|
|
||||||
case TYPE::PMOS_VDMOS:
|
|
||||||
case TYPE::PMOS_MOS1:
|
|
||||||
case TYPE::PMOS_MOS2:
|
|
||||||
case TYPE::PMOS_MOS3:
|
|
||||||
case TYPE::PMOS_BSIM1:
|
|
||||||
case TYPE::PMOS_BSIM2:
|
|
||||||
case TYPE::PMOS_MOS6:
|
|
||||||
case TYPE::PMOS_BSIM3:
|
|
||||||
case TYPE::PMOS_MOS9:
|
|
||||||
case TYPE::PMOS_B4SOI:
|
|
||||||
case TYPE::PMOS_BSIM4:
|
|
||||||
case TYPE::PMOS_B3SOIFD:
|
|
||||||
case TYPE::PMOS_B3SOIDD:
|
|
||||||
case TYPE::PMOS_B3SOIPD:
|
|
||||||
case TYPE::PMOS_HISIM2:
|
|
||||||
case TYPE::PMOS_HISIMHV1:
|
|
||||||
case TYPE::PMOS_HISIMHV2:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 Mikolaj Wielgus
|
* Copyright (C) 2022 Mikolaj Wielgus
|
||||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -109,15 +109,11 @@ protected:
|
||||||
int doFindParam( const std::string& aParamName ) const override;
|
int doFindParam( const std::string& aParamName ) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool requiresSpiceModelLine() const override
|
bool requiresSpiceModelLine() const override;
|
||||||
{
|
|
||||||
return getModelType() != MODEL_TYPE::NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool canSilentlyIgnoreParam( const std::string& aParamName );
|
bool canSilentlyIgnoreParam( const std::string& aParamName );
|
||||||
|
|
||||||
MODEL_TYPE getModelType() const;
|
MODEL_TYPE getModelType() const;
|
||||||
bool getIsOtherVariant();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SIM_MODEL_NGSPICE_H */
|
#endif /* SIM_MODEL_NGSPICE_H */
|
||||||
|
|
|
@ -44,7 +44,7 @@ std::string SPICE_GENERATOR::ModelName( const SPICE_ITEM& aItem ) const
|
||||||
|
|
||||||
std::string SPICE_GENERATOR::ModelLine( const SPICE_ITEM& aItem ) const
|
std::string SPICE_GENERATOR::ModelLine( const SPICE_ITEM& aItem ) const
|
||||||
{
|
{
|
||||||
if( !m_model.HasSpiceNonInstanceOverrides() && !m_model.requiresSpiceModelLine() )
|
if( !m_model.requiresSpiceModelLine() )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
Loading…
Reference in New Issue