Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Feature/ge21 compatibility #119

2 changes: 1 addition & 1 deletion config
Submodule config updated 3 files
+29 −67 mfRPMRules.mk
+1 −1 mfZynq.mk
+10 −33 specTemplate.spec
32 changes: 16 additions & 16 deletions python/reg_interface_gem/core/gbt_utils_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def configGBT(cardName, listOfconfigFiles, ohMask = 0xfff, nOHs=12):
Configures all GBT's for OH's defined in ohMask on cardName

cardName - network alias of backend AMC
listOfconfigFiles - List of config filenames to be used for all OH's,
listOfconfigFiles - List of config filenames to be used for all OH's,
index of element should match GBTx number on OH, max length of 3
ohMask - ohMask to apply, a 1 in the n^th bit indicates the n^th OH should be considered
nOHs - Number of OH's on this AMC
"""

rpc_connect(cardName)

if len(listOfconfigFiles) > 3:
# FIXME less generic exception
raise RuntimeError("Too many GBT filenames provided, at most 3 files should be given",os.EX_USAGE)
Expand All @@ -39,7 +39,7 @@ def configGBT(cardName, listOfconfigFiles, ohMask = 0xfff, nOHs=12):

return

def gbtPhaseScan(cardName, ohMask = 0xfff, nOHs=12, nOfRepetitions=100, silent=True, outputFile=None):
def gbtPhaseScan(cardName, ohMask = 0xfff, nOHs=12, nOfRepetitions=100, silent=True, outputFile=None, nVFAT=24, nVerificationReads=10):
"""
Scan the VFAT phases for all optohybrids defined in ohMask.

Expand All @@ -49,7 +49,7 @@ def gbtPhaseScan(cardName, ohMask = 0xfff, nOHs=12, nOfRepetitions=100, silent=T
nOfRepetitions - Number of times the scan is performed.
outputFile - If provided creates a text file with this name and writes phase scan results to the file
"""

rpc_connect(cardName)

dict_phaseScanResults = {}
Expand All @@ -59,16 +59,16 @@ def gbtPhaseScan(cardName, ohMask = 0xfff, nOHs=12, nOfRepetitions=100, silent=T
continue

# Scan phases
phasesBlob = (c_uint32 * (24*16))()
scanGBTPhases(phasesBlob, ohN, nOfRepetitions, 0, 15, 1)
phasesBlob = (c_uint32 * (nVFAT*16))()
scanGBTPhases(phasesBlob, ohN, nOfRepetitions, 0, 15, 1, nVFAT, nVerificationReads)
dict_phaseScanResults[ohN] = phasesBlob

# stdout output
if not silent:
print("="*20)
print("Phase Scan Results for OH{0}".format(ohN))
print("="*20)
printGBTPhaseScanResults(phasesBlob)
printGBTPhaseScanResults(phasesBlob, nVFAT)
pass

# File output
Expand All @@ -79,22 +79,22 @@ def gbtPhaseScan(cardName, ohMask = 0xfff, nOHs=12, nOfRepetitions=100, silent=T

return dict_phaseScanResults

def printGBTPhaseScanResults(phasesBlob):
def printGBTPhaseScanResults(phasesBlob, nVFAT=24):
from tabulate import tabulate

# Create a table with the scan results
table = []
for phase in range(16):
row = []
row.append(phase)
for vfatN in range(24):
for vfatN in range(nVFAT):
row.append(phasesBlob[vfatN*16+phase])

table.append(row)

# Create header for the table
header = ["Phase"]
for vfatN in range(24):
for vfatN in range(nVFAT):
header.append("VFAT" + str(vfatN))

# Print the table
Expand All @@ -111,7 +111,7 @@ def readGBTConfigFile(filename):
else:
return content[:366]

def saveGBTPhaseScanResults(filename, ohN, phasesBlob, nOfRepetitions=100):
def saveGBTPhaseScanResults(filename, ohN, phasesBlob, nOfRepetitions=100, nVFAT=24):
import csv

# Header for the ROOT file
Expand All @@ -123,7 +123,7 @@ def saveGBTPhaseScanResults(filename, ohN, phasesBlob, nOfRepetitions=100):

# Parse the data
data = []
for vfatN in range(24):
for vfatN in range(nVFAT):
for phase in range(16):
nOfSuccesses = phasesBlob[vfatN*16+phase]
data.append([ohN, vfatN, phase, nOfRepetitions, nOfSuccesses])
Expand Down Expand Up @@ -166,13 +166,13 @@ def setPhase(cardName, ohN, vfatN, phase):
rpcRsp = writeGBTPhase(ohN, vfatN, phase)
if rpcRsp > 0:
raise RuntimeError("Failed to write phase {0} to VFAT{1} of OH{2}".format(phase,vfatN,ohN))

return

def setPhaseAllVFATs(cardName, ohN, listOfPhases, debug=False):
"""
Writes all vfat phases on the provided ohN.

cardName - network alias of backend AMC
ohN - OptoHybrid to configure.
listOfPhases - List of phases to write, list position should follow vfat position.
Expand Down Expand Up @@ -201,9 +201,9 @@ def setPhaseAllVFATs(cardName, ohN, listOfPhases, debug=False):
def setPhaseAllOHs(cardName, dictOfPhases, ohMask=0xfff, nOHs=12, debug=False):
"""
For all OH's in ohMask writes the phase for all VFATs

cardName - network alias of backend AMC
dictOfPhases - dictionary where key is OH number, each key stores a list of phases for each vfat,
dictOfPhases - dictionary where key is OH number, each key stores a list of phases for each vfat,
the index of the list should match the vfat position.
If phase is assigned as 0xdeaddead it will not be written
ohMask - ohMask to apply, a 1 in the n^th bit indicates the n^th OH should be considered
Expand Down
2 changes: 1 addition & 1 deletion python/reg_interface_gem/core/reg_extra_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

scanGBTPhases = lib.scanGBTPhases
scanGBTPhases.restype = c_uint
scanGBTPhases.argtype = [POINTER(c_uint), c_uint, c_uint, c_uint, c_uint, c_uint]
scanGBTPhases.argtype = [POINTER(c_uint), c_uint, c_uint, c_uint, c_uint, c_uint, c_uint, c_uint]

update_atdb = lib.update_atdb
update_atdb.argtypes = [c_char_p]
Expand Down
10 changes: 5 additions & 5 deletions xhalcore/include/xhal/rpc/calibration_routines.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ struct vfat3DACSize{

DLLEXPORT uint32_t checkSbitMappingWithCalPulse(uint32_t ohN, uint32_t vfatN, uint32_t mask, bool useCalPulse, bool currentPulse, uint32_t calScaleFactor, uint32_t nevts, uint32_t L1Ainterval, uint32_t pulseDelay, uint32_t *data);
DLLEXPORT uint32_t checkSbitRateWithCalPulse(uint32_t ohN, uint32_t vfatN, uint32_t mask, bool useCalPulse, bool currentPulse, uint32_t calScaleFactor, uint32_t waitTime, uint32_t pulseRate, uint32_t pulseDelay, uint32_t *outDataCTP7Rate, uint32_t *outDataFPGAClusterCntRate, uint32_t *outDataVFATSBits);
DLLEXPORT uint32_t dacScan(uint32_t ohN, uint32_t dacSelect, uint32_t dacStep, uint32_t mask, bool useExtRefADC, uint32_t * results);
DLLEXPORT uint32_t dacScanMultiLink(uint32_t ohMask, uint32_t NOH, uint32_t dacSelect, uint32_t dacStep, bool useExtRefADC, uint32_t * results);
DLLEXPORT uint32_t dacScan(uint32_t ohN, uint32_t dacSelect, uint32_t dacStep, uint32_t mask, bool useExtRefADC, uint32_t * results, uint32_t nvfats=24);
DLLEXPORT uint32_t dacScanMultiLink(uint32_t ohMask, uint32_t NOH, uint32_t dacSelect, uint32_t dacStep, bool useExtRefADC, uint32_t * results, uint32_t nvfats=24);
DLLEXPORT uint32_t genScan(uint32_t nevts, uint32_t ohN, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep,
uint32_t ch, bool useCalPulse, bool currentPulse, uint32_t calScaleFactor, uint32_t mask, char * scanReg, bool useUltra, bool useExtTrig,
uint32_t * result);
DLLEXPORT uint32_t genChannelScan(uint32_t nevts, uint32_t ohN, uint32_t mask, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep, bool useCalPulse, bool currentPulse, uint32_t calScaleFactor, bool useExtTrig, char * scanReg, bool useUltra, uint32_t * result);
uint32_t * result, uint32_t nvfats=24);
DLLEXPORT uint32_t genChannelScan(uint32_t nevts, uint32_t ohN, uint32_t mask, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep, bool useCalPulse, bool currentPulse, uint32_t calScaleFactor, bool useExtTrig, char * scanReg, bool useUltra, uint32_t * result, uint32_t nvfats=24);
DLLEXPORT uint32_t sbitRateScan(uint32_t ohMask, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep, uint32_t ch,
char * scanReg, uint32_t * resultDacVal, uint32_t * resultTrigRate, uint32_t * resultTrigRatePerVFAT);
char * scanReg, uint32_t * resultDacVal, uint32_t * resultTrigRate, uint32_t * resultTrigRatePerVFAT, uint32_t nvfats=24);
DLLEXPORT uint32_t ttcGenConf(uint32_t ohN, uint32_t mode, uint32_t type, uint32_t pulseDelay,
uint32_t L1Ainterval, uint32_t nPulses, bool enable);
DLLEXPORT uint32_t ttcGenToggle(uint32_t ohN, bool enable);
Expand Down
2 changes: 1 addition & 1 deletion xhalcore/include/xhal/rpc/daq_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ DLLEXPORT uint32_t getmonTRIGGERmain(uint32_t* result, uint32_t noh = 12, uint32
DLLEXPORT uint32_t getmonTRIGGEROHmain(uint32_t* result, uint32_t noh = 12, uint32_t ohMask = 0xff);
DLLEXPORT uint32_t getmonDAQmain(uint32_t* result);
DLLEXPORT uint32_t getmonDAQOHmain(uint32_t* result, uint32_t noh = 12, uint32_t ohMask = 0xfff);
DLLEXPORT uint32_t getmonGBTLink(struct OHLinkMonitor *ohLinkMon, uint32_t noh = 12, uint32_t ohMask = 0xfff, bool doReset = false);
DLLEXPORT uint32_t getmonGBTLink(struct OHLinkMonitor *ohLinkMon, uint32_t noh = 12, uint32_t ohMask = 0xfff, bool doReset = false, uint32_t NGBT=3);
DLLEXPORT uint32_t getmonOHLink(struct OHLinkMonitor *ohLinkMon, struct VFATLinkMonitor *vfatLinkMon, uint32_t noh = 12, uint32_t ohMask = 0xfff, bool doReset = false);
DLLEXPORT uint32_t getmonOHmain(uint32_t* result, uint32_t noh = 12, uint32_t ohMask = 0xfff);
DLLEXPORT uint32_t getmonOHSCAmain(struct SCAMonitor *scaMon, uint32_t noh = 12, uint32_t ohMask = 0xfff);
Expand Down
2 changes: 1 addition & 1 deletion xhalcore/include/xhal/rpc/gbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "xhal/rpc/utils.h"

DLLEXPORT uint32_t scanGBTPhases(uint32_t *result, uint32_t ohN, uint32_t nScans=100, uint32_t phaseMin=0, uint32_t phaseMax=15, uint32_t phaseStep=1);
DLLEXPORT uint32_t scanGBTPhases(uint32_t *result, uint32_t ohN, uint32_t nScans=100, uint32_t phaseMin=0, uint32_t phaseMax=15, uint32_t phaseStep=1, uint32_t nVFAT=24, uint32_t nVerificationReads=10);
DLLEXPORT uint32_t writeGBTConfig(uint32_t ohN, uint32_t gbtN, uint32_t configSize, uint8_t *config);
DLLEXPORT uint32_t writeGBTPhase(uint32_t ohN, uint32_t vfatN, uint8_t phase);

Expand Down
4 changes: 2 additions & 2 deletions xhalcore/include/xhal/rpc/optohybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "xhal/rpc/utils.h"

DLLEXPORT uint32_t broadcastRead(uint32_t ohN, char * regName, uint32_t vfatMask, uint32_t * result);
DLLEXPORT uint32_t broadcastRead(uint32_t ohN, char * regName, uint32_t vfatMask, uint32_t * result, uint32_t size=24);
DLLEXPORT uint32_t broadcastWrite(uint32_t ohN, char * regName, uint32_t value, uint32_t vfatMask);
DLLEXPORT uint32_t configureScanModule(uint32_t ohN, uint32_t vfatN, uint32_t scanmode, bool useUltra,
uint32_t vfatMask, uint32_t ch, uint32_t nevts, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep);
DLLEXPORT uint32_t printScanConfiguration(uint32_t ohN, bool useUltra);
DLLEXPORT uint32_t startScanModule(uint32_t ohN, bool useUltra);
DLLEXPORT uint32_t getUltraScanResults(uint32_t ohN, uint32_t nevts, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep, uint32_t * result);
DLLEXPORT uint32_t getUltraScanResults(uint32_t ohN, uint32_t nevts, uint32_t dacMin, uint32_t dacMax, uint32_t dacStep, uint32_t * result, uint32_t nvfats=24);
DLLEXPORT uint32_t stopCalPulse2AllChannels(uint32_t ohN, uint32_t mask, uint32_t ch_min, uint32_t ch_max);

#endif
30 changes: 17 additions & 13 deletions xhalcore/include/xhal/rpc/vfat3.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,43 @@ DLLEXPORT uint32_t configureVFAT3DacMonitor(uint32_t ohN, uint32_t vfatMask, uin
*/
DLLEXPORT uint32_t configureVFAT3DacMonitorMultiLink(uint32_t ohMask, uint32_t *ohVfatMaskArray, uint32_t dacSelect);

/*! \fn DLLEXPORT uint32_t getChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData);
/*! \fn DLLEXPORT uint32_t getChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData, uint32_t nvfats=24);
* \brief reads channel registers of all unmasked vfats on ohN
* \param ohN Optohybrid optical link number
* \param vfatMask Bitmask of chip positions determining which chips to use
* \param chanRegData array pointer for channel register data with 3072 entries, the (vfat,chan) pairing determines the array index via: idx = vfat*128 + chan
*/
DLLEXPORT uint32_t getChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData);
DLLEXPORT uint32_t getChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData, uint32_t nvfats=24);

/*! \fn DLLEXPORT uint32_t getVFAT3ChipIDs(uint32_t ohN, uint32_t vfatMask=0xFF000000, bool rawID=false)
/*! \fn DLLEXPORT uint32_t getVFAT3ChipIDs(uint32_t ohN, uint32_t vfatMask=0xFF000000, bool rawID=false, uint32_t nvfats=24)
* \param chipIDData Array of size 24 that will hold the VFAT ChipID data
* \param ohN Optohybrid optical link number
* \param vfatMask Bitmask of chip positions determining which chips to use
* \param rawID If true the rawID will be returned and reed-muller decoding will not be performed
* \param nvfats number of VFAT chips per optical link
*/
DLLEXPORT uint32_t getVFAT3ChipIDs(uint32_t * chipIDData, uint32_t ohN, uint32_t vfatMask=0xFF000000, bool rawID=false);
DLLEXPORT uint32_t getVFAT3ChipIDs(uint32_t * chipIDData, uint32_t ohN, uint32_t vfatMask=0xFF000000, bool rawID=false, uint32_t nvfats=24);

/*! \fn DLLEXPORT uint32_t readVFAT3ADC(uint32_t ohN, uint32_t *adcData, bool useExtRefADC=false, uint32_t vfatMask=0xFF000000)
/*! \fn DLLEXPORT uint32_t readVFAT3ADC(uint32_t ohN, uint32_t *adcData, bool useExtRefADC=false, uint32_t vfatMask=0xFF000000, uint32_t nvfats=24)
* \brief Reads the ADC value from all unmasked VFATs
* \param adcData pointer to the array containing the ADC results; length of array is expected to be 24
* \param ohN Optohybrid optical link number
* \param useExtRefADC true (false) read the ADC1 (ADC0) which uses an external (internal) reference
* \param vfatMask Bitmask of chip positions determining which chips to use
* \param nvfats number of VFAT chips per optical link
*/
DLLEXPORT uint32_t readVFAT3ADC(uint32_t ohN, uint32_t *adcData, bool useExtRefADC=false, uint32_t vfatMask=0xFF000000);
DLLEXPORT uint32_t readVFAT3ADC(uint32_t ohN, uint32_t *adcData, bool useExtRefADC=false, uint32_t vfatMask=0xFF000000, uint32_t nvfats=24);

/*! \fn DLLEXPORT uint32_t readVFAT3ADCMultiLink(uint32_t ohN, uint32_t *adcData, bool useExtRefADC=false, uint32_t vfatMask=0xFF000000)
* \brief As readVFAT3ADC(...) but for all optical links specified in ohMask on the AMC
/*! \fn DLLEXPORT uint32_t readVFAT3ADCMultiLink(uint32_t ohMask, uint32_t *ohVfatMaskArray, uint32_t *adcDataAll, bool useExtRefADC=false, uint32_t nvfats=24) * \brief As readVFAT3ADC(...) but for all optical links specified in ohMask on the AMC
* \param ohMask A 12 bit number which specifies which optohybrids to read from. Having a value of 1 in the n^th bit indicates that the n^th optohybrid should be considered.
* \param ohVfatMaskArray Pointer to an array of length 12. Each element is the bitmask of chip positions determining which chips to use for the optohybrid number corresponding to the element index.
* \param adcDataAll pointer to the array containing the ADC results; length of array is expected to be 12*24=288
* \param useExtRefADC true (false) read the ADC1 (ADC0) which uses an external (internal) reference
* \param nvfats number of VFAT chips per optical link
*/
DLLEXPORT uint32_t readVFAT3ADCMultiLink(uint32_t ohMask, uint32_t *ohVfatMaskArray, uint32_t *adcDataAll, bool useExtRefADC=false);
DLLEXPORT uint32_t readVFAT3ADCMultiLink(uint32_t ohMask, uint32_t *ohVfatMaskArray, uint32_t *adcDataAll, bool useExtRefADC=false, uint32_t nvfats=24);

/*! \fn DLLEXPORT uint32_t setChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *calEnable, uint32_t *masks, uint32_t *trimARM, uint32_t *trimARMPol, uint32_t *trimZCC, uint32_t *trimZCCPol)
/*! \fn DLLEXPORT uint32_t setChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *calEnable, uint32_t *masks, uint32_t *trimARM, uint32_t *trimARMPol, uint32_t *trimZCC, uint32_t *trimZCCPol, uint32_t nvfats=24)
* \brief sets all vfat3 channel registers
* \param ohN Optohybrid optical link number
* \param vfatMask Bitmask of chip positions determining which chips to use
Expand All @@ -65,15 +67,17 @@ DLLEXPORT uint32_t readVFAT3ADCMultiLink(uint32_t ohMask, uint32_t *ohVfatMaskAr
* \param trimARMPol as calEnable but for arming comparator trim polarity
* \param trimZCC as calEnable but for zero crossing comparator trim value
* \param trimZCCPol as calEnable but for zero crossing comparator trim polarity
* \param nvfats number of VFAT chips per optical link
*/
DLLEXPORT uint32_t setChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *calEnable, uint32_t *masks, uint32_t *trimARM, uint32_t *trimARMPol, uint32_t *trimZCC, uint32_t *trimZCCPol);
DLLEXPORT uint32_t setChannelRegistersVFAT3(uint32_t ohN, uint32_t vfatMask, uint32_t *calEnable, uint32_t *masks, uint32_t *trimARM, uint32_t *trimARMPol, uint32_t *trimZCC, uint32_t *trimZCCPol, uint32_t nvfats=24);

/*! \fn DLLEXPORT uint32_t setChannelRegistersVFAT3Simple(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData)
/*! \fn DLLEXPORT uint32_t setChannelRegistersVFAT3Simple(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData, uint32_t nvfats=24)
* \brief sets all vfat3 channel registers using a single channel register array
* \param ohN Optohybrid optical link number
* \param vfatMask Bitmask of chip positions determining which chips to use
* \param chanRegData array pointer for channel register data with 3072 entries, the (vfat,chan) pairing determines the array index via: idx = vfat*128 + chan
* \param nvfats number of VFAT chips per optical link
*/
DLLEXPORT uint32_t setChannelRegistersVFAT3Simple(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData);
DLLEXPORT uint32_t setChannelRegistersVFAT3Simple(uint32_t ohN, uint32_t vfatMask, uint32_t *chanRegData, uint32_t nvfats=24);

#endif
Loading