Skip to content

Commit 6dc60c2

Browse files
committed
[swt] Check the SWT header for the word sequence and drop duplicate words
1 parent 54446c8 commit 6dc60c2

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/Swt/Swt.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void Swt::reset()
5353
{
5454
barWrite(sc_regs::SC_RESET.index, 0x1);
5555
barWrite(sc_regs::SC_RESET.index, 0x0); //void cmd to sync clocks
56+
mWordSequence = -1;
5657
}
5758

5859
void Swt::read(std::vector<SwtWord>& words, TimeOut msTimeOut, SwtWord::Size wordSize)
@@ -84,6 +85,17 @@ void Swt::read(std::vector<SwtWord>& words, TimeOut msTimeOut, SwtWord::Size wor
8485
}
8586
tempWord.setHigh(barRead(sc_regs::SWT_RD_WORD_H.index));
8687

88+
mWordSequence = (mWordSequence + 1) % 16;
89+
90+
// If we get the same counter as before it means the FIFO wasn't updated; drop the word
91+
if (tempWord.getSequence() != mWordSequence) { //TODO: Need to reproduce so that I can test!
92+
getWarningLogger() << "SWT word sequence duplicate" << endm;
93+
94+
mWordSequence = tempWord.getSequence(); //roll mWordSequence back by one
95+
numWords++; //will have to read one more time
96+
continue;
97+
}
98+
8799
//wordMonPairs.push_back(std::make_pair(tempWord, barRead(sc_regs::SWT_MON.index)));
88100
words.push_back(tempWord);
89101
}

src/Swt/Swt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class Swt
6767
roc::RegisterReadWriteInterface& mBar2;
6868

6969
AlfLink mLink;
70+
int mWordSequence = -1;
7071
};
7172

7273
} // namespace Alf

src/Swt/SwtWord.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void SwtWord::setMed(uint32_t med)
7676
void SwtWord::setHigh(uint16_t high)
7777
{
7878
mHigh = high & 0xfff;
79+
mSequence = (high & 0xf000) >> 12;
7980
}
8081

8182
uint32_t SwtWord::getLow() const
@@ -93,6 +94,11 @@ uint16_t SwtWord::getHigh() const
9394
return mHigh & 0xfff;
9495
}
9596

97+
int SwtWord::getSequence() const
98+
{
99+
return mSequence;
100+
}
101+
96102
std::ostream& operator<<(std::ostream& output, const SwtWord& swtWord)
97103
{
98104
output << "0x" << std::setfill('0') << std::hex << std::setw(3) << swtWord.getHigh()

src/Swt/SwtWord.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SwtWord
4646
uint32_t getLow() const;
4747
uint32_t getMed() const;
4848
uint16_t getHigh() const;
49+
int getSequence() const;
4950

5051
enum Size {
5152
High,
@@ -57,6 +58,7 @@ class SwtWord
5758
uint32_t mLow;
5859
uint32_t mMed;
5960
uint16_t mHigh;
61+
int mSequence;
6062
};
6163

6264
std::ostream& operator<<(std::ostream& output, const SwtWord& swtWord);

0 commit comments

Comments
 (0)