Commit 53daade9 authored by Sarah Seif El Nasr's avatar Sarah Seif El Nasr
Browse files

Merged with Sarah

parents 3dc0d32d bbe7baca
......@@ -87,6 +87,8 @@ class Cbc : public ReadoutChip
else
return 8;
}
};
} // namespace Ph2_HwDescription
......
......@@ -156,17 +156,38 @@ class Chip : public FrontEndDescription
// retrieve some bits of register
uint16_t getRegBits( const std::string& pReg, ChipRegMask pMask )
{
uint16_t cMask = 0x00;
uint16_t cMask = 0x0000;
for(uint8_t cIndx=0; cIndx < pMask.fNbits; cIndx++) cMask = cMask | ( 1 << cIndx);
uint16_t cRegMask = (cMask << pMask.fBitShift);
return ((getReg(pReg) & cRegMask) >> pMask.fBitShift);
uint16_t cValue = ( getReg(pReg) & cRegMask ) >> pMask.fBitShift;
//std::cout << "\t\t\t Value is 0x" << std::hex << getReg(pReg) << std::dec << " Mask is 0x" << std::hex << cRegMask << std::dec << " value is " << +cValue << "\n";
return cValue;
}
// update write count
void updateWriteCount(uint32_t fIncrement=1 ){ fI2CWrites+= fIncrement ; }
void updateReadCount(uint32_t fIncrement=1){ fI2Reads+= fIncrement ; }
void updateRBMismatchCount(uint32_t fIncrement=1){ fI2CReadMismatches+= fIncrement ; }
void updateRegWriteCount(uint32_t fIncrement=1){ fRegWrites+= fIncrement ; }
void updateRegReadCount(uint32_t fIncrement=1){ fRegReads+= fIncrement ; }
uint32_t getWriteCount(){ return fI2CWrites;}
uint32_t getReadCount(){ return fI2Reads;}
uint32_t getRBMismatchCount(){ return fI2CReadMismatches;}
uint32_t getRegWriteCount(){ return fRegWrites;}
uint32_t getRegReadCount(){ return fRegReads;}
protected:
uint8_t fChipId;
uint16_t fMaxRegValue;
uint16_t fClockFrequency;
ChipRegMap fRegMap;
CommentMap fCommentMap;
private:
uint32_t fI2CWrites=0;
uint32_t fI2Reads=0;
uint32_t fI2CReadMismatches=0;
uint32_t fRegWrites=0;
uint32_t fRegReads=0;
};
/*!
......
......@@ -64,12 +64,22 @@ class lpGBT : public Chip
uint8_t getRxHSLPolarity() { return fRxHSLPolarity; }
uint8_t getTxHSLPolarity() { return fTxHSLPolarity; }
void updateWriteCount(uint8_t pMasterId, uint32_t fIncrement=1 ){ fI2CWrites[pMasterId]+= fIncrement ; }
void updateReadCount(uint8_t pMasterId, uint32_t fIncrement=1){ fI2CReads[pMasterId]+= fIncrement ; }
uint32_t getWriteCount(uint8_t pMasterId){ return fI2CWrites[pMasterId];}
uint32_t getReadCount(uint8_t pMasterId){ return fI2CReads[pMasterId];}
private:
bool phaseRxAligned; // @TMP@
std::string configFileName;
std::vector<uint8_t> fClocks, fRxGroups, fRxChannels, fTxGroups, fTxChannels;
uint16_t fClocksFrequency, fRxDataRate, fTxDataRate;
uint8_t fRxHSLPolarity, fTxHSLPolarity;
// number of write transactions - one element per master
std::vector<uint32_t> fI2CWrites{0,0,0};
// number of read transactions - one element per master
std::vector<uint32_t> fI2CReads{0,0,0};
};
} // namespace Ph2_HwDescription
......
......@@ -328,6 +328,10 @@ class BeBoardFWInterface : public RegManager
fCPBConfig.fMaxAttempts = pConfig.fMaxAttempts;
fCPBConfig.fI2CFrequency = pConfig.fI2CFrequency;
}
// return functions for internal I2C reads and writes
uint32_t getWriteCount(){ return fI2CWriteCount;}
uint32_t getReadCount(){ return fI2CReadCount;}
uint32_t getRBMismatchCount(){ return fI2CReadMismatches;}
protected:
uint32_t fBlockSize{0};
......@@ -350,6 +354,12 @@ class BeBoardFWInterface : public RegManager
return pMismatchedWriteVector;
}
protected :
// I2C write and read count
uint32_t fI2CWriteCount{0};
uint32_t fI2CReadCount{0};
uint32_t fI2CReadMismatches{0};
};
} // namespace Ph2_HwInterface
......
......@@ -334,7 +334,9 @@ uint16_t CbcInterface::readErrorRegister(ReadoutChip* pCbc)
{
bool cVerifLoop = true;
bool cSuccess = ConfigurePage(pCbc, cRegItem.fPage, cVerifLoop);
if(cSuccess) cErrorReg = fBoardFW->ReadFERegister(pCbc, cRegItem.fAddress);
if(cSuccess){
cErrorReg = fBoardFW->ReadFERegister(pCbc, cRegItem.fAddress);
}
}
return cErrorReg;
}
......@@ -662,7 +664,7 @@ uint8_t CbcInterface::GetLastPage(Chip* pCbc)
auto cValue = ReadChipSingleReg(pCbc, "FeCtrl&TrgLat2");
ChipRegMask cMask; cMask.fBitShift=7; cMask.fNbits=1;
uint8_t cDefaultPage = pCbc->getRegBits( "FeCtrl&TrgLat2",cMask );
LOG (INFO) << BOLDMAGENTA << "Default page on CBC" << +pCbc->getId() << " on hybrid " << +pCbc->getHybridId() << " is " << +cDefaultPage << " register value is 0x" << std::hex << +cValue << std::dec << RESET;
LOG (DEBUG) << BOLDMAGENTA << "\t...Default page on CBC" << +pCbc->getId() << " on hybrid " << +pCbc->getHybridId() << " is " << +cDefaultPage << " register value is 0x" << std::hex << +cValue << std::dec << RESET;
return cDefaultPage;
}
else
......@@ -830,9 +832,11 @@ uint8_t CbcInterface::ReadChipSingleReg(Chip* pCbc, const std::string& pRegNode)
{
bool cVerifLoop = true;
bool cSuccess = ( pRegNode == "FeCtrl&TrgLat2" ) ? true : ConfigurePage(pCbc, cRegItem.fPage, cVerifLoop);
if(cSuccess) cValue = fBoardFW->ReadFERegister(pCbc, cRegItem.fAddress);
if(cSuccess){
cValue = fBoardFW->ReadFERegister(pCbc, cRegItem.fAddress);
}
}
pCbc->setReg(pRegNode, cRegItem.fValue);
pCbc->setReg(pRegNode, cValue);
return cValue;
}
......
......@@ -621,7 +621,7 @@ void D19cFWInterface::configureLink(const BeBoard* pBoard)
if(cSCAenabled == 1) LOG(INFO) << BOLDBLUE << "SCA enabled successfully." << RESET;
cGBTx.scaConfigureGPIO(this);
// configure GBTx
bool cRisingEdge = false;
bool cRisingEdge = true;
// cGBTx.gbtxResetPhaseShifterClocks(this);
cGBTx.gbtxConfigureChargePumps(this);
cGBTx.gbtxResetPhaseShifterClocks(this);
......@@ -5734,7 +5734,7 @@ bool D19cFWInterface::I2CWrite(uint8_t pLinkId, uint8_t pMasterId, uint8_t pSlav
std::this_thread::sleep_for(std::chrono::microseconds(50));
std::vector<uint32_t> cReplyVector = ReadReplyCPB(10);
fI2Cstatus = cReplyVector[7] & 0xFF;
size_t cIter = 0, cMaxIter = fCPBConfig.fMaxAttempts;
size_t cIter = 0, cMaxIter = fCPBConfig.fMaxAttempts;
while(fI2Cstatus != 4 && cIter < cMaxIter && fCPBConfig.fReTry)
{
// // reset link
......@@ -5764,6 +5764,7 @@ bool D19cFWInterface::I2CWrite(uint8_t pLinkId, uint8_t pMasterId, uint8_t pSlav
fI2Cstatus = cReplyVector[7] & 0xFF;
cIter++;
}
fI2CWriteCount+= (1+cIter);
if(cIter == cMaxIter)
{
LOG(INFO) << BOLDRED << "[D19cFWInterface::I2CWrite] Iter#" << +cIter << " I2CM" << +pMasterId << " status indicates a failure 0x" << std::hex << +fI2Cstatus << std::dec
......@@ -5830,6 +5831,7 @@ uint8_t D19cFWInterface::I2CRead(uint8_t pLinkId, uint8_t pMasterId, uint8_t pSl
if(cIter == cMaxIter - 1) LOG(INFO) << BOLDRED << "[D19cFWInterface::I2CRead] : Corrupted CPB reply frame" << RESET;
cIter++;
};
fI2CReadCount += (1+cIter);
if(cIter == cMaxIter) throw std::runtime_error(std::string("[D19cFWInterface::I2CRead] : Corrupted CPB reply frame"));
return cReadBack;
}
......@@ -5866,7 +5868,18 @@ bool D19cFWInterface::WriteFERegister(Ph2_HwDescription::Chip* pChip, uint16_t p
cNbytes = 2;
cSlaveData = (pRegisterValue << 8) | (pRegisterAddress & 0xFF);
}
fI2CWriteCount=0;
fI2CReadMismatches=0;
bool cSuccess = I2CWrite(cLinkId, cMasterId, cChipAddress, cSlaveData, cNbytes);
pChip->updateWriteCount( fI2CWriteCount );
if( fI2CWriteCount != 1 ){
std::stringstream cOutput;
pChip->printChipType(cOutput);
LOG (INFO) << BOLDYELLOW << "\t\t... Pre-verfication - took " << +fI2CWriteCount
<< " I2C writes to succeed in writing " << +pRegisterValue << " on register " << +pRegisterAddress
<< " for " << cOutput.str() << "#" << +pChip->getId() << " on Hybrid#" << +pChip->getHybridId()
<< RESET;
}
if(pVerify && cSuccess)
{
uint8_t cReadBack = ReadFERegister(pChip, pRegisterAddress);
......@@ -5878,14 +5891,29 @@ bool D19cFWInterface::WriteFERegister(Ph2_HwDescription::Chip* pChip, uint16_t p
LOG(INFO) << BOLDRED << "I2C ReadBack Mismatch in hybrid " << +pChip->getHybridId() << " Chip " << +cChipId << " register 0x" << std::hex << +pRegisterAddress << std::dec
<< " asked to write 0x" << std::hex << +pRegisterValue << std::dec << " and read back 0x" << std::hex << +cReadBack << std::dec << RESET;
}
cSuccess = I2CWrite(cLinkId, cMasterId, cChipAddress, cSlaveData, cNbytes);
if(cSuccess) { cReadBack = ReadFERegister(pChip, pRegisterAddress); }
// dont re-write - just try and read again
cReadBack = ReadFERegister(pChip, pRegisterAddress);
fI2CReadMismatches++;
// this was repeating both the write and the read
//cSuccess = I2CWrite(cLinkId, cMasterId, cChipAddress, cSlaveData, cNbytes);
//if(cSuccess) { cReadBack = ReadFERegister(pChip, pRegisterAddress); }
cIter++;
}
if(cReadBack != pRegisterValue) { throw std::runtime_error(std::string("I2C readback mismatch")); }
}
else if(!cSuccess)
LOG(INFO) << BOLDRED << "I2C Write FAILED - I2C status is " << +fI2Cstatus << RESET;
if( fI2CReadMismatches != 0 ){
std::stringstream cOutput;
pChip->printChipType(cOutput);
LOG (INFO) << BOLDYELLOW << "\t\t\t ...Post-verfication - took " << +fI2CReadMismatches
<< "attempts to read-back written value from " << +pRegisterValue << " on register " << +pRegisterAddress
<< " for " << cOutput.str() << "#" << +pChip->getId() << " on Hybrid#" << +pChip->getHybridId()
<< RESET;
}
pChip->updateRBMismatchCount( fI2CReadMismatches );
pChip->updateRegWriteCount();
return cSuccess;
}
......@@ -5912,8 +5940,13 @@ uint8_t D19cFWInterface::ReadFERegister(Ph2_HwDescription::Chip* pChip, uint16_t
cSlaveData = (pRegisterAddress & 0xFF);
}
fI2CWriteCount=0;
I2CWrite(cLinkId, cMasterId, cChipAddress, cSlaveData, cNbytes);
pChip->updateWriteCount( fI2CWriteCount );
fI2CReadCount=0;
uint32_t cReadBack = I2CRead(cLinkId, cMasterId, cChipAddress, 1);
pChip->updateReadCount( fI2CReadCount );
pChip->updateRegReadCount();
return cReadBack;
}
......
......@@ -830,6 +830,7 @@ class D19cFWInterface : public BeBoardFWInterface
// fast command generic block
void ResetFCMDBram();
void ConfigureFCMDBram(std::vector<uint8_t> pFastCommands);
};
} // namespace Ph2_HwInterface
......
......@@ -155,7 +155,6 @@ class D19clpGBTInterface : public lpGBTInterface
if(fFeType == FrontEndType::OuterTrackerPS) return {fReset_LHS_CIC, fReset_LHS_MPA, fReset_LHS_SSA, fReset_RHS_CIC, fReset_RHS_MPA, fReset_RHS_SSA};
return {};
}
private:
// default clock configuration
lpGBTClockConfig fClkConfig;
......@@ -171,6 +170,11 @@ class D19clpGBTInterface : public lpGBTInterface
// reset
uint8_t fResetMinPeriod = 100; // ms was 100
// number of read transactions
uint8_t fI2CReads_M0 = 0 ;
uint8_t fI2CReads_M1 = 0 ;
uint8_t fI2CReads_M2 = 0 ;
// clocks
uint8_t fClock_RHS_Hybrid = 1;
uint8_t fClock_LHS_Hybrid = 11;
......
......@@ -40,7 +40,7 @@ DetectorMonitor::~DetectorMonitor()
#ifdef __USE_ROOT__
fOutputFile->Write();
fOutputFile->Close();
delete fOutputFile;
// delete fOutputFile;
delete fMonitorPlotDQM;
#endif
}
......
......@@ -270,6 +270,41 @@ class SystemController
void DecodeData(const Ph2_HwDescription::BeBoard* pBoard, const std::vector<uint32_t>& pData, uint32_t pNevents, BoardType pType);
double findValueInSettings(const std::string name, double defaultValue = 0.) const;
void PrintRegCount()
{
// print number of I2C transactions
for(auto cBoard: *fDetectorContainer)
{
for(auto cOpticalGroup: *cBoard)
{
auto& clpGBT = cOpticalGroup->flpGBT;
for(auto cHybrid: *cOpticalGroup)
{
LOG (INFO) << BOLDBLUE << "Hybrid#" << +cHybrid->getId() << RESET;
uint8_t cMasterId = (cHybrid->getId()%2 == 0 ) ? 2 : 0 ;
for(auto cChip: *cHybrid)
{
LOG (INFO) << BOLDMAGENTA << "\t\t..Chip#" << +cChip->getId()
<< " performed " << cChip->getWriteCount() << " CPB I2C writes and "
<< cChip->getReadCount() << " CPB I2C reads; "
<< " wrote " << cChip->getRegWriteCount() << " registers and read "
<< cChip->getRegReadCount() << " registers."
<< RESET;
if( clpGBT != nullptr )
{
clpGBT->updateWriteCount( cMasterId , cChip->getWriteCount() );
clpGBT->updateReadCount( cMasterId , cChip->getReadCount() );
}
}
if( clpGBT != nullptr )
{
LOG (INFO) << BOLDBLUE << "\tCPB I2C writes on Master" << +cMasterId << " : " << clpGBT->getWriteCount( cMasterId ) << RESET;
LOG (INFO) << BOLDBLUE << "\tCPB I2C reads on Master" << +cMasterId << " : " << clpGBT->getReadCount( cMasterId ) << RESET;
}
}
}
}
}
private:
void SetFuture(const Ph2_HwDescription::BeBoard* pBoard, const std::vector<uint32_t>& pData, uint32_t pNevents, BoardType pType);
......
......@@ -12,7 +12,7 @@
<!-- RHS -->
<OpticalGroup Id="0" FMCId="0" >
<GBT phaseTap="7" enable="1"/>
<GBT phaseTap="8" enable="1"/>
<Hybrid Id="0" Status="1" LinkId="0" >
<Global>
<Settings threshold="560" latency="200"/>
......@@ -35,7 +35,7 @@
<CIC_Files path="${PH2ACF_BASE_DIR}/settings/CicFiles/" />
<CIC2 Id="8" configfile="CIC2_default.txt" />
</Hybrid>
<Hybrid Id="1" Status="1" LinkId="0" >
<Hybrid Id="1" Status="0" LinkId="0" >
<Global>
<Settings threshold="560" latency="200"/>
<TestPulse enable="1" polarity="0" amplitude="0xE1" channelgroup="0" delay="0" groundothers="0"/>
......
......@@ -788,6 +788,7 @@ int main(int argc, char* argv[])
cShortFinder.waitForRunToBeCompleted();
cShortFinder.Stop();
}
cTool.PrintRegCount();
cTool.dumpConfigFiles();
cTool.SaveResults();
cTool.WriteRootFile();
......@@ -804,7 +805,6 @@ int main(int argc, char* argv[])
cGoodRuns.open("GoodRunNumbers.dat", std::fstream::app);
cGoodRuns << cRunNumber << "\n";
cGoodRuns.close();
#ifdef __POWERSUPPLY__
cPowerLog.open(cTool.getDirectoryName() + "/PowerLog.tab", std::ios::app);
const auto cStop = std::chrono::system_clock::now();
......
......@@ -42,6 +42,23 @@ void RegisterTester::Initialise()
if(cIsPS) static_cast<PSInterface*>(fReadoutChipInterface)->ResetModifiedRegisterMap();
}
void RegisterTester::SendHardReset(const OpticalGroup* pOpticalGroup, const Chip* pFrontEndChip )
{
auto cBoardId = pOpticalGroup->getBeBoardId();
auto cBoardIter = std::find_if(fDetectorContainer->begin(), fDetectorContainer->end(), [&cBoardId](Ph2_HwDescription::BeBoard* x) { return x->getId() == cBoardId; });
auto& clpGBT = pOpticalGroup->flpGBT;
bool cWithLpGBT = ( clpGBT != nullptr);
if(!cWithLpGBT)
{
fBeBoardInterface->ChipReset((*cBoardIter));
}
else
{
if( pFrontEndChip->getFrontEndType() == FrontEndType::CBC3 ) static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetCBC(clpGBT, pFrontEndChip->getHybridId() % 2);
else if( pFrontEndChip->getFrontEndType() == FrontEndType::SSA ) static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetSSA(clpGBT, pFrontEndChip->getHybridId() % 2);
else static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetMPA(clpGBT, pFrontEndChip->getHybridId() % 2);
}
}
void RegisterTester::RegisterTest()
{
std::vector<std::string> cRegsToSkip{"Bandgap","ChipIDFuse","FeCtrl&TrgLat2"};
......@@ -50,8 +67,8 @@ void RegisterTester::RegisterTest()
// first just test page toggle
LOG(INFO) << BOLDMAGENTA << "Test" << +cTestFlavor << " of I2C registers in CBCs .... just going to toggle the page without writing..." << RESET;
uint8_t cSortOrder=0;
uint8_t cFirstPage=(cSortOrder==0)? 0 : 1;
std::vector<uint8_t> cPages{cFirstPage,static_cast<uint8_t>(~cFirstPage&0x01)};//static_cast<uint8_t>(~cFirstPage&0x01),cFirstPage,static_cast<uint8_t>(~cFirstPage&0x01)};
//uint8_t cFirstPage=(cSortOrder==0)? 0 : 1;
//std::vector<uint8_t> cPages{cFirstPage,static_cast<uint8_t>(~cFirstPage&0x01)};//static_cast<uint8_t>(~cFirstPage&0x01),cFirstPage,static_cast<uint8_t>(~cFirstPage&0x01)};
// first I want to record the register map for this map
......@@ -120,52 +137,6 @@ void RegisterTester::RegisterTest()
for(size_t cAttempt = 0; cAttempt < cAttempts; cAttempt++)
{
// so here .. I need to send a hard reset to the ROCs
LOG(INFO) << BOLDMAGENTA << "Sending hard reste to ROCs...[Test Attempt#" << +cAttempt << "]" << RESET;
for(auto cBoard: *fDetectorContainer)
{
auto cWithLpGBT = fReadoutChipInterface->lpGBTCheck(cBoard);
if(!cWithLpGBT)
{
fBeBoardInterface->ChipReset(cBoard);
continue;
}
for(auto cOpticalGroup: *cBoard)
{
auto& clpGBT = cOpticalGroup->flpGBT;
for(auto cHybrid: *cOpticalGroup)
{
auto cType = FrontEndType::CBC3;
bool cWithCBC = (std::find_if(cHybrid->begin(), cHybrid->end(), [&cType](Ph2_HwDescription::Chip* x) { return x->getFrontEndType() == cType; }) != cHybrid->end());
cType = FrontEndType::SSA;
bool cWithSSA = (std::find_if(cHybrid->begin(), cHybrid->end(), [&cType](Ph2_HwDescription::Chip* x) { return x->getFrontEndType() == cType; }) != cHybrid->end());
cType = FrontEndType::MPA;
bool cWithMPA = (std::find_if(cHybrid->begin(), cHybrid->end(), [&cType](Ph2_HwDescription::Chip* x) { return x->getFrontEndType() == cType; }) != cHybrid->end());
if(cWithCBC) static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetCBC(clpGBT, cHybrid->getId() % 2);
if(cWithSSA) static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetSSA(clpGBT, cHybrid->getId() % 2);
if(cWithMPA) static_cast<D19clpGBTInterface*>(flpGBTInterface)->resetMPA(clpGBT, cHybrid->getId() % 2);
}
}
} // board loop to send hard reset
// reset page map
LOG(INFO) << BOLDMAGENTA << "Resetting page map ..." << RESET;
for(auto cBoard: *fDetectorContainer)
{
for(auto cOpticalGroup: *cBoard)
{
for(auto cHybrid: *cOpticalGroup)
{
for(auto cChip: *cHybrid)
{
if( cChip->getFrontEndType() != FrontEndType::CBC3 ) continue;
static_cast<CbcInterface*>(fReadoutChipInterface)->resetPageMap();
} // chip
} // hybrid
} // OG
}
// now .. try and change page after config and look for mis-matches
for(auto cBoard: *fDetectorContainer)
{
......@@ -175,71 +146,77 @@ void RegisterTester::RegisterTest()
{
for(auto cChip: *cHybrid)
{
if( cChip->getFrontEndType() != FrontEndType::CBC3 ) continue;
LOG (INFO) << BOLDMAGENTA << "Chip#" << +cChip->getId() << " on hybrid" << +cHybrid->getId() << RESET;
Registers& cExpectedLst = cDefRegListContainer.at(cBoard->getIndex())->at(cOpticalGroup->getIndex())->at(cHybrid->getIndex())->at(cChip->getIndex())->getSummary<Registers>();
Registers cSensitiveRegisters;
cSensitiveRegisters.clear();
std::vector<int> cPageToggles(0);
for(auto cPage : cPages )
size_t cMatches = 0;
size_t cNRegs = 0;
for(auto& cItem: cExpectedLst) // loop over what I think the current values are
{
// here .. I need to send a hard reset to the ROCs
SendHardReset(cOpticalGroup, cChip);
// reset page map control
static_cast<CbcInterface*>(fReadoutChipInterface)->resetPageMap();
// read previous page
uint8_t cPreviousPage = static_cast<CbcInterface*>(fReadoutChipInterface)->GetLastPage(cChip);
LOG (INFO) << BOLDMAGENTA << "\t\t.. Going to select page " << +cPage
<< " - previous page was " << +cPreviousPage << RESET;
// static_cast<CbcInterface*>(fReadoutChipInterface)->ConfigurePage( cChip, cPage );
// check for mismatches
size_t cMatches = 0;
size_t cNRegs = 0;
for(auto& cItem: cExpectedLst) // loop over what I think the current values are
LOG (DEBUG) << BOLDMAGENTA << "Page after a hard reset is " << +cPreviousPage << RESET;
// if this page is the same .. ignore this register for now
if( cItem.second.fPage == cPreviousPage ) continue;
// so now I expect the value to be the default
// compare the value read back from the chip against what is expected
// if I'm reading from a different page - this means I'm switching pages
LOG (DEBUG) << BOLDMAGENTA << "\t... Reading back value from register " << cItem.first << " on page " << +cItem.second.fPage << " with expected value 0x"
<< std::hex << +cItem.second.fValue << std::dec
<< " when previous page is " << +cPreviousPage
<< RESET;
auto cReadBack = fReadoutChipInterface->ReadChipReg(cChip, cItem.first);
auto cValue = cItem.second.fValue;
bool cCorrupted = cReadBack != cValue;
if(cCorrupted)
{
//if( cItem.second.fPage == cPage ) continue;
// compare the value read back from the chip against what is expected
LOG (DEBUG) << BOLDMAGENTA << "\t... Reading back value from register " << cItem.first << " on page " << +cItem.second.fPage << " with value 0x"
<< std::hex << +cItem.second.fValue << std::dec << RESET;
auto cReadBack = fReadoutChipInterface->ReadChipReg(cChip, cItem.first);
auto cValue = cItem.second.fValue;
bool cCorrupted = cReadBack != cValue;
if(cCorrupted)
std::string cRegName = cItem.first;
if(std::find_if(cSensitiveRegisters.begin(), cSensitiveRegisters.end(), [&cRegName](Register x) { return x.first == cRegName; }) == cSensitiveRegisters.end())
{
std::string cRegName = cItem.first;
if(std::find_if(cSensitiveRegisters.begin(), cSensitiveRegisters.end(), [&cRegName](Register x) { return x.first == cRegName; }) == cSensitiveRegisters.end())
{
cSensitiveRegisters.push_back(cItem);
cPageToggles.push_back( cPreviousPage - cPage );
}
LOG (INFO) << BOLDRED << "\t\t\t\t..When switching from page " << +cPreviousPage
<< " to page " << +cPage
<< " register# " << +cNRegs
<< "\t\t...Mismatch in I2C register " << cItem.first << " value stored in map is 0x" << std::hex << +cItem.second.fValue << std::dec
<< " value read-back from chip is 0x" << std::hex << +cReadBack << std::dec << RESET;
// if register value does not match
// then update value in memory
cItem.second.fValue =cReadBack;
cSensitiveRegisters.push_back(cItem);
cPageToggles.push_back( cPreviousPage - cItem.second.fPage );
}
else
{
LOG (DEBUG) << BOLDGREEN << "\t\t...Match in I2C register " << cItem.first
<< " value stored in map is 0x" << std::hex << +cItem.second.fValue << std::dec
<< " value read-back from chip is 0x" << std::hex << +cReadBack << std::dec
<< RESET;
cMatches++;
}
cPreviousPage = cItem.second.fPage;
cNRegs++;
} // loop over current values and compare what I read back against what I have stored in memory
float cMatchedPerc = cMatches / (float)(cNRegs);
if( cMatches == cNRegs )
LOG(INFO) << BOLDGREEN << "\t\t.. Found read-back matched fraction from other registers to be " << 100 * cMatchedPerc << " percent. Found "
<< +cSensitiveRegisters.size() << " sensitive registers." << RESET;
LOG (INFO) << BOLDRED << "\t\t\t\t..When switching from page " << +cPreviousPage
<< " to page " << +cItem.second.fPage
<< " register# " << +cNRegs
<< "\t\t...Mismatch in I2C register " << cItem.first << " value stored in map is 0x" << std::hex << +cItem.second.fValue << std::dec
<< " value read-back from chip is 0x" << std::hex << +cReadBack << std::dec << RESET;
// if register value does not match
// then update value in memory
cItem.second.fValue =cReadBack;
}
else
LOG(INFO) << BOLDRED << "\t\t.. Found read-back matched fraction from other registers to be " << 100 * cMatchedPerc << " percent. Found "
<< +cSensitiveRegisters.size() << " sensitive registers." << RESET;
cPreviousPage = cPage;
} // register write loop
{
LOG (DEBUG) << BOLDGREEN << "\t\t\t\t..When switching from page " << +cPreviousPage
<< " to page " << +cItem.second.fPage
<< " register# " << +cNRegs
<< "\t\t...Match in I2C register " << cItem.first << " value stored in map is 0x" << std::hex << +cItem.second.fValue << std::dec
<< " value read-back from chip is 0x" << std::hex << +cReadBack << std::dec << RESET;
cMatches++;
}
cPreviousPage = cItem.second.fPage;
cNRegs++;
} // loop over current values and compare what I read back against what I have stored in memory
float cMatchedPerc = cMatches / (float)(cNRegs);
if( cMatches == cNRegs )
LOG(INFO) << BOLDGREEN << "\t\t.. Found read-back matched fraction from other registers to be " << 100 * cMatchedPerc << " percent. Found "
<< +cSensitiveRegisters.size() << " sensitive registers." << RESET;
else
LOG(INFO) << BOLDRED << "\t\t.. Found read-back matched fraction from other registers to be " << 100 * cMatchedPerc << " percent. Found "
<< +cSensitiveRegisters.size() << " sensitive registers." << RESET;
std::sort(cSensitiveRegisters.begin(), cSensitiveRegisters.end(), customGreaterThanAddress);
for( auto cSensitiveRegister : cSensitiveRegisters )
{
......
......@@ -79,6 +79,9 @@ class RegisterTester : public Tool
// Counters
uint32_t fNBadRegisters;
// HardReset
void SendHardReset(const Ph2_HwDescription::OpticalGroup* pOpticalGroup, const Ph2_HwDescription::Chip* pFrontEndChip );
// functions/procedures
void PrintTestResults(std::ostream& os = std::cout);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment