spice: generate .model lines for all device types

- generate .model lines in spice netlist for all device types that need
  one
- add "level=<n>" to .model line for non-default model levels. This is
  necessary to allow more sophisticated models to be used, and some
  devices *always* need a level specified (e.g. JFETs)
- add "version=<n>" to .model line for models that have multiple
  versions available (AFAIK only affects HiSIM_HV MOSFET models)

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13775
This commit is contained in:
Graham Keeth 2023-02-03 12:19:30 -05:00 committed by Jeff Young
parent 41c4ee2245
commit 5abe1a201b
2 changed files with 11 additions and 2 deletions

View File

@ -111,7 +111,7 @@ protected:
private: private:
bool requiresSpiceModelLine() const override bool requiresSpiceModelLine() const override
{ {
return getModelType() == MODEL_TYPE::DIODE; return getModelType() != MODEL_TYPE::NONE;
} }
bool canSilentlyIgnoreParam( const std::string& aParamName ); bool canSilentlyIgnoreParam( const std::string& aParamName );

View File

@ -52,7 +52,16 @@ std::string SPICE_GENERATOR::ModelLine( const SPICE_ITEM& aItem ) const
result.append( fmt::format( ".model {} ", aItem.modelName ) ); result.append( fmt::format( ".model {} ", aItem.modelName ) );
size_t indentLength = result.length(); size_t indentLength = result.length();
result.append( fmt::format( "{}\n", m_model.GetSpiceInfo().modelType ) ); SIM_MODEL::SPICE_INFO spiceInfo = m_model.GetSpiceInfo();
result.append( spiceInfo.modelType );
if ( !spiceInfo.isDefaultLevel && !spiceInfo.level.empty() )
result.append( fmt::format( " level={}", spiceInfo.level ) );
if ( !spiceInfo.version.empty() )
result.append( fmt::format( " version={}", spiceInfo.version ) );
result.append( "\n" );
for( const SIM_MODEL::PARAM& param : m_model.GetParams() ) for( const SIM_MODEL::PARAM& param : m_model.GetParams() )
{ {