From d2adcdfde0a2b8b317f246b52f22cde3ba4a7799 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 1 Dec 2022 09:14:14 +0100 Subject: [PATCH] Sim: Add "number of bits" parameter to KIBIS PRBS model and some more fixes The other fixes: - PRBS's `m_bits` should be an integer. - Fix some references to outdated parameter names. --- eeschema/sim/kibis/kibis.h | 2 +- eeschema/sim/sim_model_kibis.cpp | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/eeschema/sim/kibis/kibis.h b/eeschema/sim/kibis/kibis.h index 95e5bb353e..7e5dfd7949 100644 --- a/eeschema/sim/kibis/kibis.h +++ b/eeschema/sim/kibis/kibis.h @@ -113,7 +113,7 @@ public: }; double m_bitrate = 10e6; double m_delay = 0; - double m_bits = 10; + int m_bits = 10; std::vector> GenerateBitSequence() override; bool Check( IbisWaveform* aRisingWf, IbisWaveform* aFallingWf ) override; diff --git a/eeschema/sim/sim_model_kibis.cpp b/eeschema/sim/sim_model_kibis.cpp index f2d553186a..576d4b4349 100644 --- a/eeschema/sim/sim_model_kibis.cpp +++ b/eeschema/sim/sim_model_kibis.cpp @@ -173,11 +173,11 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const st if ( m_model.FindParam( "toff" ) ) waveform->m_toff = static_cast( *m_model.FindParam( "toff" )->value ).Get().value_or( 1 ); - if ( m_model.FindParam( "delay" ) ) - waveform->m_delay = static_cast( *m_model.FindParam( "delay" )->value ).Get().value_or( 0 ); + if ( m_model.FindParam( "td" ) ) + waveform->m_delay = static_cast( *m_model.FindParam( "td" )->value ).Get().value_or( 0 ); - if ( m_model.FindParam( "cycles" ) ) - waveform->m_cycles = static_cast( *m_model.FindParam( "cycles" )->value ).Get().value_or( 1 ); + if ( m_model.FindParam( "n" ) ) + waveform->m_cycles = static_cast( *m_model.FindParam( "n" )->value ).Get().value_or( 1 ); kparams.m_waveform = waveform; @@ -195,11 +195,11 @@ std::string SPICE_GENERATOR_KIBIS::IbisDevice( const SPICE_ITEM& aItem, const st if ( m_model.FindParam( "f0" ) ) waveform->m_bitrate = static_cast( *m_model.FindParam( "f0" )->value ).Get().value_or( 0 ); - if ( m_model.FindParam( "bits" ) ) - waveform->m_bits = static_cast( *m_model.FindParam( "bits" )->value ).Get().value_or( 0 ); + if ( m_model.FindParam( "td" ) ) + waveform->m_delay = static_cast( *m_model.FindParam( "td" )->value ).Get().value_or( 0 ); - if ( m_model.FindParam( "delay" ) ) - waveform->m_delay = static_cast( *m_model.FindParam( "delay" )->value ).Get().value_or( 0 ); + if ( m_model.FindParam( "n" ) ) + waveform->m_bits = static_cast( *m_model.FindParam( "n" )->value ).Get().value_or( 0 ); kparams.m_waveform = waveform; @@ -466,7 +466,7 @@ std::vector SIM_MODEL_KIBIS::makeRectWaveformParamInfos( paramInfos.push_back( paramInfo ); paramInfo.name = "n"; - paramInfo.type = SIM_VALUE::TYPE_FLOAT; + paramInfo.type = SIM_VALUE::TYPE_INT; paramInfo.unit = ""; paramInfo.category = PARAM::CATEGORY::WAVEFORM; paramInfo.defaultValue = "1"; @@ -490,8 +490,15 @@ std::vector SIM_MODEL_KIBIS::makePrbsWaveformParamInfos( paramInfo.description = _( "Bitrate" ); paramInfos.push_back( paramInfo ); - paramInfo.name = "n"; + paramInfo.name = "td"; paramInfo.type = SIM_VALUE::TYPE_FLOAT; + paramInfo.unit = "s"; + paramInfo.category = PARAM::CATEGORY::WAVEFORM; + paramInfo.description = _( "Delay" ); + paramInfos.push_back( paramInfo ); + + paramInfo.name = "n"; + paramInfo.type = SIM_VALUE::TYPE_INT; paramInfo.unit = ""; paramInfo.category = PARAM::CATEGORY::WAVEFORM; paramInfo.defaultValue = "";