Sim: cleanup: use unique_ptr for PARAM::value

This commit is contained in:
Mikolaj Wielgus 2022-10-03 22:14:14 +02:00
parent b716afd6f1
commit c464c5b87b
2 changed files with 13 additions and 25 deletions

View File

@ -376,28 +376,22 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
if( mparam )
static_cast<KIBIS_WAVEFORM_RECTANGULAR*>( kparams.m_waveform )
->m_ton = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 1 ) );
->m_ton = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 1 );
mparam = spiceItem.model->FindParam( "toff" );
if( mparam )
static_cast<KIBIS_WAVEFORM_RECTANGULAR*>( kparams.m_waveform )
->m_toff = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 1 ) );
->m_toff = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 1 );
mparam = spiceItem.model->FindParam( "delay" );
if( mparam )
static_cast<KIBIS_WAVEFORM_RECTANGULAR*>( kparams.m_waveform )
->m_delay = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 0 ) );
->m_delay = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 0 );
kpin->writeSpiceDriver( &modelData, modelName, *kmodel, kparams );
break;
@ -411,28 +405,22 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
if( mparam )
static_cast<KIBIS_WAVEFORM_PRBS*>( kparams.m_waveform )
->m_bitrate = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 1 ) );
->m_bitrate = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 0 );
mparam = spiceItem.model->FindParam( "bits" );
if( mparam )
static_cast<KIBIS_WAVEFORM_PRBS*>( kparams.m_waveform )
->m_bits = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 1 ) );
->m_bits = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 0 );
mparam = spiceItem.model->FindParam( "delay" );
if( mparam )
static_cast<KIBIS_WAVEFORM_PRBS*>( kparams.m_waveform )
->m_delay = static_cast<double>(
std::dynamic_pointer_cast<SIM_VALUE_FLOAT>( mparam->value )
->Get()
.value_or( 0 ) );
->m_delay = static_cast<SIM_VALUE_FLOAT*>( mparam->value.get() )->Get()
.value_or( 0 );
kpin->writeSpiceDriver( &modelData, modelName, *kmodel, kparams );
break;

View File

@ -422,7 +422,7 @@ public:
}
};
std::shared_ptr<SIM_VALUE> value;
std::unique_ptr<SIM_VALUE> value;
const INFO& info;
bool isOtherVariant = false; // Legacy.