Move only-write-model-if-it-contains-overrides up to base class.
It's necessary to keep us from writing out model lines for included models and fall-backs of included models.
This commit is contained in:
parent
a0f99ea8ba
commit
f5edcf82f2
|
@ -1064,10 +1064,35 @@ void SIM_MODEL::doWriteFields( std::vector<T>& aFields ) const
|
||||||
|
|
||||||
bool SIM_MODEL::requiresSpiceModelLine( const SPICE_ITEM& aItem ) const
|
bool SIM_MODEL::requiresSpiceModelLine( const SPICE_ITEM& aItem ) const
|
||||||
{
|
{
|
||||||
for( const PARAM& param : GetParams() )
|
// Model must be written if there's no base model or the base model is an internal model
|
||||||
|
if( !m_baseModel || aItem.baseModelName == "" )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for( int ii = 0; ii < GetParamCount(); ++ii )
|
||||||
{
|
{
|
||||||
if( !param.info.isSpiceInstanceParam )
|
const PARAM& param = m_params[ii];
|
||||||
return true;
|
|
||||||
|
// Instance parameters are written in item lines
|
||||||
|
if( param.info.isSpiceInstanceParam )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Empty parameters are interpreted as default-value
|
||||||
|
if ( param.value == "" )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const SIM_MODEL* baseModel = dynamic_cast<const SIM_MODEL*>( 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;
|
return false;
|
||||||
|
|
|
@ -215,43 +215,6 @@ bool SIM_MODEL_NGSPICE::canSilentlyIgnoreParam( const std::string& aParamName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SIM_MODEL_NGSPICE::requiresSpiceModelLine( const SPICE_ITEM& aItem ) const
|
|
||||||
{
|
|
||||||
// Model must be written if there's no base model or the base model is an internal model
|
|
||||||
if( !m_baseModel || aItem.baseModelName == "" )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -109,8 +109,6 @@ protected:
|
||||||
int doFindParam( const std::string& aParamName ) const override;
|
int doFindParam( const std::string& aParamName ) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool requiresSpiceModelLine( const SPICE_ITEM& aItem ) const override;
|
|
||||||
|
|
||||||
bool canSilentlyIgnoreParam( const std::string& aParamName );
|
bool canSilentlyIgnoreParam( const std::string& aParamName );
|
||||||
|
|
||||||
MODEL_TYPE getModelType() const;
|
MODEL_TYPE getModelType() const;
|
||||||
|
|
|
@ -60,8 +60,6 @@ public:
|
||||||
std::string GetSpiceCode() const;
|
std::string GetSpiceCode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool requiresSpiceModelLine( const SPICE_ITEM& aItem ) const override { return true; }
|
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ std::string SPICE_GENERATOR::ModelName( const SPICE_ITEM& aItem ) const
|
||||||
if( aItem.baseModelName == "" )
|
if( aItem.baseModelName == "" )
|
||||||
return fmt::format( "__{}", aItem.refName );
|
return fmt::format( "__{}", aItem.refName );
|
||||||
|
|
||||||
// FIXME: This ModelLine() call is relatively expensive.
|
if( m_model.requiresSpiceModelLine( aItem ) )
|
||||||
if( ModelLine( aItem ) != "" )
|
|
||||||
return fmt::format( "{}.{}", aItem.refName, aItem.baseModelName );
|
return fmt::format( "{}.{}", aItem.refName, aItem.baseModelName );
|
||||||
|
|
||||||
return aItem.baseModelName;
|
return aItem.baseModelName;
|
||||||
|
|
Loading…
Reference in New Issue