Ignore extraneous LTSpice parameters for VDMOS models.

Also adds special case handling of VDMOS syntax to allow parens (or extra
spaces, linebreaks, etc.) between "VDMOS" and "NCHAN"/"PCHAN".

Fixes https://gitlab.com/kicad/code/kicad/issues/14299
This commit is contained in:
Jeff Young 2023-03-20 16:14:21 +00:00
parent a65accd412
commit a713ee852c
2 changed files with 36 additions and 5 deletions

View File

@ -210,6 +210,17 @@ bool SIM_MODEL_NGSPICE::canSilentlyIgnoreParam( const std::string& aParamName )
} }
} }
if( GetType() == TYPE::NMOS_VDMOS || GetType() == TYPE::PMOS_VDMOS )
{
// Ignore the purely informative LTspice-specific parameters "Vds", "Ron" and "Qg".
if( aParamName == "vds"
|| aParamName == "ron"
|| aParamName == "qg" )
{
return true;
}
}
return false; return false;
} }

View File

@ -277,12 +277,32 @@ SIM_MODEL::TYPE SPICE_MODEL_PARSER::ReadTypeFromSpiceStrings( const std::string&
if( typePrefix == "" ) if( typePrefix == "" )
continue; continue;
// Check if `aTypeString` starts with `typePrefix`. if( boost::starts_with( typePrefix, "VDMOS" ) )
if( boost::starts_with( boost::to_upper_copy( aTypeString ), typePrefix )
&& ( level == readLevel || ( !aSkipDefaultLevel && isDefaultLevel && aLevel == "" ) )
&& version == aVersion )
{ {
return type; wxString deviceType = wxString( typePrefix ).BeforeFirst( ' ' ); // VDMOS
wxString channelType = wxString( typePrefix ).AfterFirst( ' ' ); // NCHAN or PCHAN
wxStringTokenizer tokenizer( aTypeString, wxT( " \t\n\r+(" ), wxTOKEN_STRTOK );
if( tokenizer.HasMoreTokens() && tokenizer.GetNextToken().Upper() == deviceType
&& tokenizer.HasMoreTokens() && tokenizer.GetNextToken().Upper() == channelType )
{
return type;
}
}
else if( boost::starts_with( boost::to_upper_copy( aTypeString ), typePrefix ) )
{
if( version != aVersion )
continue;
if( level == readLevel )
return type;
if( aSkipDefaultLevel )
continue;
if( isDefaultLevel && aLevel == "" )
return type;
} }
} }