From bbeb70ed51fc3f1b875d10471f016256b3baa1a4 Mon Sep 17 00:00:00 2001 From: Marcus10110 Date: Wed, 13 Jan 2021 11:22:04 -0800 Subject: [PATCH] fixed issue where the disable event could get produced before the last data word if the clock and enable signal of the next transaction transition in the same sample. --- src/SpiAnalyzer.cpp | 25 +++++++++++++++++++------ src/SpiAnalyzer.h | 4 ++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/SpiAnalyzer.cpp b/src/SpiAnalyzer.cpp index d49740c..983a86a 100644 --- a/src/SpiAnalyzer.cpp +++ b/src/SpiAnalyzer.cpp @@ -172,7 +172,7 @@ bool SpiAnalyzer::IsInitialClockPolarityCorrect() } } -bool SpiAnalyzer::WouldAdvancingTheClockToggleEnable() +bool SpiAnalyzer::WouldAdvancingTheClockToggleEnable( bool add_disable_frame, U64* disable_frame ) { if( mEnable == NULL ) return false; @@ -183,8 +183,15 @@ bool SpiAnalyzer::WouldAdvancingTheClockToggleEnable() if( enable_will_toggle ) { U64 enable_edge = mEnable->GetSampleOfNextEdge(); - FrameV2 frame_v2_end_of_transaction; - mResults->AddFrameV2( frame_v2_end_of_transaction, "disable", enable_edge, enable_edge + 1 ); + if( add_disable_frame ) + { + FrameV2 frame_v2_end_of_transaction; + mResults->AddFrameV2( frame_v2_end_of_transaction, "disable", enable_edge, enable_edge + 1 ); + } + else if( disable_frame != nullptr ) + { + *disable_frame = enable_edge; + } } if( enable_will_toggle == false ) @@ -208,6 +215,8 @@ void SpiAnalyzer::GetWord() U64 first_sample = 0; bool need_reset = false; + U64 disable_event_sample = 0; + mArrowLocations.clear(); ReportProgress( mClock->GetSampleNumber() ); @@ -220,7 +229,7 @@ void SpiAnalyzer::GetWord() // on every single edge, we need to check that enable doesn't toggle. // note that we can't just advance the enable line to the next edge, becuase there may not be another edge - if( WouldAdvancingTheClockToggleEnable() == true ) + if( WouldAdvancingTheClockToggleEnable( true, nullptr ) == true ) { AdvanceToActiveEnableEdgeWithCorrectClockPolarity(); // ok, we pretty much need to reset everything and return. return; @@ -253,7 +262,7 @@ void SpiAnalyzer::GetWord() if( ( i == ( bits_per_transfer - 1 ) ) && ( mSettings->mDataValidEdge != AnalyzerEnums::TrailingEdge ) ) { // if this is the last bit, and the trailing edge doesn't represent valid data - if( WouldAdvancingTheClockToggleEnable() == true ) + if( WouldAdvancingTheClockToggleEnable( false, &disable_event_sample ) == true ) { // moving to the trailing edge would cause the clock to revert to inactive. jump out, record the frame, and them move to // the next active enable edge @@ -267,7 +276,7 @@ void SpiAnalyzer::GetWord() } // this isn't the very last bit, etc, so proceed as normal - if( WouldAdvancingTheClockToggleEnable() == true ) + if( WouldAdvancingTheClockToggleEnable( true, nullptr ) == true ) { AdvanceToActiveEnableEdgeWithCorrectClockPolarity(); // ok, we pretty much need to reset everything and return. return; @@ -324,7 +333,11 @@ void SpiAnalyzer::GetWord() mResults->CommitResults(); if( need_reset == true ) + { + FrameV2 frame_v2_end_of_transaction; + mResults->AddFrameV2( frame_v2_end_of_transaction, "disable", disable_event_sample, disable_event_sample + 1 ); AdvanceToActiveEnableEdgeWithCorrectClockPolarity(); + } } bool SpiAnalyzer::NeedsRerun() diff --git a/src/SpiAnalyzer.h b/src/SpiAnalyzer.h index 3901fc6..dc96e53 100644 --- a/src/SpiAnalyzer.h +++ b/src/SpiAnalyzer.h @@ -1,4 +1,4 @@ -#ifndef SPI_ANALYZER_H +#ifndef SPI_ANALYZER_H #define SPI_ANALYZER_H #include @@ -25,7 +25,7 @@ class SpiAnalyzer : public Analyzer2 void AdvanceToActiveEnableEdge(); bool IsInitialClockPolarityCorrect(); void AdvanceToActiveEnableEdgeWithCorrectClockPolarity(); - bool WouldAdvancingTheClockToggleEnable(); + bool WouldAdvancingTheClockToggleEnable( bool add_disable_frame, U64* disable_frame ); void GetWord(); #pragma warning( push )