Skip to content

Commit

Permalink
Add timeout detect
Browse files Browse the repository at this point in the history
Add the frame timeout detect.
  • Loading branch information
TiferKing committed Jan 3, 2023
1 parent 079506d commit be1af9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions SWIMAnalyzer/SWIMAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void SWIMAnalyzer::SetupSample()
{
mLowSpeedSampleOffsets.push_back(clk_gen.AdvanceByHalfPeriod());
}

mTimeoutSampleNum = clk_gen.AdvanceByTimeS(5e-4); // Set bit timeout 0.5ms
}

void SWIMAnalyzer::ParseSWIM(bool is_high_speed)
Expand Down Expand Up @@ -457,7 +459,11 @@ BitState SWIMAnalyzer::ParseBit(bool is_high_speed)
}
}

mSWIM->AdvanceToNextEdge();
if ((mSWIM->GetSampleOfNextEdge() - mSWIM->GetSampleNumber()) < mTimeoutSampleNum)
{
// Next bit present
mSWIM->AdvanceToNextEdge();
}
return bit;
}

Expand All @@ -469,7 +475,15 @@ BitState SWIMAnalyzer::ParseACK(bool is_high_speed)

if (mSWIM->GetBitState() == BIT_HIGH)
{
mSWIM->AdvanceToNextEdge();
if ((mSWIM->GetSampleOfNextEdge() - mSWIM->GetSampleNumber()) < mTimeoutSampleNum)
{
mSWIM->AdvanceToNextEdge();
}
else
{
// ACK edge not present
return BIT_LOW;
}
}
U64 starting_sample = mSWIM->GetSampleNumber();

Expand Down
1 change: 1 addition & 0 deletions SWIMAnalyzer/SWIMAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ANALYZER_EXPORT SWIMAnalyzer : public Analyzer
U64 mCurrentSample;
std::vector<U32> mHighSpeedSampleOffsets;
std::vector<U32> mLowSpeedSampleOffsets;
U32 mTimeoutSampleNum;

#pragma warning( pop )
};
Expand Down

0 comments on commit be1af9a

Please sign in to comment.