Sim: Don't generate .model line when there's no instance param overrides
This commit is contained in:
parent
7bd8cfd7f9
commit
ba723d36c9
|
@ -911,7 +911,7 @@ wxString SIM_MODEL::GenerateSpiceModelLine( const wxString& aModelName ) const
|
|||
{
|
||||
LOCALE_IO toggle;
|
||||
|
||||
if( !HasSpiceNonInstanceOverrides() && !requiresSpiceModel() )
|
||||
if( !HasSpiceNonInstanceOverrides() && !requiresSpiceModelLine() )
|
||||
return "";
|
||||
|
||||
wxString result = "";
|
||||
|
@ -982,22 +982,10 @@ wxString SIM_MODEL::GenerateSpiceItemLine( const wxString& aRefName,
|
|||
const std::vector<wxString>& aPinNetNames ) const
|
||||
{
|
||||
wxString result;
|
||||
result << GenerateSpiceItemName( aRefName ) << " ";
|
||||
result << GenerateSpiceItemName( aRefName );
|
||||
result << GenerateSpiceItemPins( aRefName, aModelName, aSymbolPinNumbers, aPinNetNames );
|
||||
|
||||
if( requiresSpiceModel() )
|
||||
result << aModelName << " ";
|
||||
|
||||
bool isFirst = false;
|
||||
|
||||
for( const PARAM& param : GetParams() )
|
||||
{
|
||||
if( !param.info.isSpiceInstanceParam )
|
||||
continue;
|
||||
|
||||
result << GenerateSpiceItemParamValuePair( param, isFirst );
|
||||
}
|
||||
|
||||
result << GenerateSpiceItemModelName( aModelName );
|
||||
result << GenerateSpiceItemParams();
|
||||
result << "\n";
|
||||
return result;
|
||||
}
|
||||
|
@ -1102,12 +1090,26 @@ std::vector<std::reference_wrapper<const SIM_MODEL::PARAM>> SIM_MODEL::GetParams
|
|||
std::vector<std::reference_wrapper<const PARAM>> params;
|
||||
|
||||
for( int i = 0; i < GetParamCount(); ++i )
|
||||
params.push_back( GetParam( i ) );
|
||||
params.emplace_back( GetParam( i ) );
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::reference_wrapper<const SIM_MODEL::PARAM>> SIM_MODEL::GetSpiceInstanceParams() const
|
||||
{
|
||||
std::vector<std::reference_wrapper<const PARAM>> spiceInstanceParams;
|
||||
|
||||
for( const PARAM& param : GetParams() )
|
||||
{
|
||||
if( param.info.isSpiceInstanceParam )
|
||||
spiceInstanceParams.emplace_back( param );
|
||||
}
|
||||
|
||||
return spiceInstanceParams;
|
||||
}
|
||||
|
||||
|
||||
const SIM_MODEL::PARAM& SIM_MODEL::GetUnderlyingParam( unsigned aParamIndex ) const
|
||||
{
|
||||
return m_params.at( aParamIndex );
|
||||
|
@ -1252,12 +1254,12 @@ wxString SIM_MODEL::GenerateSpiceItemPins( const wxString& aRefName,
|
|||
if( it == aSymbolPinNumbers.end() )
|
||||
{
|
||||
LOCALE_IO toggle;
|
||||
result << wxString::Format( "NC-%s-%u ", aRefName, ncCounter++ );
|
||||
result << wxString::Format( " NC-%s-%u", aRefName, ncCounter++ );
|
||||
}
|
||||
else
|
||||
{
|
||||
long symbolPinIndex = std::distance( aSymbolPinNumbers.begin(), it );
|
||||
result << aPinNetNames.at( symbolPinIndex ) << " ";
|
||||
result << " " << aPinNetNames.at( symbolPinIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1265,21 +1267,25 @@ wxString SIM_MODEL::GenerateSpiceItemPins( const wxString& aRefName,
|
|||
}
|
||||
|
||||
|
||||
wxString SIM_MODEL::GenerateSpiceItemParamValuePair( const PARAM& aParam, bool& aIsFirst ) const
|
||||
wxString SIM_MODEL::GenerateSpiceItemModelName( const wxString& aModelName ) const
|
||||
{
|
||||
return " " + aModelName;
|
||||
}
|
||||
|
||||
|
||||
wxString SIM_MODEL::GenerateSpiceItemParams() const
|
||||
{
|
||||
wxString result;
|
||||
|
||||
if( aIsFirst )
|
||||
aIsFirst = false;
|
||||
else
|
||||
result << " ";
|
||||
for( const PARAM& param : GetSpiceInstanceParams() )
|
||||
{
|
||||
wxString name = ( param.info.spiceInstanceName == "" ) ?
|
||||
param.info.name : param.info.spiceInstanceName;
|
||||
wxString value = param.value->ToSpiceString();
|
||||
|
||||
wxString name = ( aParam.info.spiceInstanceName == "" ) ?
|
||||
aParam.info.name : aParam.info.spiceInstanceName;
|
||||
wxString value = aParam.value->ToSpiceString();
|
||||
|
||||
if( value != "" )
|
||||
result << name << "=" << value;
|
||||
if( value != "" )
|
||||
result << " " << name << "=" << value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1682,7 +1688,7 @@ wxString SIM_MODEL::parseFieldFloatValue( wxString aFieldFloatValue )
|
|||
}
|
||||
|
||||
|
||||
bool SIM_MODEL::requiresSpiceModel() const
|
||||
bool SIM_MODEL::requiresSpiceModelLine() const
|
||||
{
|
||||
for( const PARAM& param : GetParams() )
|
||||
{
|
||||
|
|
|
@ -541,6 +541,7 @@ public:
|
|||
const PARAM* FindParam( const wxString& aParamName ) const;
|
||||
|
||||
std::vector<std::reference_wrapper<const PARAM>> GetParams() const;
|
||||
std::vector<std::reference_wrapper<const PARAM>> GetSpiceInstanceParams() const;
|
||||
|
||||
const PARAM& GetUnderlyingParam( unsigned aParamIndex ) const; // Return the actual parameter.
|
||||
const PARAM& GetBaseParam( unsigned aParamIndex ) const; // Always return base parameter if it exists.
|
||||
|
@ -574,7 +575,8 @@ protected:
|
|||
const wxString& aModelName,
|
||||
const std::vector<wxString>& aSymbolPinNumbers,
|
||||
const std::vector<wxString>& aPinNetNames ) const;
|
||||
virtual wxString GenerateSpiceItemParamValuePair( const PARAM& aParam, bool& aIsFirst ) const;
|
||||
virtual wxString GenerateSpiceItemModelName( const wxString& aModelName ) const;
|
||||
virtual wxString GenerateSpiceItemParams() const;
|
||||
|
||||
virtual wxString GenerateParamValuePair( const PARAM& aParam, bool& aIsFirst ) const;
|
||||
|
||||
|
@ -622,7 +624,7 @@ private:
|
|||
|
||||
wxString parseFieldFloatValue( wxString aFieldFloatValue );
|
||||
|
||||
virtual bool requiresSpiceModel() const;
|
||||
virtual bool requiresSpiceModelLine() const;
|
||||
|
||||
virtual std::vector<wxString> getPinNames() const { return {}; }
|
||||
|
||||
|
|
|
@ -34,12 +34,13 @@ SIM_MODEL_MUTUAL_INDUCTOR::SIM_MODEL_MUTUAL_INDUCTOR() : SIM_MODEL( SIM_MODEL::T
|
|||
}
|
||||
|
||||
|
||||
wxString SIM_MODEL_MUTUAL_INDUCTOR::GenerateSpiceItemParamValuePair( const PARAM& aParam,
|
||||
bool& aIsFirst ) const
|
||||
wxString SIM_MODEL_MUTUAL_INDUCTOR::GenerateSpiceItemParams() const
|
||||
{
|
||||
wxString result;
|
||||
|
||||
result << aParam.value->ToSimpleString() << " ";
|
||||
for( const PARAM& param : GetSpiceInstanceParams() )
|
||||
result << param.value->ToSimpleString() << " ";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class SIM_MODEL_MUTUAL_INDUCTOR : public SIM_MODEL
|
|||
public:
|
||||
SIM_MODEL_MUTUAL_INDUCTOR();
|
||||
|
||||
wxString GenerateSpiceItemParamValuePair( const PARAM& aParam, bool& aIsFirst ) const override;
|
||||
wxString GenerateSpiceItemParams() const override;
|
||||
|
||||
private:
|
||||
static const std::vector<PARAM::INFO> makeParamInfos();
|
||||
|
|
|
@ -95,6 +95,8 @@ protected:
|
|||
static const MODEL_INFO& ModelInfo( MODEL_TYPE aType );
|
||||
|
||||
private:
|
||||
bool requiresSpiceModelLine() const override { return false; }
|
||||
|
||||
std::vector<wxString> getPinNames() const override;
|
||||
|
||||
MODEL_TYPE getModelType() const;
|
||||
|
|
|
@ -135,7 +135,7 @@ wxString SIM_MODEL_SPICE::GenerateSpiceItemPins( const wxString& aRefName,
|
|||
if( it != aSymbolPinNumbers.end() )
|
||||
{
|
||||
long symbolPinIndex = std::distance( aSymbolPinNumbers.begin(), it );
|
||||
result << aPinNetNames.at( symbolPinIndex ) << " ";
|
||||
result << " " << aPinNetNames.at( symbolPinIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,13 +143,25 @@ wxString SIM_MODEL_SPICE::GenerateSpiceItemPins( const wxString& aRefName,
|
|||
}
|
||||
|
||||
|
||||
wxString SIM_MODEL_SPICE::GenerateSpiceItemParamValuePair( const PARAM& aParam,
|
||||
bool& aIsFirst ) const
|
||||
wxString SIM_MODEL_SPICE::GenerateSpiceItemModelName( const wxString& aModelName ) const
|
||||
{
|
||||
if( aParam.info.name != "model" )
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
return aParam.value->ToString();
|
||||
|
||||
wxString SIM_MODEL_SPICE::GenerateSpiceItemParams() const
|
||||
{
|
||||
wxString result;
|
||||
|
||||
for( const PARAM& param : GetSpiceInstanceParams() )
|
||||
{
|
||||
if( param.info.name != "model" )
|
||||
result << "";
|
||||
else
|
||||
result << " " << param.value->ToString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,9 @@ protected:
|
|||
const std::vector<wxString>& aSymbolPinNumbers,
|
||||
const std::vector<wxString>& aPinNetNames ) const override;
|
||||
|
||||
wxString GenerateSpiceItemParamValuePair( const PARAM& aParam, bool& aIsFirst ) const override;
|
||||
wxString GenerateSpiceItemModelName( const wxString& aModelName ) const override;
|
||||
|
||||
wxString GenerateSpiceItemParams() const override;
|
||||
|
||||
bool SetParamFromSpiceCode( const wxString& aParamName, const wxString& aParamValue,
|
||||
SIM_VALUE_GRAMMAR::NOTATION aNotation
|
||||
|
@ -80,7 +82,7 @@ private:
|
|||
|
||||
void parseLegacyPinsField( unsigned aSymbolPinCount, const wxString& aLegacyPinsField );
|
||||
|
||||
bool requiresSpiceModel() const override { return false; }
|
||||
bool requiresSpiceModelLine() const override { return false; }
|
||||
|
||||
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ protected:
|
|||
void CreatePins( unsigned aSymbolPinCount ) override;
|
||||
|
||||
private:
|
||||
bool requiresSpiceModel() const override { return true; }
|
||||
bool requiresSpiceModelLine() const override { return true; }
|
||||
|
||||
std::vector<std::unique_ptr<PARAM::INFO>> m_paramInfos;
|
||||
};
|
||||
|
|
|
@ -51,16 +51,22 @@ SIM_MODEL_SWITCH::SIM_MODEL_SWITCH( TYPE aType ) : SIM_MODEL( aType )
|
|||
}
|
||||
|
||||
|
||||
wxString SIM_MODEL_SWITCH::GenerateSpiceItemParamValuePair( const PARAM& aParam,
|
||||
bool& aIsFirst ) const
|
||||
wxString SIM_MODEL_SWITCH::GenerateSpiceItemParams() const
|
||||
{
|
||||
// The only instance param is "ic", which is positional.
|
||||
wxString value = aParam.value->ToSpiceString();
|
||||
|
||||
if( value == "none" )
|
||||
return "";
|
||||
else
|
||||
return value;
|
||||
wxString result;
|
||||
|
||||
for( const PARAM& param : GetSpiceInstanceParams() )
|
||||
{
|
||||
// The only instance param is "ic", which is positional.
|
||||
wxString value = param.value->ToSpiceString();
|
||||
|
||||
if( value == "none" )
|
||||
result << "";
|
||||
else
|
||||
result << value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class SIM_MODEL_SWITCH : public SIM_MODEL
|
|||
public:
|
||||
SIM_MODEL_SWITCH( TYPE aType );
|
||||
|
||||
wxString GenerateSpiceItemParamValuePair( const PARAM& aParam, bool& aIsFirst ) const override;
|
||||
wxString GenerateSpiceItemParams() const override;
|
||||
wxString GenerateSpiceItemLine( const wxString& aRefName, const wxString& aModelName,
|
||||
const std::vector<wxString>& aSymbolPinNumbers,
|
||||
const std::vector<wxString>& aPinNetNames ) const override;
|
||||
|
@ -48,7 +48,7 @@ private:
|
|||
return { "ctrl+", "ctrl-", "no+", "no-" };
|
||||
}
|
||||
|
||||
bool requiresSpiceModel() const override { return true; }
|
||||
bool requiresSpiceModelLine() const override { return true; }
|
||||
|
||||
static const std::vector<PARAM::INFO> makeSwVParamInfos();
|
||||
static const std::vector<PARAM::INFO> makeSwIParamInfos();
|
||||
|
|
Loading…
Reference in New Issue