Commit 851c87f9 authored by Fabio Ravera's avatar Fabio Ravera
Browse files

Merge branch 'master' into 'Dev'

Periodic merge with OT

See merge request cms_tk_ph2/Ph2_ACF!161
parents b2330887 50cc3129
......@@ -26,7 +26,7 @@ const RD53::FrontEnd* RD53::getMajorityFE(size_t colStart, size_t colStop)
});
}
RD53::RD53(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pRD53Id, uint8_t pRD53Lane, const std::string& fileName) : ReadoutChip(pBeId, pFMCId, pFeId, pRD53Id)
RD53::RD53(uint8_t pBeId, uint8_t pFMCId, uint8_t pHybridId, uint8_t pRD53Id, uint8_t pRD53Lane, const std::string& fileName) : ReadoutChip(pBeId, pFMCId, pHybridId, pRD53Id)
{
fMaxRegValue = RD53Shared::setBits(RD53Constants::NBIT_MAXREG);
fChipOriginalMask = new ChannelGroup<nRows, nCols>;
......
......@@ -131,7 +131,7 @@ class RD53 : public ReadoutChip
static const FrontEnd* frontEnds[];
static const FrontEnd* getMajorityFE(size_t colStart, size_t colStop);
RD53(uint8_t pBeId, uint8_t pFMCId, uint8_t pFeId, uint8_t pRD53Id, uint8_t pRD53Lane, const std::string& fileName);
RD53(uint8_t pBeId, uint8_t pFMCId, uint8_t pHybridId, uint8_t pRD53Id, uint8_t pRD53Lane, const std::string& fileName);
RD53(const RD53& chipObj);
void loadfRegMap(const std::string& fileName) override;
......
......@@ -147,8 +147,8 @@ class BeBoardInterface
* \param pBoard
* \param pRegVec : Vector of Register/Value pairs
*/
void ReadBoardMultReg(Ph2_HwDescription::BeBoard* pBoard, std::vector<std::pair<std::string, uint32_t>>& pRegVec);
/*!
* \brief Get the board infos
* \param pBoard
......@@ -171,14 +171,14 @@ class BeBoardInterface
* \brief Hard reset of all Chip
* \param pChip
*/
void ChipReSync(const Ph2_HwDescription::BeBoard* pBoard);
/*!
* \brief Fast Reset of the Chip
* \param pChip
*/
void ChipReset(const Ph2_HwDescription::BeBoard* pBoard);
/*!
* \brief Send Chip Trigger
* \param pChip
......@@ -223,7 +223,7 @@ class BeBoardInterface
* \return none
*/
template <typename... Ts>
void ReadChipMonitor(Ph2_HwInterface::ReadoutChipInterface* pReadoutChipInterface, Ph2_HwDescription::Chip* pChip, const Ts&... args)
void ReadChipMonitor(Ph2_HwInterface::ReadoutChipInterface* pReadoutChipInterface, Ph2_HwDescription::ReadoutChip* pChip, const Ts&... args)
{
std::lock_guard<std::mutex> theGuard(theMtx);
......
......@@ -128,28 +128,16 @@ void RD53FWInterface::ConfigureBoard(const BeBoard* pBoard)
// # 2 = double chip hybrid #
// # 4 = quad chip hybrid #
// ################################
this->singleChip = ReadReg("user.stat_regs.aurora_rx.Module_type") == 1;
uint32_t chips_en = 0;
enabledHybrids = 0;
this->singleChip = ReadReg("user.stat_regs.aurora_rx.Module_type") == 1;
this->enabledHybrids = 0;
uint32_t chips_en = 0;
for(const auto cOpticalGroup: *pBoard)
for(const auto cHybrid: *cOpticalGroup)
{
uint16_t hybrid_id = cHybrid->getId();
enabledHybrids |= 1 << hybrid_id;
if(this->singleChip == true)
chips_en = enabledHybrids;
else
{
uint16_t mod_chips_en = 0;
for(const auto cChip: *cHybrid)
{
uint16_t chip_lane = static_cast<RD53*>(cChip)->getChipLane();
mod_chips_en |= 1 << chip_lane;
}
chips_en |= mod_chips_en << (NLANE_HYBRID * hybrid_id);
}
this->enabledHybrids |= 1 << cHybrid->getId();
chips_en |= RD53FWInterface::GetHybridEnabledChips(cHybrid);
}
cVecReg.push_back({"user.ctrl_regs.Hybrids_en", enabledHybrids});
cVecReg.push_back({"user.ctrl_regs.Hybrids_en", this->enabledHybrids});
cVecReg.push_back({"user.ctrl_regs.Chips_en", chips_en});
if(cVecReg.size() != 0) RegManager::WriteStackReg(cVecReg);
......@@ -204,7 +192,6 @@ void RD53FWInterface::WriteChipCommand(const std::vector<uint16_t>& data, int hy
// # Check if all good #
// #####################
if(ReadReg("user.stat_regs.slow_cmd.error_flag") == true) LOG(ERROR) << BOLDRED << "Write-command FIFO error" << RESET;
if(ReadReg("user.stat_regs.slow_cmd.fifo_empty") == false) LOG(ERROR) << BOLDRED << "Write-command FIFO not empty" << RESET;
// #######################
......@@ -239,15 +226,15 @@ void RD53FWInterface::WriteChipCommand(const std::vector<uint16_t>& data, int hy
if(retry == true) LOG(ERROR) << BOLDRED << "Error while dispatching chip register program, reached maximum number of attempts (" << BOLDYELLOW << MAXATTEMPTS << BOLDRED << ")" << RESET;
}
std::vector<std::pair<uint16_t, uint16_t>> RD53FWInterface::ReadChipRegisters(Chip* pChip)
std::vector<std::pair<uint16_t, uint16_t>> RD53FWInterface::ReadChipRegisters(ReadoutChip* pChip)
{
std::vector<std::pair<uint16_t, uint16_t>> regReadback;
uint32_t chipLane;
if(this->singleChip == true)
chipLane = pChip->getHybridId(); // @TMP@
else
chipLane = NLANE_HYBRID * pChip->getHybridId() + static_cast<RD53*>(pChip)->getChipLane(); // @TMP@
// #################################
// # Compose chip-lane in readback #
// #################################
uint32_t chipLane = pChip->getHybridId();
if(this->singleChip != true) chipLane = NLANE_HYBRID * chipLane + static_cast<RD53*>(pChip)->getChipLane();
// #####################
// # Read the register #
......@@ -364,26 +351,12 @@ void RD53FWInterface::InitHybridByHybrid(const BeBoard* pBoard)
for(const auto cOpticalGroup: *pBoard)
for(const auto cHybrid: *cOpticalGroup)
{
// ########################
// # Retrieve lane number #
// ########################
const uint16_t hybrid_id = cHybrid->getId();
uint16_t mod_chips_en = 0;
uint16_t chips_en_to_check;
for(const auto cChip: *cHybrid)
{
uint16_t chip_lane = static_cast<RD53*>(cChip)->getChipLane();
mod_chips_en |= 1 << chip_lane;
}
if(this->singleChip == true)
chips_en_to_check = mod_chips_en << hybrid_id;
else
chips_en_to_check = mod_chips_en << (NLANE_HYBRID * hybrid_id);
// #############################
// # Check if all lanes are up #
// #############################
uint32_t channel_up = ReadReg("user.stat_regs.aurora_rx_channel_up");
const uint32_t hybrid_id = cHybrid->getId();
const uint32_t chips_en_to_check = RD53FWInterface::GetHybridEnabledChips(cHybrid);
const uint32_t channel_up = ReadReg("user.stat_regs.aurora_rx_channel_up");
if((channel_up & chips_en_to_check) == chips_en_to_check)
{
......@@ -471,6 +444,27 @@ std::vector<uint16_t> RD53FWInterface::GetInitSequence(const unsigned int type)
return initSequence;
}
uint32_t RD53FWInterface::GetHybridEnabledChips(const Hybrid* pHybrid)
{
const uint32_t hybrid_id = pHybrid->getId();
uint32_t chips_en = 0;
if(this->singleChip == true)
chips_en = 1 << hybrid_id;
else
{
uint32_t hyb_chips_en = 0;
for(const auto cChip: *pHybrid)
{
uint32_t chip_lane = static_cast<RD53*>(cChip)->getChipLane();
hyb_chips_en |= 1 << chip_lane;
}
chips_en |= hyb_chips_en << (NLANE_HYBRID * hybrid_id);
}
return chips_en;
}
void RD53FWInterface::Start()
{
RD53FWInterface::ChipReset();
......@@ -747,7 +741,7 @@ void RD53FWInterface::ReadNEvents(BeBoard* pBoard, uint32_t pNEvents, std::vecto
// ##################
decodedEvents.clear();
uint16_t status = RD53FWInterface::DecodeEventsMultiThreads(pData, decodedEvents); // Decode events with multiple threads
// uint16_t status = RD53FWInterface::DecodeEvents(pData, decodedEvents, {}); // Decode events with a
// uint16_t status = RD53FWInterface::DecodeEvents(pData, decodedEvents, {}); // Decode events with a single thread
// RD53FWInterface::PrintEvents(decodedEvents, pData); // @TMP@
if(RD53FWInterface::EvtErrorHandler(status) == false)
{
......
......@@ -108,12 +108,8 @@ class RD53FWInterface : public BeBoardFWInterface
void ChipReset() override;
void ChipReSync() override;
bool CheckChipCommunication();
void InitHybridByHybrid(const Ph2_HwDescription::BeBoard* pBoard);
std::vector<uint16_t> GetInitSequence(const unsigned int type);
void WriteChipCommand(const std::vector<uint16_t>& data, int hybridId);
std::vector<std::pair<uint16_t, uint16_t>> ReadChipRegisters(Ph2_HwDescription::Chip* pChip);
std::vector<std::pair<uint16_t, uint16_t>> ReadChipRegisters(Ph2_HwDescription::ReadoutChip* pChip);
struct ChipFrame
{
......@@ -281,16 +277,20 @@ class RD53FWInterface : public BeBoardFWInterface
bool RunPRBStest(bool given_time, unsigned long long frames_or_time, uint16_t hybrid_id, uint16_t chip_id);
private:
void PrintFWstatus();
void TurnOffFMC();
void TurnOnFMC();
void ResetBoard();
void ResetFastCmdBlk();
void ResetSlowCmdBlk();
void ResetReadoutBlk();
void ConfigureFastCommands(const FastCommandsConfig* config = nullptr);
void ConfigureDIO5(const DIO5Config* config);
void SendBoardCommand(const std::string& cmd_reg);
void PrintFWstatus();
void TurnOffFMC();
void TurnOnFMC();
void ResetBoard();
void ResetFastCmdBlk();
void ResetSlowCmdBlk();
void ResetReadoutBlk();
void ConfigureFastCommands(const FastCommandsConfig* config = nullptr);
void ConfigureDIO5(const DIO5Config* config);
void SendBoardCommand(const std::string& cmd_reg);
bool CheckChipCommunication();
void InitHybridByHybrid(const Ph2_HwDescription::BeBoard* pBoard);
std::vector<uint16_t> GetInitSequence(const unsigned int type);
uint32_t GetHybridEnabledChips(const Ph2_HwDescription::Hybrid* pHybrid);
// ###################
// # Clock generator #
......@@ -301,8 +301,8 @@ class RD53FWInterface : public BeBoardFWInterface
FastCommandsConfig localCfgFastCmd;
D19cFpgaConfig* fpgaConfig;
size_t ddr3Offset;
uint16_t enabledHybrids;
bool singleChip;
uint16_t enabledHybrids;
};
} // namespace Ph2_HwInterface
......
......@@ -15,6 +15,17 @@ namespace Ph2_HwInterface
{
RD53Interface::RD53Interface(const BeBoardFWMap& pBoardMap) : ReadoutChipInterface(pBoardMap) {}
int RD53Interface::CheckChipID(Chip* pChip, int chipIDfromDB)
{
// @TMP@ : to be implemented for RD53B
auto chipID = RD53Interface::ReadChipReg(pChip, "CHIP_ID");
if(chipID == chipIDfromDB)
LOG(INFO) << GREEN << "Chip ID: " << BOLDYELLOW << chipID << RESET << GREEN << " --> same as in database: " << BOLDYELLOW << chipIDfromDB << RESET;
else
LOG(WARNING) << GREEN << "Chip ID: " << BOLDYELLOW << chipID << RESET << GREEN << " --> different from database: " << BOLDYELLOW << chipIDfromDB << RESET;
return chipID;
}
bool RD53Interface::ConfigureChip(Chip* pChip, bool pVerifLoop, uint32_t pBlockSize)
{
this->setBoard(pChip->getBeBoardId());
......@@ -24,7 +35,7 @@ bool RD53Interface::ConfigureChip(Chip* pChip, bool pVerifLoop, uint32_t pBlockS
// ###################################
// # Initializing chip communication #
// ###################################
RD53Interface::InitRD53Aurora(pChip);
RD53Interface::InitRD53Aurora(static_cast<RD53*>(pChip));
// ################################################
// # Programming global registers from white list #
......@@ -90,7 +101,7 @@ bool RD53Interface::ConfigureChip(Chip* pChip, bool pVerifLoop, uint32_t pBlockS
return true;
}
void RD53Interface::InitRD53Aurora(Chip* pChip, int nActiveLanes)
void RD53Interface::InitRD53Aurora(ReadoutChip* pChip, int nActiveLanes)
{
this->setBoard(pChip->getBeBoardId());
......@@ -143,7 +154,7 @@ bool RD53Interface::WriteChipReg(Chip* pChip, const std::string& pRegNode, const
{
this->setBoard(pChip->getBeBoardId());
RD53Interface::sendCommand(pChip, RD53Cmd::WrReg(pChip->getId(), pChip->getRegItem(pRegNode).fAddress, data));
RD53Interface::sendCommand(static_cast<RD53*>(pChip), RD53Cmd::WrReg(pChip->getId(), pChip->getRegItem(pRegNode).fAddress, data));
if((pRegNode == "VCAL_HIGH") || (pRegNode == "VCAL_MED")) usleep(VCALSLEEP); // @TMP@
if(pVerifLoop == true)
......@@ -153,7 +164,7 @@ bool RD53Interface::WriteChipReg(Chip* pChip, const std::string& pRegNode, const
auto pixMode = RD53Interface::ReadChipReg(pChip, "PIX_MODE");
if(pixMode == 0)
{
auto regReadback = RD53Interface::ReadRD53Reg(pChip, pRegNode);
auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), pRegNode);
auto row = RD53Interface::ReadChipReg(pChip, "REGION_ROW");
if(regReadback.size() == 0 /* @TMP@ */ || regReadback[0].first != row || regReadback[0].second != data)
{
......@@ -174,19 +185,15 @@ void RD53Interface::WriteBoardBroadcastChipReg(const BeBoard* pBoard, const std:
{
this->setBoard(pBoard->getId());
uint16_t address = static_cast<RD53*>(pBoard->at(0)->at(0)->at(0))->getRegItem(pRegNode).fAddress;
const uint16_t address = static_cast<RD53*>(pBoard->at(0)->at(0)->at(0))->getRegItem(pRegNode).fAddress;
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(RD53Cmd::WrReg(RD53Constants::BROADCAST_CHIPID, address, data).getFrames(), -1);
}
uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& pRegNode) // @TMP@
uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& pRegNode)
{
this->setBoard(pChip->getBeBoardId());
// auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), pRegNode);
// return regReadback[0].second;
const int nAttempts = 2;
for(auto attempt = 0; attempt < nAttempts; attempt++)
{
auto regReadback = RD53Interface::ReadRD53Reg(static_cast<RD53*>(pChip), pRegNode);
......@@ -200,10 +207,11 @@ uint16_t RD53Interface::ReadChipReg(Chip* pChip, const std::string& pRegNode) //
}
LOG(ERROR) << BOLDRED << "Empty register readback FIFO in " << BOLDYELLOW << nAttempts << BOLDRED " attempts" << RESET;
return 0;
}
std::vector<std::pair<uint16_t, uint16_t>> RD53Interface::ReadRD53Reg(Chip* pChip, const std::string& pRegNode)
std::vector<std::pair<uint16_t, uint16_t>> RD53Interface::ReadRD53Reg(ReadoutChip* pChip, const std::string& pRegNode)
{
this->setBoard(pChip->getBeBoardId());
......@@ -222,7 +230,7 @@ uint16_t getPixelConfig(const std::vector<perColumnPixelData>& mask, uint16_t ro
// ##############################################################################################################
// # Encodes the configuration for a pixel pair #
// # In the LIN FE TDAC is unsigned and increasing it reduces the local threshold #
// # In the DIFF FE TDAC is signed and increasing it reduces the local threshold #
// # In the DIFF FE TDAC is signed and increasing it increases the local threshold #
// # To prevent having to deal with that in the rest of the code, we map the TDAC range of the DIFF FE like so: #
// # -15 -> 30, -14 -> 29, ... 0 -> 15, ... 15 -> 0 #
// # So for the rest of the code the TDAC range of the DIFF FE is [0, 30] and #
......@@ -247,13 +255,12 @@ void RD53Interface::WriteRD53Mask(RD53* pRD53, bool doSparse, bool doDefault, bo
std::vector<uint16_t> commandList;
const uint16_t REGION_COL_ADDR = pRD53->getRegItem("REGION_COL").fAddress;
const uint16_t REGION_ROW_ADDR = pRD53->getRegItem("REGION_ROW").fAddress;
const uint16_t PIX_PORTAL_ADDR = pRD53->getRegItem("PIX_PORTAL").fAddress;
const uint8_t highGain = pRD53->getRegItem("HighGain_LIN").fValue;
const uint8_t chipID = pRD53->getId();
std::vector<perColumnPixelData>& mask = doDefault ? *pRD53->getPixelsMaskDefault() : *pRD53->getPixelsMask();
const uint16_t REGION_COL_ADDR = pRD53->getRegItem("REGION_COL").fAddress;
const uint16_t REGION_ROW_ADDR = pRD53->getRegItem("REGION_ROW").fAddress;
const uint16_t PIX_PORTAL_ADDR = pRD53->getRegItem("PIX_PORTAL").fAddress;
const uint8_t highGain = pRD53->getRegItem("HighGain_LIN").fValue;
const uint8_t chipID = pRD53->getId();
std::vector<perColumnPixelData>& mask = doDefault ? *pRD53->getPixelsMaskDefault() : *pRD53->getPixelsMask();
// ##########################
// # Disable default config #
......@@ -298,7 +305,7 @@ void RD53Interface::WriteRD53Mask(RD53* pRD53, bool doSparse, bool doDefault, bo
if(commandList.size() > RD53Constants::FIELDS_SHORTCMD * NPIXCMD)
{
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId()); // @TMP@
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId());
commandList.clear();
}
}
......@@ -327,14 +334,14 @@ void RD53Interface::WriteRD53Mask(RD53* pRD53, bool doSparse, bool doDefault, bo
if((commandList.size() > RD53Constants::FIELDS_LONGCMD * NPIXCMD) || (row == (RD53::nRows - 1)))
{
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId()); // @TMP@
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId());
commandList.clear();
}
}
}
}
if(commandList.size() != 0) static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId()); // @TMP@
if(commandList.size() != 0) static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pRD53->getHybridId());
}
bool RD53Interface::ConfigureChipOriginalMask(ReadoutChip* pChip, bool pVerifLoop, uint32_t pBlockSize)
......@@ -403,7 +410,7 @@ void RD53Interface::ReadChipAllLocalReg(ReadoutChip* pChip, const std::string& r
// # Dedicated to minitoring #
// ###########################
float RD53Interface::ReadChipMonitor(Chip* pChip, const char* observableName)
float RD53Interface::ReadChipMonitor(ReadoutChip* pChip, const char* observableName)
{
this->setBoard(pChip->getBeBoardId());
......@@ -461,7 +468,7 @@ float RD53Interface::ReadChipMonitor(Chip* pChip, const char* observableName)
return value;
}
uint32_t RD53Interface::measureADC(Chip* pChip, uint32_t data)
uint32_t RD53Interface::measureADC(ReadoutChip* pChip, uint32_t data)
{
const uint16_t GLOBAL_PULSE_ROUTE = pChip->getRegItem("GLOBAL_PULSE_ROUTE").fAddress;
const uint8_t chipID = pChip->getId();
......@@ -482,23 +489,22 @@ uint32_t RD53Interface::measureADC(Chip* pChip, uint32_t data)
RD53Cmd::WrReg(chipID, GLOBAL_PULSE_ROUTE, GlbPulseVal).appendTo(commandList); // Restore value in Global Pulse Route
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(commandList, pChip->getHybridId());
return RD53Interface::ReadChipReg(pChip, "MONITORING_DATA_ADC");
}
float RD53Interface::measureVoltageCurrent(Chip* pChip, uint32_t data, bool isCurrentNotVoltage)
float RD53Interface::measureVoltageCurrent(ReadoutChip* pChip, uint32_t data, bool isCurrentNotVoltage)
{
const float safetyMargin = 0.9;
auto ADC = RD53Interface::measureADC(pChip, data);
if(ADC > (RD53Shared::setBits(pChip->getNumberOfBits("MONITORING_DATA_ADC")) + 1.) * safetyMargin)
LOG(WARNING) << BOLDRED << "\t--> ADC measurement in saturation (ADC = " << BOLDYELLOW << ADC << BOLDRED
LOG(WARNING) << BOLDRED << "\t\t--> ADC measurement in saturation (ADC = " << BOLDYELLOW << ADC << BOLDRED
<< "): likely the R-IMUX resistor, that converts the current into a voltage, is not connected" << RESET;
return RD53Interface::convertADC2VorI(pChip, ADC, isCurrentNotVoltage);
}
float RD53Interface::measureTemperature(Chip* pChip, uint32_t data)
float RD53Interface::measureTemperature(ReadoutChip* pChip, uint32_t data)
{
// ################################################################################################
// # Temperature measurement is done by measuring twice, once with high bias, once with low bias #
......@@ -534,7 +540,7 @@ float RD53Interface::measureTemperature(Chip* pChip, uint32_t data)
return e / (idealityFactor * kb * log(R)) * (valueHigh - valueLow) - T0C;
}
float RD53Interface::convertADC2VorI(Chip* pChip, uint32_t value, bool isCurrentNotVoltage)
float RD53Interface::convertADC2VorI(ReadoutChip* pChip, uint32_t value, bool isCurrentNotVoltage)
{
// #####################################################################
// # ADCoffset = 63 [1/10mV] Offset due to ground shift #
......@@ -549,16 +555,8 @@ float RD53Interface::convertADC2VorI(Chip* pChip, uint32_t value, bool isCurrent
return voltage / (isCurrentNotVoltage == true ? resistorI2V : 1);
}
float RD53Interface::ReadHybridTemperature(Chip* pChip)
{
auto hybridId = static_cast<RD53*>(pChip)->getHybridId(); // @TMP@
return static_cast<RD53FWInterface*>(fBoardFW)->ReadHybridTemperature(hybridId);
}
float RD53Interface::ReadHybridTemperature(ReadoutChip* pChip) { return static_cast<RD53FWInterface*>(fBoardFW)->ReadHybridTemperature(pChip->getHybridId()); }
float RD53Interface::ReadHybridVoltage(Chip* pChip)
{
auto hybridId = static_cast<RD53*>(pChip)->getHybridId(); // @TMP@
return static_cast<RD53FWInterface*>(fBoardFW)->ReadHybridVoltage(hybridId);
}
float RD53Interface::ReadHybridVoltage(ReadoutChip* pChip) { return static_cast<RD53FWInterface*>(fBoardFW)->ReadHybridVoltage(pChip->getHybridId()); }
} // namespace Ph2_HwInterface
......@@ -18,8 +18,8 @@
// # CONSTANTS #
// #############
#define VCALSLEEP 50000 // [microseconds]
#define NPIXCMD 100 // Number of possible pixel commands to stack
#define MONITORSLEEP 10 // [seconds]
#define NPIXCMD 100 // Number of possible pixel commands to stack
namespace Ph2_HwInterface
{
......@@ -28,6 +28,7 @@ class RD53Interface : public ReadoutChipInterface
public:
RD53Interface(const BeBoardFWMap& pBoardMap);
int CheckChipID(Ph2_HwDescription::Chip* pChip, int chipIDfromDB);
bool ConfigureChip(Ph2_HwDescription::Chip* pChip, bool pVerifLoop = true, uint32_t pBlockSize = 310) override;
bool WriteChipReg(Ph2_HwDescription::Chip* pChip, const std::string& pRegNode, uint16_t data, bool pVerifLoop = true) override;
void WriteBoardBroadcastChipReg(const Ph2_HwDescription::BeBoard* pBoard, const std::string& pRegNode, uint16_t data) override;
......@@ -39,12 +40,12 @@ class RD53Interface : public ReadoutChipInterface
bool maskChannelsAndSetInjectionSchema(Ph2_HwDescription::ReadoutChip* pChip, const ChannelGroupBase* group, bool mask, bool inject, bool pVerifLoop = false) override;
private:
std::vector<std::pair<uint16_t, uint16_t>> ReadRD53Reg(Ph2_HwDescription::Chip* pChip, const std::string& pRegNode);
std::vector<std::pair<uint16_t, uint16_t>> ReadRD53Reg(Ph2_HwDescription::ReadoutChip* pChip, const std::string& pRegNode);
void WriteRD53Mask(Ph2_HwDescription::RD53* pRD53, bool doSparse, bool doDefault, bool pVerifLoop = false);
void InitRD53Aurora(Ph2_HwDescription::Chip* pChip, int nActiveLanes = 1);
void InitRD53Aurora(Ph2_HwDescription::ReadoutChip* pChip, int nActiveLanes = 1);
template <typename T>
void sendCommand(Ph2_HwDescription::Chip* pChip, const T& cmd)
void sendCommand(Ph2_HwDescription::ReadoutChip* pChip, const T& cmd)
{
static_cast<RD53FWInterface*>(fBoardFW)->WriteChipCommand(cmd.getFrames(), pChip->getHybridId());
}
......@@ -60,21 +61,21 @@ class RD53Interface : public ReadoutChipInterface
// ###########################
public:
template <typename T, typename... Ts>
void ReadChipMonitor(Ph2_HwDescription::Chip* pChip, const T& observableName, const Ts&... observableNames)
void ReadChipMonitor(Ph2_HwDescription::ReadoutChip* pChip, const T& observableName, const Ts&... observableNames)
{
ReadChipMonitor(pChip, observableName);
ReadChipMonitor(pChip, observableNames...);
}
float ReadChipMonitor(Ph2_HwDescription::Chip* pChip, const char* observableName);
float ReadHybridTemperature(Ph2_HwDescription::Chip* pChip);
float ReadHybridVoltage(Ph2_HwDescription::Chip* pChip);
float ReadChipMonitor(Ph2_HwDescription::ReadoutChip* pChip, const char* observableName);
float ReadHybridTemperature(Ph2_HwDescription::ReadoutChip* pChip);
float ReadHybridVoltage(Ph2_HwDescription::ReadoutChip* pChip);
private:
uint32_t measureADC(Ph2_HwDescription::Chip* pChip, uint32_t data);
float measureVoltageCurrent(Ph2_HwDescription::Chip* pChip, uint32_t data, bool isCurrentNotVoltage);
float measureTemperature(Ph2_HwDescription::Chip* pChip, uint32_t data);
float convertADC2VorI(Ph2_HwDescription::Chip* pChip, uint32_t value, bool isCurrentNotVoltage = false);
uint32_t measureADC(Ph2_HwDescription::ReadoutChip* pChip, uint32_t data);
float measureVoltageCurrent(Ph2_HwDescription::ReadoutChip* pChip, uint32_t data, bool isCurrentNotVoltage);
float measureTemperature(Ph2_HwDescription::ReadoutChip* pChip, uint32_t data);
float convertADC2VorI(Ph2_HwDescription::ReadoutChip* pChip, uint32_t value, bool isCurrentNotVoltage = false);
};
} // namespace Ph2_HwInterface
......
......@@ -125,19 +125,19 @@ class ReadoutChipInterface : public ChipInterface
/*!
* \brief Monitorign memeber functions
*/
virtual float ReadHybridTemperature(Ph2_HwDescription::Chip* pChip)
virtual float ReadHybridTemperature(Ph2_HwDescription::ReadoutChip* pChip)
{
LOG(ERROR) << BOLDRED << __PRETTY_FUNCTION__ << "\tError: implementation of virtual member function is absent" << RESET;
return 0;
}
virtual float ReadHybridVoltage(Ph2_HwDescription::Chip* pChip)
virtual float ReadHybridVoltage(Ph2_HwDescription::ReadoutChip* pChip)
{
LOG(ERROR) << BOLDRED << __PRETTY_FUNCTION__ << "\tError: implementation of virtual member function is absent" << RESET;
return 0;
}
virtual float ReadChipMonitor(Ph2_HwDescription::Chip* pChip, const char* observableName)
virtual float ReadChipMonitor(Ph2_HwDescription::ReadoutChip* pChip, const char* observableName)
{
LOG(ERROR) << BOLDRED << __PRETTY_FUNCTION__ << "\tError: implementation of virtual member function is absent" << RESET;
return 0;
......
......@@ -26,11 +26,11 @@ More informations can be found at https://indico.cern.ch/event/842824/attachment
## Middleware for the Inner-Tracker (IT) system
```diff
+ Last change made to this section: 19/09/2020
+ Last change made to this section: 09/10/2020
```
**Suggested software and firmware versions:**
- Software git branch / tag : `master` / `IT-v3.9.4`
- Software git branch / tag : `master` / `IT-v3.9.7`
- Firmware tag: `3.4`
- Mattermost forum: `cms-it-daq` (https://mattermost.web.cern.ch/cms-it-daq/)
......
......@@ -529,8 +529,8 @@ void FileParser::parseHybridContainer(pugi::xml_node pHybridNode, OpticalGroup*
Hybrid* cHybrid;
if(pBoard->getBoardType() == BoardType::RD53)
{
cHybrid = pOpticalGroup->addHybridContainer(pHybridNode.attribute("Id").as_int(),
new Hybrid(pOpticalGroup->getBeBoardId(), pOpticalGroup->getFMCId(), pHybridNode.attribute("Id").as_int(), pHybridNode.attribute("Id").as_int()));
cHybrid = pOpticalGroup->addHybridContainer(
pHybridNode.attribute("Id").as_int(), new Hybrid(pOpticalGroup->getBeBoardId(), pOpticalGroup->getFMCId(), pHybridNode.attribute("Id").as_int(), pHybridNode.attribute("Id").as_int()));
}
else
{
......
......@@ -318,6 +318,7 @@ void SystemController::ConfigureHw(bool bIgnoreI2c)
LOG(INFO) << GREEN << "Configuring RD53: " << RESET << BOLDYELLOW << +cRD53->getId() << RESET;
static_cast<RD53Interface*>(fReadoutChipInterface)->ConfigureChip(static_cast<RD53*>(cRD53));
LOG(INFO) << GREEN << "Number of masked pixels: " << RESET << BOLDYELLOW << static_cast<RD53*>(cRD53)->getNbMaskedPixels() << RESET;
// @TMP@ static_cast<RD53Interface*>(fReadoutChipInterface)->CheckChipID(static_cast<RD53*>(cRD53), 0);
}
}
}
......
......@@ -163,7 +163,7 @@ class SystemController
for(const auto cChip: *cHybrid)
{
LOG(INFO) << GREEN << "Monitor data for [board/opticalGroup/hybrid/chip = " << BOLDYELLOW << pBoard->getId() << "/" << cOpticalGroup->getId() << "/" << cHybrid->getId() << "/"
<< cChip->getId() << RESET << GREEN << "]" << RESET;
<< +cChip->getId() << RESET << GREEN << "]" << RESET;
fBeBoardInterface->ReadChipMonitor(fReadoutChipInterface, cChip, args...);
LOG(INFO) << BOLDBLUE << "\t--> Done" << RESET;
}
......
......@@ -27,6 +27,12 @@ class RD53RunProgress
return value;
}
static void reset()
{
RD53RunProgress::total() = 0;
RD53RunProgress::current() = 0;