Commit ad17c554 authored by Christian Dz's avatar Christian Dz
Browse files

prep resync from opto-rx

parent edb7c0e7
......@@ -519,8 +519,8 @@ uint8_t D19clpGBTInterface::GetI2CStatus(Ph2_HwDescription::Chip* pChip, uint8_t
// Gets I2C Master status
std::string cI2CStatReg = "I2CM" + std::to_string(pMaster) + "Status";
uint8_t cStatus = ReadChipReg(pChip, cI2CStatReg);
LOG(INFO) << BOLDBLUE << "I2C Master " << +pMaster << " -- Status : " << fI2CStatusMap[cStatus] << RESET;
LOG(INFO) << BOLDBLUE << "I2C Master " << +pMaster << " -- Status : " << +cStatus << RESET;
// LOG(INFO) << BOLDBLUE << "I2C Master " << +pMaster << " -- Status : " << fI2CStatusMap[cStatus] << RESET;
// LOG(INFO) << BOLDBLUE << "I2C Master " << +pMaster << " -- Status : " << +cStatus << RESET;
return cStatus;
}
......
......@@ -5,6 +5,7 @@
###############-->
<BeBoard Id="0" boardType="D19C" eventType="SSA">
<connection id="board0" uri="ipbusudp-2.0://192.168.4.170:50001" address_table="file://settings/address_tables/uDTC_SEH_address_table.xml" />
<!-- <connection id="board0" uri="chtcp-2.0://localhost:10203?target=192.168.4.170:50001" address_table="file://settings/address_tables/uDTC_SEH_address_table.xml" /> -->
<CDCE configure="0" clockRate="320"/>
......@@ -139,6 +140,7 @@
###############-->
<BeBoard Id="1" boardType="D19C" eventType="SSA">
<connection id="board1" uri="ipbusudp-2.0://192.168.4.171:50001" address_table="file://settings/address_tables/uDTC_SEH_address_table.xml" />
<!-- <connection id="board1" uri="chtcp-2.0://localhost:10203?target=192.168.4.171:50001" address_table="file://settings/address_tables/uDTC_SEH_address_table.xml" /> -->
<CDCE configure="0" clockRate="120"/>
......
......@@ -5,7 +5,8 @@
<node id="standard">
<node id="status" address="0x00">
<node id="byteWrapState" mask="0x00000007"/>
<!-- <node id="byteWrapState" mask="0x00000007"/> -->
<node id="resyncReceived" mask="0x00000001"/>
<node id="prbsReady" mask="0x00000010"/>
<node id="bitAlign_done" mask="0x00000020"/>
<node id="latAlign_done" mask="0x00000040"/>
......
......@@ -288,6 +288,17 @@
<node id="bitAlign_value" mask="0x00000f00"/>
<node id="latAlign_value" mask="0x000ff000"/>
</node>
<node id="bert_toggle" address="0xA002">
<node id="patternSel" mask="0x0000000f"/>
<node id="disableCnt" mask="0x00000010"/>
<node id="fifoPause" mask="0x00000100"/>
<node id="prbsReset" mask="0x00001000"/>
<node id="bertReset" mask="0x00010000"/>
<node id="bertCntReset" mask="0x00100000"/>
<node id="failedReset" mask="0x01000000"/>
<node id="triggerResync" mask="0x02000000"/>
<node id="bertEnable" mask="0x10000000"/>
</node>
</node>
<node id="fc7_daq_ctrl" address="0x40020000" permission="rw" >
......@@ -787,7 +798,7 @@
-->
</node>
<node id="calibration_2s_block" address="0xE000">R
<node id="calibration_2s_block" address="0xE000">
<node id="general" address="0x000">
<node id="counters_ready" mask="0x00000001"/>
<node id="fifo_empty" mask="0x00000002"/>
......
......@@ -63,7 +63,7 @@ int main(int argc, char* argv[])
cmd.defineOption("testReset", "Test Reset lines");
cmd.defineOptionAlternative("testReset", "r");
// test I2C Masters
cmd.defineOption("testI2C", "Test I2C LpGBT Masters on SEH");
cmd.defineOption("testI2C", "Test I2C LpGBT Masters on SEH", ArgvParser::OptionRequiresValue);
cmd.defineOptionAlternative("testI2C", "i");
// test ADC channels
cmd.defineOption("testADC", "Test LpGBT ADCs on SEH");
......@@ -74,7 +74,8 @@ int main(int argc, char* argv[])
cmd.defineOption("testVTRxplus", "Test testVTRx+ slow control");
cmd.defineOptionAlternative("testVTRxplus", "v");
//
cmd.defineOption("cnfg-Gbtx", "do configureation of GBTx BEB Links");
cmd.defineOption("cnfg-lpgbt", "do configureation of lpGBT BEB Links", ArgvParser::NoOptionAttribute);
cmd.defineOption("cnfg-Gbtx", "do configureation of GBTx BEB Links", ArgvParser::NoOptionAttribute);
cmd.defineOption("testBERT", "Test LpGBT eLinks on SEH with Testboard");
cmd.defineOption("bert-len-s", "specify lenght of BER test in seconds", ArgvParser::OptionRequiresValue);
cmd.defineOptionAlternative("bert-len-s", "s");
......@@ -124,6 +125,7 @@ int main(int argc, char* argv[])
bool cIsResetTest = (cmd.foundOption("testReset"));
bool cIsVtrxTest = (cmd.foundOption("testVTRxplus"));
bool cIsI2cTest = (cmd.foundOption("testI2C"));
int cNbrI2cTestWords = cIsI2cTest ? convertAnyInt(cmd.optionValue("testI2C").c_str()) : 10;
bool cIsAdcTest = (cmd.foundOption("testADC"));
bool cIsNewBertSeconds = (cmd.foundOption("bert-len-s"));
bool cIsNewBertBits = (cmd.foundOption("bert-len-b"));
......@@ -162,9 +164,14 @@ int main(int argc, char* argv[])
// cSEHBertTestboardTester.exampleFit();
cSEHBertTestboardTester.Inherit(&cTool);
bool cSkipBebGbtxInit = (cmd.foundOption("cnfg-Gbtx")) ? false : true;
bool cSkipBebGbtxInit = (cmd.foundOption("cnfg-Gbtx")) ? false : true;
bool cSkipBebLpgbtInit = (cmd.foundOption("cnfg-lpgbt")) ? false : true;
cTool.ConfigureHw(false,false,cSkipBebGbtxInit);
cTool.ConfigureHw(true,cSkipBebLpgbtInit,cSkipBebGbtxInit);
int lSehIdUnderTest {0};
cSEHBertTestboardTester.PrimeOutputFileWithOptions(SEHBertTestboardTester::resultsOutputEnum::STORE_BOTH);
// std::vector<OpticalELinkBertData> vecOfOelb();
// vecOfOelb.reserve(28);
// for (int i=0 ; i<2 ; i++)
......@@ -257,9 +264,9 @@ int main(int argc, char* argv[])
/****************************/
if (cIsI2cTest)
{
std::vector<uint8_t> cMasters = {0, 2};
uint64_t cNbrOfTestsPerMaster {1};
bool cStatus = cSEHBertTestboardTester.LpGBTTestI2CMaster(cMasters,cNbrOfTestsPerMaster);
std::vector<uint8_t> cMasters = {2};
uint64_t cNbrOfTestsPerMaster = uint64_t(cNbrI2cTestWords);
bool cStatus = cSEHBertTestboardTester.LpGBTTestI2CMaster(lSehIdUnderTest,cMasters,cNbrOfTestsPerMaster);
if(cStatus)
LOG(INFO) << BOLDBLUE << "I2C test " << BOLDGREEN << " passed" << RESET;
else
......@@ -291,14 +298,15 @@ int main(int argc, char* argv[])
if (cIsNewBertBits)
cSEHBertTestboardTester.SetTestLimitByNWords(convertAnyInt(cmd.optionValue("bert-len-b").c_str()));
if(cIsBerTest)
if (cIsBerTest)
{
// cSEHBertTestboardTester.DoBitslipAlignmentManual(0,0x7F, 0x2);
cSEHBertTestboardTester.PrimeOutputFileWithOptions(SEHBertTestboardTester::resultsOutputEnum::STORE_BOTH);
cSEHBertTestboardTester.DoBitslipAlignmentManual(0,0xCA, 0x2);
cSEHBertTestboardTester.DoLatencyAlignmentManual(0,0xCA, 0x1);
cSEHBertTestboardTester.RunBertEvalation(0,2, SEHBertTestboardTester::resultsOutputEnum::STORE_BOTH, false);
cSEHBertTestboardTester.ConfigureLpgbt_Seh5GSetup(lSehIdUnderTest);
cSEHBertTestboardTester.DoBitslipAlignmentManual(lSehIdUnderTest,0xCA, 0x2);
cSEHBertTestboardTester.DoBitslipAlignmentManual(lSehIdUnderTest,0x7f, 0x2);
cSEHBertTestboardTester.DoLatencyAlignmentManual(lSehIdUnderTest,0xCA, 0x2);
cSEHBertTestboardTester.SwitchCommon_PatternSel(0x2);
// cSEHBertTestboardTester.RunBertEvalation(lSehIdUnderTest,2, SEHBertTestboardTester::resultsOutputEnum::STORE_BOTH, false);
}
/*
D19cFWInterface* cFWInterface = dynamic_cast<D19cFWInterface*>(cTool.fBeBoardInterface->getFirmwareInterface());
......@@ -311,6 +319,8 @@ int main(int argc, char* argv[])
// Save Result File
cSEHBertTestboardTester.FinalizeOutputFileWithOptions(SEHBertTestboardTester::resultsOutputEnum::STORE_BOTH);
cTool.SaveResults();
cTool.WriteRootFile();
cTool.CloseResultFile();
......
......@@ -18,7 +18,7 @@ OpticalELinkBertData::OpticalELinkBertData(Ph2_HwInterface::BeBoardInterface * p
mUserParameters = fDefaultParameters;
}
OpticalELinkBertData::~OpticalELinkBertData() {
if (fBeBoard!=nullptr) delete fBeBoard;
// if (fBeBoard!=nullptr) delete fBeBoard;
}
......@@ -30,6 +30,11 @@ bool OpticalELinkBertData::CheckIsBertRunning() {
std::string cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.status.bertRunning";
return (fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId))!= 0);
}
bool OpticalELinkBertData::CheckIsResyncReceived() {
std::string cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.status.resyncReceived";
return (fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId))!= 0);
}
std::string OpticalELinkBertData::QueryUnitStateMaschine() {
std::string cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.status.byteWrapState";
......@@ -92,12 +97,12 @@ void OpticalELinkBertData::IssueAnyReset(OpticalELinkBertData::reset_slot_enum p
void OpticalELinkBertData::CalculateBertRatio() {
if (mNbrReceivedWords!=0)
mBert_ration = 1.0*mNbrFailingWords / mNbrReceivedWords;
mBert_ration = 1.0* mNbrFailingBits / mNbrReceivedBits;
return;
}
void OpticalELinkBertData::CalculatePertRatio() {
if (mNbrReceivedBits!=0)
mPert_ration = 1.0* mNbrFailingBits / mNbrReceivedBits;
mPert_ration = 1.0* mNbrFailingWords / mNbrReceivedWords;
return;
}
......
......@@ -39,17 +39,19 @@ public:
Ph2_HwDescription::BeBoard* fBeBoard = nullptr;
int fDutId {0};
int fLinkId {0};
bool fUseMultiRegImpl {true};
bool fUseMultiRegImpl {false};
uint64_t mNbrFailingWords {0};
uint64_t mNbrReceivedWords {0};
uint64_t mNbrFailingBits {0};
uint64_t mNbrReceivedBits {0};
double mBert_ration {0};
double mPert_ration {0};
double mBert_ration {std::nan("")};
double mPert_ration {std::nan("")};
int mBitSlipMeasured {0};
int mLatecnyMeasured {0};
int mBitSlipMeasured {-1};
int mLatencyMeasured {-1};
int mBitSlipAtStack {-1};
int mLatencyAtStack {-1};
std::string mFile {""};
......@@ -100,23 +102,23 @@ public:
void ReadBackPatternSelection() ;
void ReadPatternOutSelection() ;
/**
* @brief set all board elinks pattern muxes to value specified
*
* @param pSel
* "0000" : idle
* "0001" : prbs7
* "0010" : static
* "0011" : reply
*/
void SwitchCommon_PatternSel(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.patternSel", pSel); }
void SwitchCommon_DisableCnt(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.disableCnt", pSel); }
void SwitchCommon_FifoPause(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.fifoPause", pSel); }
void SwitchCommon_PrbsReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.prbsReset", pSel); }
void SwitchCommon_BertReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertReset", pSel); }
void SwitchCommon_BertCntReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertCntReset", pSel); }
void SwitchCommon_FailedReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.failedReset", pSel); }
void SwitchCommon_BertEnable(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertEnable", pSel); }
// /**
// * @brief set all board elinks pattern muxes to value specified
// *
// * @param pSel
// * "0000" : idle
// * "0001" : prbs7
// * "0010" : static
// * "0011" : reply
// */
// void SwitchCommon_PatternSel(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.patternSel", pSel); }
// void SwitchCommon_DisableCnt(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.disableCnt", pSel); }
// void SwitchCommon_FifoPause(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.fifoPause", pSel); }
// void SwitchCommon_PrbsReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.prbsReset", pSel); }
// void SwitchCommon_BertReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertReset", pSel); }
// void SwitchCommon_BertCntReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertCntReset", pSel); }
// void SwitchCommon_FailedReset(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.failedReset", pSel); }
// void SwitchCommon_BertEnable(uint8_t pSel = 0x0) { fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_ctrl.bert_toggle.bertEnable", pSel); }
/**
* @brief specify 8-bit test pattern directly
......@@ -129,11 +131,13 @@ public:
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.pattern_value", (uint32_t)(pSel));
}
void ConfigureELink_bitslipValue(uint8_t pSel = 0x0) {
this->mBitSlipAtStack = pSel;
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.dut_select",(uint32_t) fDutId);
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.link_select", (uint32_t) fLinkId);
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.bitAlign_value", (uint32_t)(pSel));
}
void ConfigureELink_latencyValue(uint8_t pSel = 0x0) {
this->mLatencyAtStack = pSel;
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.dut_select",(uint32_t) fDutId);
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.link_select", (uint32_t) fLinkId);
fBeBoardInterface->WriteBoardReg(static_cast<BeBoard*>(fBeBoard), "fc7_daq_cnfg.bert_setup.latAlign_value", (uint32_t)(pSel));
......@@ -144,12 +148,23 @@ public:
uint8_t reply = (uint8_t) fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId));
LOG (INFO) << BLUE << "Read aligned rx-word ::" << BOLDYELLOW << std::bitset<8>(reply) << BOLDYELLOW << " : beb "<<fBeBoard->getId()<<" dut "<< fDutId<< " link " <<fLinkId<<RESET;
}
uint8_t ReturnAlignedRxWord() {
std::string cRegister ;
cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.ctrlCnfgReadback.AlignedRxData";
return (uint8_t) fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId));
// LOG (INFO) << BLUE << "Read aligned rx-word ::" << BOLDYELLOW << std::bitset<8>(reply) << BOLDYELLOW << " : beb "<<fBeBoard->getId()<<" dut "<< fDutId<< " link " <<fLinkId<<RESET;
}
void CheckELink_SendingTxWord() {
std::string cRegister ;
cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.ctrlCnfgReadback.StaticPattern";
uint8_t reply = (uint8_t) fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId));
LOG (INFO) << BLUE << "Read static pattern out ::" << BOLDYELLOW << std::bitset<8>(reply) << BOLDYELLOW << " : beb "<<fBeBoard->getId()<<" dut "<< fDutId<< " link " <<fLinkId<<RESET;
}
uint8_t ReturnSendingTxWord() {
std::string cRegister ;
cRegister = "fc7_daq_stat.bert_block.dut%d.link%d.standard.ctrlCnfgReadback.StaticPattern";
return (uint8_t) fBeBoardInterface->ReadBoardReg(static_cast<BeBoard*>(fBeBoard), string_format(cRegister.c_str(),fDutId,fLinkId));
}
void ConfigureAnyAlignmentMode(bitslip_latency_enum pAligner, std::string pAligmentMode = "AUTO") ;
void StartAnyAligment(bitslip_latency_enum pAligner) ;
......@@ -162,6 +177,7 @@ public:
bool CheckIsPrbsReady() ;
bool CheckIsBertRunning() ;
bool CheckIsResyncReceived() ;
void WriteBertUnitEnable(int pEnable) ;
void IssueAnyReset(reset_slot_enum pRstSlot) ;
std::string QueryUnitStateMaschine() ;
......
......@@ -20,6 +20,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include "TDatime.h"
#include "TCanvas.h"
#include "TGraph.h"
#include "TGraphAsymmErrors.h"
......@@ -74,7 +75,7 @@ void SEHBertTestboardTester::BertContainerInit()
{
fOpticalElinkBertContainers.clear();
fOpticalElinkBertContainers.reserve(fNumberOfELinks*fNumberOfDuts*3);
// LOG (DEBUG) << "BORD IN CONTAINER : size of fDetectorContainer "<< fDetectorContainer->size()<< " reserved : "<< (fNumberOfELinks*fNumberOfDuts) << RESET;
LOG (DEBUG) << "BORD IN CONTAINER : size of fDetectorContainer "<< fDetectorContainer->size()<< " reserved : "<< (fNumberOfELinks*fNumberOfDuts) << RESET;
for(int cLinkId = 0; cLinkId<fNumberOfELinks; cLinkId ++) {
for(int cDutId = 0; cDutId<fNumberOfDuts; cDutId ++) {
......@@ -209,69 +210,86 @@ bool SEHBertTestboardTester::LpGBTTestGPILines(uint64_t pNbrOfToggles)
return cValid;
}
bool SEHBertTestboardTester::LpGBTTestI2CMaster(const std::vector<uint8_t>& pMasters, uint64_t pNbrTests)
bool SEHBertTestboardTester::LpGBTTestI2CMaster(int pSehId, const std::vector<uint8_t>& pMasters, uint64_t pNbrTests,int pUpdateIntervall)
{
bool cTestSuccess = true;
std::vector<int> cTestSuccesses = std::vector<int> (pMasters.size(),1);
bool cTestSuccess = true;
std::vector<int> cTestSuccesses = std::vector<int> (pMasters.size(),1);
std::vector<double> cTestAccuBer = std::vector<double> (pMasters.size(),0.);
D19clpGBTInterface* clpGBTInterface = static_cast<D19clpGBTInterface*>(flpGBTInterface);
mDateTimeObj = new TDatime();
uint8_t cSuccess {0};
uint8_t cSlaveAddress = 0x50;
uint32_t cReadData {0};
std::srand(std::time(nullptr)); // use current time as seed for random generator
uint16_t random_variable_16bit = std::rand() % 0x7fff;
uint8_t random_variable_8bit = std::rand() % 0xff;
uint16_t random_variable_16bit = 0;
uint8_t random_variable_8bit = 0;
// random_variable_16bit = random_variable_16bit<<8|random_variable_16bit>>8;
int random_variable_24bit = (random_variable_16bit<<8)|(random_variable_8bit<<0);
int random_variable_24bit = 0;
int masterIter = 0;
for(auto cBoard: *fDetectorContainer)
{
if(cBoard->at(0)->flpGBT == nullptr) continue;
if(cBoard->at(pSehId)->flpGBT == nullptr) continue;
for(auto cOpticalGroup: *cBoard)
{
clpGBTInterface->ResetI2C(cOpticalGroup->flpGBT, {0, 1, 2});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
for(const auto cMaster: pMasters)
{
for (uint64_t test_i=0 ; test_i < pNbrTests ; test_i ++){
random_variable_16bit = std::rand() % 0x7ff;
for (uint64_t test_i=0 ; test_i < pNbrTests ; test_i ++) {
if (test_i%pUpdateIntervall==0)
LOG (INFO) << "I2C Test :: " << test_i << "/" << pNbrTests << " --> " << cTestAccuBer.back() << RESET;
masterIter = 0;
for(const auto cMaster: pMasters) {
random_variable_16bit = std::rand() % 0x7fff;
random_variable_8bit = std::rand() % 0xff;
random_variable_24bit = 0xffffff&((random_variable_8bit<<16)|(random_variable_16bit<<0));
mDateTimeObj->Set();
cSuccess = clpGBTInterface->WriteI2C(cOpticalGroup->flpGBT, cMaster, cSlaveAddress, random_variable_24bit, 3);
cSuccess = clpGBTInterface->WriteI2C(cOpticalGroup->flpGBT, cMaster, cSlaveAddress, random_variable_16bit, 2);
cReadData = clpGBTInterface->ReadI2C(cOpticalGroup->flpGBT, cMaster, cSlaveAddress, 1);
cTestSuccesses[cMaster] &= cSuccess;
cTestSuccesses[cMaster] &= (uint8_t(cReadData) == random_variable_8bit) ? true : false ;
if (uint8_t(cReadData) != random_variable_8bit)
LOG(INFO) << BOLDRED << "I2C Master " << +cMaster << " send 0b" << std::bitset<8>(random_variable_8bit) << " to " << std::hex << random_variable_16bit << " reads 0b" << std::bitset<8>(cReadData) << RESET;
else
LOG(INFO) << BOLDGREEN << "I2C Master " << +cMaster << " send 0b" << std::bitset<8>(random_variable_8bit) << " to " << std::hex << random_variable_16bit << " reads 0b" << std::bitset<8>(cReadData) << RESET;
cTestSuccesses[masterIter] &= cSuccess;
cTestSuccesses[masterIter] &= (uint8_t(cReadData) == random_variable_8bit) ? true : false ;
// if (uint8_t(cReadData) != random_variable_8bit)
// LOG(INFO) << BOLDRED << "I2C Master " << +cMaster << " send 0b" << std::bitset<8>(random_variable_8bit) << " to " << std::hex << random_variable_16bit << " reads 0b" << std::bitset<8>(cReadData) << RESET;
// else
// LOG(INFO) << BOLDGREEN << "I2C Master " << +cMaster << " send 0b" << std::bitset<8>(random_variable_8bit) << " to " << std::hex << random_variable_16bit << " reads 0b" << std::bitset<8>(cReadData) << RESET;
mI2cBitsWritten = random_variable_8bit;
mI2cAddrWritten = random_variable_16bit;
mI2cBitsReading = cReadData;
mI2cBitErroRation = std::bitset<8>(random_variable_8bit ^ uint8_t(cReadData)).count()/8.;
mI2cMaster = cMaster;
mI2cSehIdBranch = pSehId;
mI2CErrorTtree->Fill();
cTestAccuBer[masterIter] += mI2cBitErroRation;
masterIter++;
}
fillSummaryTree(Form("i2cmaster%i", cMaster), cSuccess);
// fillSummaryTree(Form("i2cmaster%i", cMaster), cSuccess);
}
}
}
masterIter=0;
for(const auto cMaster: pMasters)
{
if(cTestSuccesses[cMaster])
if(cTestSuccesses[masterIter])
LOG(INFO) << BOLDGREEN << "I2C Master " << +cMaster << " PASSED" << RESET;
else
LOG(INFO) << BOLDRED << "I2C Master " << +cMaster << " FAILED" << RESET;
cTestSuccess &= cTestSuccesses[cMaster];
cTestSuccess &= cTestSuccesses[masterIter];
masterIter++;
}
return cTestSuccess;
}
void SEHBertTestboardTester::ConfigureLpgbt_Seh5GSetup() {
void SEHBertTestboardTester::ConfigureLpgbt_Seh5GSetup(int pSehId) {
D19clpGBTInterface* clpGBTInterface = static_cast<D19clpGBTInterface*>(flpGBTInterface);
for(auto cBoard: *fDetectorContainer) {
for(auto cOpticalGroup: *cBoard) {
if(cOpticalGroup->flpGBT == nullptr) continue;
if (cOpticalGroup->getOpticalGroupId() != pSehId) continue;
if (cOpticalGroup->flpGBT == nullptr) continue;
clpGBTInterface->Configure2SSEH(cOpticalGroup->flpGBT);
}
}
......@@ -431,7 +449,10 @@ void SEHBertTestboardTester::DoBitslipAlignmentManual(int pSehId, uint8_t pPatte
// bool lLpgbtTrxSuc = true;
std::vector<uint64_t> vecOfBers;
std::vector<std::pair<uint8_t,double>> vecOfBerPairs;
ConfigureLpgbt_Seh5GSetup();
std::vector<int> vecOfLastBSVal,vecOfNewBSVal;
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]) {
vecOfLastBSVal.push_back( cOelb->mBitSlipMeasured );
}
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]) {
cOelb->ConfigureELink_TestPattern(pPattern);
......@@ -507,7 +528,7 @@ void SEHBertTestboardTester::DoBitslipAlignmentManual(int pSehId, uint8_t pPatte
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]) {
cOelb->ConfigureELink_bitslipValue(cOelb->mBitSlipMeasured);
}
SwitchCommon_BertEnable(0x0);
SwitchCommon_DisableCnt(0x1);
SwitchCommon_BertCntReset(0x1);
......@@ -529,7 +550,22 @@ void SEHBertTestboardTester::DoBitslipAlignmentManual(int pSehId, uint8_t pPatte
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]) {
int dutid = cOelb->fBeBoard->getId()*2+cOelb->fDutId;
LOG (INFO) << BOLDBLUE << cOelb->fBeBoard->getId() <<", "<< cOelb->fDutId << ", "<<cOelb->fLinkId << " :: "<< BOLDGREEN << +cOelb->mBitSlipMeasured << " --> " << cOelb->mPert_ration << " ("<< +cOelb->mBert_ration<<") @ " <<" ("<< +cOelb->mNbrFailingWords<<" / "<< +cOelb->mNbrReceivedWords<<") "<< BOLDYELLOW << std::bitset<8>(fLastSendTxWord[std::make_pair(dutid,cOelb->fLinkId)])<<" >> " << std::bitset<8>(fLastReceivedRxWord[std::make_pair(dutid,cOelb->fLinkId)]) << RESET;
vecOfNewBSVal.push_back(cOelb->mBitSlipMeasured);
}
int vecIter = 0;
if (vecOfLastBSVal.front() != -1) {
LOG (INFO) << BOLDBLUE << "Check bitslip stability, compare old to new scan values:" << RESET;
}
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]) {
if (vecOfLastBSVal[vecIter] != -1) {
if (vecOfLastBSVal[vecIter] == vecOfNewBSVal[vecIter])
LOG (INFO) << BOLDGREEN << cOelb->fBeBoard->getId() <<", "<< cOelb->fDutId << ", "<<cOelb->fLinkId << " :: " << "DID MATCHES : " << +vecOfLastBSVal[vecIter] << RESET;
else
LOG (INFO) << BOLDRED << cOelb->fBeBoard->getId() <<", "<< cOelb->fDutId << ", "<<cOelb->fLinkId << " :: " << "DID NOT MATCHES : " << +vecOfLastBSVal[vecIter] << "->" << +vecOfNewBSVal[vecIter] << RESET;
}
}
}
void SEHBertTestboardTester::DoLatencyAlignmentManual(int pSehId, uint8_t pPattern, uint8_t pPatSel) {
......@@ -587,7 +623,12 @@ void SEHBertTestboardTester::DoLatencyAlignmentManual(int pSehId, uint8_t pPatte
SwitchCommon_DisableCnt(0x1);
SwitchCommon_BertCntReset(0x1);
SwitchCommon_FailedReset(0x1);
SwitchCommon_BertReset(0x1);
SwitchCommon_BertReset(0x1);
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]){
cOelb->ConfigureELink_bitslipValue(cOelb->mBitSlipMeasured);
cOelb->ConfigureELink_latencyValue(lLatency);
cOelb->ConfigureELink_TestPattern(0xCA);
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
......@@ -598,6 +639,13 @@ void SEHBertTestboardTester::DoLatencyAlignmentManual(int pSehId, uint8_t pPatte
SwitchCommon_DisableCnt(0x0);
SwitchCommon_BertEnable(0x1);
std::this_thread::sleep_for(std::chrono::milliseconds(250));
for(const auto & cOelb : fSehIdToListOfOELBs[pSehId]){
cOelb->ConfigureELink_bitslipValue(cOelb->mBitSlipMeasured);
cOelb->ConfigureELink_latencyValue(lLatency);
cOelb->ConfigureELink_TestPattern(0XF7);
}
std::this_thread::sleep_for(std::chrono::milliseconds(250));
ReadBertUpdates(pSehId);
......@@ -899,28 +947,37 @@ void SEHBertTestboardTester::PrimeOutputFileWithOptions(int pSehId,resultsOutput
srand(time(NULL));
clock_gettime(CLOCK_MONOTONIC, &mStartTime);
fResultFile->cd();
mMeasurementTtree = new TTree("measuredDateTree", "Data Ttree");
mBitErrorTtree = new TTree("mBitErrorTtree", "Optical Data Bit Error Test Ttree");
// Create variables for TTree branches
mMeasurementTtree->Branch("Time", &mTimeValBranch);
mMeasurementTtree->Branch("SehId", &mSehIdBranch);
mMeasurementTtree->Branch("BebId", &mBebIdBranch);
mMeasurementTtree->Branch("DutId", &mDutIdBranch);
mMeasurementTtree->Branch("ElinkId", &mElinkIdBranch);
mMeasurementTtree->Branch("isPreparation", &mIsPreparationMeasurement);
mMeasurementTtree->Branch("isBitslip", &mIsBitslipMeasurement);
mMeasurementTtree->Branch("isLatency", &mIsLatencyMeasurement);
mMeasurementTtree->Branch("isErrorTesting", &mIsErrorTestingMeasurement);
mMeasurementTtree->Branch("latency", &mMeasuredLatency);
mMeasurementTtree->Branch("bitslip", &mMeasuredBitslip);
mMeasurementTtree->Branch("per", &mPert_ration);
mMeasurementTtree->Branch("ber", &mBert_ration);
mMeasurementTtree->Branch("NWordsReceived", &mNWordsReceivedBranch);
mMeasurementTtree->Branch("NBitsReceived", &mNBitsReceivedBranch);
mMeasurementTtree->Branch("NWordsFailing", &mNWordsFailingBranch);
mMeasurementTtree->Branch("NBitsFailing", &mBitsFailingBranch);
mBitErrorTtree->Branch("Time", &mTimeValBranch);
mBitErrorTtree->Branch("SehId", &mSehIdBranch);
mBitErrorTtree->Branch("BebId", &mBebIdBranch);
mBitErrorTtree->Branch("DutId", &mDutIdBranch);
mBitErrorTtree->Branch("ElinkId", &mElinkIdBranch);
mBitErrorTtree->Branch("isPreparation", &mIsPreparationMeasurement);
mBitErrorTtree->Branch("isBitslip", &mIsBitslipMeasurement);
mBitErrorTtree->Branch("isLatency", &mIsLatencyMeasurement);
mBitErrorTtree->Branch("isErrorTesting", &mIsErrorTestingMeasurement);
mBitErrorTtree->Branch("latency", &mMeasuredLatency);
mBitErrorTtree->Branch("bitslip", &mMeasuredBitslip);
mBitErrorTtree->Branch("per", &mPert_ration);
mBitErrorTtree->Branch("ber", &mBert_ration);
mBitErrorTtree->Branch("NWordsReceived", &mNWordsReceivedBranch);
mBitErrorTtree->Branch("NBitsReceived", &mNBitsReceivedBranch);
mBitErrorTtree->Branch("NWordsFailing", &mNWordsFailingBranch);
mBitErrorTtree->Branch("NBitsFailing", &mBitsFailingBranch);
mI2CErrorTtree = new TTree("mI2CErrorTtree", "I2C Write-Read Error Test Ttree");
mI2CErrorTtree->Branch("DateTime", &mDateTimeObj);
mI2CErrorTtree->Branch("SehId", &mI2cSehIdBranch);
mI2CErrorTtree->Branch("i2cMaster", &mI2cMaster);
mI2CErrorTtree->Branch("bitsWritten", &mI2cBitsWritten);
mI2CErrorTtree->Branch("bitsReading", &mI2cBitsReading);
mI2CErrorTtree->Branch("ber", &mI2cBitErroRation);
mI2CErrorTtree->Branch("addrWritten", &mI2cAddrWritten);
}
return;
}
......@@ -932,7 +989,8 @@ void SEHBertTestboardTester::FinalizeOutputFileWithOptions(resultsOutputEnum pOu
}
if (pOutputType == resultsOutputEnum::STORE_GRAPH || pOutputType == resultsOutputEnum::STORE_BOTH) {
fResultFile->cd();
mMeasurementTtree->Write();
mI2CErrorTtree->Write();
mBitErrorTtree->Write();
fResultFile->mkdir("bitSlipAlignment");
fResultFile->mkdir("latencyAlignment");
fResultFile->mkdir("errorMeasurement");
......@@ -944,15 +1002,15 @@ void SEHBertTestboardTester::FinalizeOutputFileWithOptions(resultsOutputEnum pOu
c1->Divide(4,4);
for (int lElinkId=0 ; lElinkId<14 ;lElinkId++){
c1->cd(lElinkId+1);
mMeasurementTtree->Draw("Time : bitslip : ber : per : NBitsFailing : NBitsReceived" ,TString::Format("isBitslip && BebId==0 && ElinkId==%i",lElinkId),"goff" );
mBitErrorTtree->Draw("Time : bitslip : ber : per : NBitsFailing : NBitsReceived" ,TString::Format("isBitslip && BebId==0 && ElinkId==%i",lElinkId),"goff" );
int n = mMeasurementTtree->GetSelectedRows();
auto t = mMeasurementTtree->GetVal(0);
auto b = mMeasurementTtree->GetVal(1);
auto ber = mMeasurementTtree->GetVal(2);
auto per = mMeasurementTtree->GetVal(3);
auto nErr = mMeasurementTtree->GetVal(4);
auto nRec = mMeasurementTtree->GetVal(5);
int n = mBitErrorTtree->GetSelectedRows();
auto t = mBitErrorTtree->GetVal(0);
auto b = mBitErrorTtree->GetVal(1);
auto ber = mBitErrorTtree->GetVal(2);