Exemple #1
0
def getClockingInfo(device, gtx, debug=False):
    """
    Get the OptoHybrid clocking information
    """
    clocking = nesteddict()

    # v2b only
    clocking["qplllock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.QPLL_LOCK" % (gtx))
    clocking["qpllfpgaplllock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.QPLL_FPGA_PLL_LOCK" % (gtx))

    #v2a only
    clocking["fpgaplllock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.FPGA_PLL_LOCK" % (gtx))
    clocking["extplllock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.EXT_PLL_LOCK" % (gtx))
    clocking["cdcelock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.CDCE_LOCK" % (gtx))
    clocking["gtxreclock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.STATUS.GTX_LOCK" % (gtx))
    clocking["refclock"] = readRegister(
        device, "GEM_AMC.OH.OH%d.CONTROL.CLOCK.REF_CLK" % (gtx))

    return clocking
def writeVFATRegisters(device, gtx, chip, regs_with_values, debug=False):
    baseNode = "GEM_AMC.OH.OH%d.GEB.VFATS.VFAT%d"%(gtx,chip)
    registers = nesteddict()
    for reg in regs_with_values.keys():
        registers["%s.%s"%(baseNode,reg)] = regs_with_values[reg]
        pass
    writeRegisterList(device,registers)
Exemple #3
0
def writeVFATRegisters(device, gtx, chip, regs_with_values, debug=False):
    baseNode = "GEM_AMC.OH.OH%d.GEB.VFATS.VFAT%d" % (gtx, chip)
    registers = nesteddict()
    for reg in regs_with_values.keys():
        registers["%s.%s" % (baseNode, reg)] = regs_with_values[reg]
        pass
    writeRegisterList(device, registers)
Exemple #4
0
def calculateLinkErrors(device, gtx, sampleTime):
    baseNode = "GEM_AMC.OH_LINKS"
    errorCounts = nesteddict()

    # writeRegister(device,"%s.CTRL.CNT_RESET"%(baseNode),0x1)
    first = readRegister(device,
                         "%s.OH%d.TRACK_LINK_ERROR_CNT" % (baseNode, gtx))
    time.sleep(sampleTime)
    second = readRegister(device,
                          "%s.OH%d.TRACK_LINK_ERROR_CNT" % (baseNode, gtx))
    errorCounts["LINK"] = [first, second]

    baseNode = "GEM_AMC.OH"
    for link in ("GBT", "GTX"):
        writeRegister(
            device,
            "%s.OH%d.COUNTERS.%s_LINK.TRK_ERR.Reset" % (baseNode, gtx, link),
            0x1)
        first = readRegister(
            device, "%s.OH%d.COUNTERS.%s_LINK.TRK_ERR" % (baseNode, gtx, link))
        time.sleep(sampleTime)
        second = readRegister(
            device, "%s.OH%d.COUNTERS.%s_LINK.TRK_ERR" % (baseNode, gtx, link))
        errorCounts[link] = [first, second]
    return errorCounts
Exemple #5
0
def printScanConfiguration(device, gtx, useUltra=False, debug=False):
    """
    """
    scanBase = "GEM_AMC.OH.OH%d.ScanController.THLAT" % (gtx)
    if useUltra:
        scanBase = "GEM_AMC.OH.OH%d.ScanController.ULTRA" % (gtx)
        pass

    print scanBase
    regList = [
        "%s.CONF.MODE" % (scanBase),
        "%s.CONF.MIN" % (scanBase),
        "%s.CONF.MAX" % (scanBase),
        "%s.CONF.CHAN" % (scanBase),
        "%s.CONF.STEP" % (scanBase),
        "%s.CONF.NTRIGS" % (scanBase),
        "%s.MONITOR" % (scanBase),
    ]
    if useUltra:
        regList.append("%s.CONF.MASK" % (scanBase))
    else:
        regList.append("%s.CONF.CHIP" % (scanBase))
        pass

    if debug:
        regParams = nesteddict()
        for reg in regList:
            regParams[reg] = {
                "Path": "%s" % (device.getNode(reg).getPath()),
                "Address": "0x%x" % (device.getNode(reg).getAddress()),
                "Mask": "0x%x" % (device.getNode(reg).getMask()),
                "Permission": "%s" % (device.getNode(reg).getPermission()),
                "Mode": "%s" % (device.getNode(reg).getMode()),
                "Size": "%s" % (device.getNode(reg).getSize())
            }
            print regParams[reg]
            pass
        pass
    regVals = readRegisterList(device, regList)
    print "FW scan mode       : %d" % (regVals["%s.CONF.MODE" % (scanBase)])
    print "FW scan min        : %d" % (regVals["%s.CONF.MIN" % (scanBase)])
    print "FW scan max        : %d" % (regVals["%s.CONF.MAX" % (scanBase)])
    if useUltra:
        print "Ultra FW scan mask : 0x%08x" % (regVals["%s.CONF.MASK" %
                                                       (scanBase)])
    else:
        print "FW scan VFAT       : %d" % (regVals["%s.CONF.CHIP" %
                                                   (scanBase)])
        pass
    print "FW scan channel    : %d" % (regVals["%s.CONF.CHAN" % (scanBase)])
    print "FW scan step size  : %d" % (regVals["%s.CONF.STEP" % (scanBase)])
    print "FW scan n_triggers : %d" % (regVals["%s.CONF.NTRIGS" % (scanBase)])
    print "FW scan status     : 0x%08x" % (readRegister(
        device, "%s.MONITOR" % (scanBase)))

    return
Exemple #6
0
def calculateLockErrors(device, gtx, register, sampleTime):
    baseNode = "GEM_AMC.OH.OH%d.COUNTERS" % (gtx)
    errorCounts = nesteddict()

    #for link in ("QPLL_LOCK","QPLL_FPGA_PLL_LOCK"):
    writeRegister(device, "%s.%s_LOCK.Reset" % (baseNode, register), 0x1)
    first = readRegister(device, "%s.%s_LOCK" % (baseNode, register))
    time.sleep(sampleTime)
    second = readRegister(device, "%s.%s_LOCK" % (baseNode, register))
    errorCounts = [first, second]
    return errorCounts
def glibCounters(device, gtx, doReset=False):
    """
    read the optical gtx counters, returning a map
    if doReset is true, just send the reset command and pass
    IPBus:Strobe,Ack
    T1:L1A,CalPulse,Resync,BC0
    GTX:
    """
    baseNode = "GLIB.COUNTERS"

    if doReset:
        for ipbcnt in ["Strobe", "Ack"]:
            writeRegister(
                device,
                "%s.IPBus.%s.OptoHybrid_%d.Reset" % (baseNode, ipbcnt, gtx),
                0x1)
            writeRegister(device,
                          "%s.IPBus.%s.TRK_%d.Reset" % (baseNode, ipbcnt, gtx),
                          0x1)
            writeRegister(device,
                          "%s.IPBus.%s.Counters.Reset" % (baseNode, ipbcnt),
                          0x1)

        #T1 counters
        for t1 in ["L1A", "CalPulse", "Resync", "BC0"]:
            writeRegister(device, "%s.T1.%s.Reset" % (baseNode, t1), 0x1)

        writeRegister(device, "%s.GTX%d.TRK_ERR.Reset" % (baseNode, gtx), 0x1)
        writeRegister(device, "%s.GTX%d.TRG_ERR.Reset" % (baseNode, gtx), 0x1)
        writeRegister(device, "%s.GTX%d.DATA_Packets.Reset" % (baseNode, gtx),
                      0x1)
        return
    else:
        counters = nesteddict()

        for ipbcnt in ["Strobe", "Ack"]:
            for ipb in ["OptoHybrid", "TRK"]:
                counters["IPBus"][ipbcnt][ipb] = readRegister(
                    device, "%s.IPBus.%s.%s_%d" % (baseNode, ipbcnt, ipb, gtx))
            counters["IPBus"][ipbcnt]["Counters"] = readRegister(
                device, "%s.IPBus.%s.Counters" % (baseNode, ipbcnt))

        #T1 counters
        for t1 in ["L1A", "CalPulse", "Resync", "BC0"]:
            counters["T1"][t1] = readRegister(device,
                                              "%s.T1.%s" % (baseNode, t1))

        counters["GTX%d" % (gtx)]["TRK_ERR"] = readRegister(
            device, "%s.GTX%d.TRK_ERR" % (baseNode, gtx))
        counters["GTX%d" % (gtx)]["TRG_ERR"] = readRegister(
            device, "%s.GTX%d.TRG_ERR" % (baseNode, gtx))
        counters["GTX%d" % (gtx)]["DATA_Packets"] = readRegister(
            device, "%s.GTX%d.DATA_Packets" % (baseNode, gtx))
        return counters
Exemple #8
0
def getFirmwareDateOld(device, gtx=0, debug=False):
    """
    Returns the OH firmware date as a map (day, month, year)
    """
    baseNode = "GEM_AMC.OH.OH%d" % (gtx)
    fwdate = readRegister(device, "%s.STATUS.FW_DATE" % (baseNode), debug)
    date = nesteddict()
    date["d"] = fwdate & 0xff
    date["m"] = (fwdate >> 8) & 0xff
    date["y"] = (fwdate >> 16) & 0xffff
    return date
def readFIFODepth(device,gtx):
    """
    read the tracking FIFO depth from given optical gtx
    """
    baseNode = "GLIB.TRK_DATA.OptoHybrid_%d"%(gtx)

    data = nesteddict()
    data["isFULL"]    = readRegister(device,"%s.ISFULL"%(baseNode))
    data["isEMPTY"]   = readRegister(device,"%s.ISEMPTY"%(baseNode))
    data["Occupancy"] = readRegister(device,"%s.DEPTH"%(baseNode))
    return data
def readFIFODepth(device, gtx):
    """
    read the tracking FIFO depth from given optical gtx
    """
    baseNode = "GLIB.TRK_DATA.OptoHybrid_%d" % (gtx)

    data = nesteddict()
    data["isFULL"] = readRegister(device, "%s.ISFULL" % (baseNode))
    data["isEMPTY"] = readRegister(device, "%s.ISEMPTY" % (baseNode))
    data["Occupancy"] = readRegister(device, "%s.DEPTH" % (baseNode))
    return data
def getErrorRate(errorCounts,sampleTime):
    """
    Calculates the error rate provided in a list of pairs of measurements, taken with delay sampleTime
    errorCounts = [pair1, pair2, ...]
    pair1 = [first, second]
    returns a pair which is the rate (averaged over the number of trials) and the modifier string (k, M, G)
    """
    rates    = nesteddict()
    modifier = nesteddict()
    rate = 0
    lastCount = 0
    for trial in errorCounts:
        tmprate = ((trial[1]-trial[0])/(1.0*sampleTime))
        rate = rate + tmprate
        lastCount = trial[1]
        
    rate = rate / len(errorCounts)
    (rate,modifier) = rateConverter(rate)
    return [lastCount,rate,modifier]
    
    return rates
Exemple #12
0
def getErrorRate(errorCounts, sampleTime):
    """
    Calculates the error rate provided in a list of pairs of measurements, taken with delay sampleTime
    errorCounts = [pair1, pair2, ...]
    pair1 = [first, second]
    returns a pair which is the rate (averaged over the number of trials) and the modifier string (k, M, G)
    """
    rates = nesteddict()
    modifier = nesteddict()
    rate = 0
    lastCount = 0
    for trial in errorCounts:
        tmprate = ((trial[1] - trial[0]) / (1.0 * sampleTime))
        rate = rate + tmprate
        lastCount = trial[1]

    rate = rate / len(errorCounts)
    (rate, modifier) = rateConverter(rate)
    return [lastCount, rate, modifier]

    return rates
Exemple #13
0
def readRegisterList(device, registers, debug=False):
    """
    read registers 'registers' from uhal device 'device'
    returns values of the registers in a dict
    """
    global gRetries
    nRetries = 0
    msg = "%s\n" % (device)
    if debug:
        for reg in registers:
            msg += "%s\n" % (reg)
            pass
        pass
    reglogger.debug(msg)

    while (nRetries < gMAX_RETRIES):
        try:
            results = nesteddict()
            for reg in registers:
                results[reg] = device.getNode(reg).read()
                pass
            msg = "%s\n" % (device)
            if (debug):
                for reg in results.keys():
                    msg += "%s: 0x%x" % (reg, results[reg])
                    pass
                pass
            reglogger.debug(msg)

            device.dispatch()
            time.sleep(0.1)

            msg = "%s\n" % (device)
            if (debug):
                for reg in results.keys():
                    msg += "%s: 0x%x" % (reg, results[reg])
                    pass
                pass
            reglogger.debug(msg)

            return results

        except uhal.exception, e:
            msg = "%s: read error encountered (%s), retrying operation (%d,%d)" % (
                device, str(e), nRetries, gRetries),
            reglogger.warning(msg)
            nRetries += 1
            gRetries += 1
            if ((nRetries % 10) == 1):
                continue
            pass
        pass
def calculateLinkErrors(isGLIB,device,gtx,sampleTime):
    baseNode = "GEM_AMC.OH_LINKS"
    errorCounts = nesteddict()
    if not isGLIB:
        baseNode = "GEM_AMC.OH_LINKS"

    for link in ("TRK","TRG"):
        writeRegister(device,"%s.CTRL.CNT_RESET"%(baseNode),0x1)
        first = readRegister(device,"%s.OH%d.TRACK_LINK_ERROR_CNT"%(baseNode,gtx))
        time.sleep(sampleTime)
        second = readRegister(device,"%s.OH%d.TRACK_LINK_ERROR_CNT"%(baseNode,gtx))
        errorCounts[link] = [first,second]
    return errorCounts
def readRegisterList(device, registers, debug=False):
    """
    read registers 'registers' from uhal device 'device'
    returns values of the registers in a dict
    """
    global gRetries
    nRetries = 0
    msg = "%s\n"%(device)
    if debug:
        for reg in registers:
            msg+= "%s\n"%(reg)
            pass
        pass
    reglogger.debug(msg)

    while (nRetries < gMAX_RETRIES):
        try:
            results = nesteddict()
            for reg in registers:
                results[reg] = device.getNode(reg).read()
                pass
            msg = "%s\n"%(device)
            if (debug):
                for reg in results.keys():
                    msg+= "%s: 0x%x"%(reg,results[reg])
                    pass
                pass
            reglogger.debug(msg)

            device.dispatch()
            time.sleep(0.1)

            msg = "%s\n"%(device)
            if (debug):
                for reg in results.keys():
                    msg+= "%s: 0x%x"%(reg,results[reg])
                    pass
                pass
            reglogger.debug(msg)

            return results

        except uhal.exception, e:
            msg ="%s: read error encountered (%s), retrying operation (%d,%d)"%(device,str(e),nRetries,gRetries),
            reglogger.warning(msg)
            nRetries += 1
            gRetries += 1
            if ((nRetries % 10) == 1):
                continue
            pass
        pass
def calculateLinkErrors(isGLIB, device, gtx, sampleTime):
    baseNode = "GEM_AMC.OH_LINKS"
    errorCounts = nesteddict()
    if not isGLIB:
        baseNode = "GEM_AMC.OH_LINKS"

    for link in ("TRK", "TRG"):
        writeRegister(device, "%s.CTRL.CNT_RESET" % (baseNode), 0x1)
        first = readRegister(device,
                             "%s.OH%d.TRACK_LINK_ERROR_CNT" % (baseNode, gtx))
        time.sleep(sampleTime)
        second = readRegister(device,
                              "%s.OH%d.TRACK_LINK_ERROR_CNT" % (baseNode, gtx))
        errorCounts[link] = [first, second]
    return errorCounts
def glibCounters(device,gtx,doReset=False):
    """
    read the optical gtx counters, returning a map
    if doReset is true, just send the reset command and pass
    IPBus:Strobe,Ack
    T1:L1A,CalPulse,Resync,BC0
    GTX:
    """
    baseNode = "GLIB.COUNTERS"

    if doReset:
        for ipbcnt in ["Strobe","Ack"]:
            writeRegister(device,"%s.IPBus.%s.OptoHybrid_%d.Reset"%(baseNode, ipbcnt, gtx),0x1)
            writeRegister(device,"%s.IPBus.%s.TRK_%d.Reset"%(       baseNode, ipbcnt, gtx),0x1)
            writeRegister(device,"%s.IPBus.%s.Counters.Reset"%(     baseNode, ipbcnt),     0x1)

        #T1 counters
        for t1 in ["L1A", "CalPulse","Resync","BC0"]:
            writeRegister(device,"%s.T1.%s.Reset"%(baseNode, t1),0x1)

        writeRegister(device,"%s.GTX%d.TRK_ERR.Reset"%(     baseNode, gtx), 0x1)
        writeRegister(device,"%s.GTX%d.TRG_ERR.Reset"%(     baseNode, gtx), 0x1)
        writeRegister(device,"%s.GTX%d.DATA_Packets.Reset"%(baseNode, gtx), 0x1)
        return
    else:
        counters = nesteddict()
        
        for ipbcnt in ["Strobe","Ack"]:
            for ipb in ["OptoHybrid","TRK"]:
                counters["IPBus"][ipbcnt][ipb] = readRegister(device,"%s.IPBus.%s.%s_%d"%(   baseNode, ipbcnt,ipb,gtx))
            counters["IPBus"][ipbcnt]["Counters"] = readRegister(device,"%s.IPBus.%s.Counters"%(baseNode, ipbcnt))


        #T1 counters
        for t1 in ["L1A", "CalPulse","Resync","BC0"]:
            counters["T1"][t1] = readRegister(device,"%s.T1.%s"%(baseNode, t1))

        counters["GTX%d"%(gtx)]["TRK_ERR"]      = readRegister(device,"%s.GTX%d.TRK_ERR"%(baseNode,gtx))
        counters["GTX%d"%(gtx)]["TRG_ERR"]      = readRegister(device,"%s.GTX%d.TRG_ERR"%(baseNode,gtx))
        counters["GTX%d"%(gtx)]["DATA_Packets"] = readRegister(device,"%s.GTX%d.DATA_Packets"%(baseNode,gtx))
        return counters
Exemple #18
0
    setRunMode(ohboard, options.gtx, chip, True)
    pass

if options.testsingle:
    print "Testing single VFAT transactions"
    for vfat in range(24):
        # if (vfat%2 == 0):
        setRunMode(ohboard, options.gtx, chip=vfat, enable=False, debug=True)
        # setRunMode(ohboard, options.gtx, chip=vfat, enable=True,debug=True)
        # else:
        #     setRunMode(ohboard, options.gtx, chip=vfat, enable=False,debug=True)
        #     pass
        pass
    pass

controlRegs = nesteddict()
for control in range(4):
    controls.append(
        readAllVFATs(ohboard, options.gtx, "ContReg%d" % (control), 0xf0000000,
                     options.debug))
    controlRegs["ctrl%d" % control] = dict(
        map(lambda chip: (chip, controls[control][chip] & 0xff), range(0, 24)))
    pass
displayChipInfo(ohboard, options.gtx, chipids)

print "%6s  %6s  %02s  %02s  %02s  %02s" % ("chip", "ID", "ctrl0", "ctrl1",
                                            "ctrl2", "ctrl3")
for chip in chipids.keys():
    if (int(chip) % 8 == 0):
        print "-------------GEB Column %d-----------------" % (int(chip) / 8)
        pass
def getMapping(mappingFileName):
    """
    Returns a nested dictionary, the outer dictionary uses VFAT position as the has a key,
    the inner most dict has keys from the list anaInfo.py mappingNames.
    
    The inner dict stores a list whose index is ordered by ASIC channel number, accessing
    the i^th element of this list gives either the readout strip number, the readout connector
    pin number, or the vfat channel number as shown in this example:

        ret_dict[vfatN]['Strip'][asic_chan] is the strip number
        ret_dict[vfatN]['PanPin'][asic_chan] is the pin number on the readout connector
        ret_dict[vfatN]['vfatCH'][asic_chan] is the vfat channel number

    mappingFile - physical filename of file which contains the mapping information, 
                  expected format:

                        vfat/I:strip/I:channel/I:PanPin/I
                        0	0	16	63
                        0	1	20	62
                        0	2	24	61
                        ...
                        ...

                  Here these column headings are:
                        vfat - the VFAT position on the detector (e.g. vfatN)
                        strip - the anode strip on the readout board in an ieta row
                        channel - the channel on the ASIC
                        PanPin - the pin number on the panasonic connector
    """
    from gempython.utils.nesteddict import nesteddict

    from anaInfo import mappingNames
    import ROOT as r

    # Try to get the mapping data
    try:
        mapFile = open(mappingFileName, 'r')
    except IOError as e:
        print "Exception:", e
        print "Failed to open: '%s'"%mappingFileName
    else:
        listMapData = mapFile.readlines()
    finally:
        mapFile.close()

    # strip trhe end of line character
    listMapData = [x.strip('\n') for x in listMapData]

    # setup the look up table
    ret_mapDict = nesteddict()
    for vfat in range(0,24):
        for name in mappingNames:
            ret_mapDict[vfat][name] = [0] * 128

    # Set the data in the loop up table
    for idx, line in enumerate(listMapData):
        if idx == 0: 
            continue # skip the header line
        mapping = line.rsplit('\t')
        ret_mapDict[int(mapping[0])]['Strip'][int(mapping[2]) - 1] = int(mapping[1])
        ret_mapDict[int(mapping[0])]['PanPin'][int(mapping[2]) -1] = int(mapping[3])
        ret_mapDict[int(mapping[0])]['vfatCH'][int(mapping[2]) - 1] = int(mapping[2]) - 1

    return ret_mapDict
Exemple #20
0
def optohybridCounters(device, gtx=0, doReset=False, debug=False):
    """
    read the optical link counters, returning a map
    if doReset is true, just send the reset command and pass
    WB:MASTER,SLAVE
    CRC:VALID,INCORRECT
    T1:GTX_TTC,GBT_TTC,INTERNAL,EXTERNAL,LOOPBACK,SENT
    GTX
    GBT
    """
    baseNode = "GEM_AMC.OH.OH%d.COUNTERS" % (gtx)

    if doReset:
        reg_list = nesteddict()
        for wbcnt in ["Strobe", "Ack"]:

            reg_list["%s.WB.MASTER.%s.GTX.Reset" % (baseNode, wbcnt)] = 0x1
            reg_list["%s.WB.MASTER.%s.GBT.Reset" % (baseNode, wbcnt)] = 0x1
            reg_list["%s.WB.MASTER.%s.ExtI2C.Reset" % (baseNode, wbcnt)] = 0x1
            reg_list["%s.WB.MASTER.%s.Scan.Reset" % (baseNode, wbcnt)] = 0x1
            reg_list["%s.WB.MASTER.%s.DAC.Reset" % (baseNode, wbcnt)] = 0x1
            # wishbone slaves
            for i2c in range(6):
                reg_list["%s.WB.SLAVE.%s.I2C%d.Reset" %
                         (baseNode, wbcnt, i2c)] = 0x1
            for slave in [
                    "ExtI2C", "Scan", "T1", "DAC", "ADC", "Clocking",
                    "Counters", "System"
            ]:
                reg_list["%s.WB.SLAVE.%s.%s.Reset" %
                         (baseNode, wbcnt, slave)] = 0x1
        #CRC counters
        for vfat in range(24):
            reg_list["%s.CRC.VALID.VFAT%d.Reset" % (baseNode, vfat)] = 0x1
            reg_list["%s.CRC.INCORRECT.VFAT%d.Reset" % (baseNode, vfat)] = 0x1

        #T1 counters
        for t1src in [
                "GTX_TTC", "GBT_TTC", "INTERNAL", "EXTERNAL", "LOOPBACK",
                "SENT"
        ]:
            for t1 in ["L1A", "CalPulse", "Resync", "BC0"]:
                reg_list["%s.T1.%s.%s.Reset" % (baseNode, t1src, t1)] = 0x1

        reg_list["%s.GTX_LINK.TRK_ERR.Reset" % (baseNode)] = 0x1
        # reg_list["%s.GTX_LINK.TRG_ERR.Reset"%(   baseNode)] = 0x1
        reg_list["%s.GTX_LINK.DATA_Packets.Reset" % (baseNode)] = 0x1
        reg_list["%s.GBT_LINK.TRK_ERR.Reset" % (baseNode)] = 0x1
        reg_list["%s.GBT_LINK.DATA_Packets.Reset" % (baseNode)] = 0x1

        writeRegisterList(device, reg_list, debug)
        return
    else:
        counters = nesteddict()

        reg_list = []
        for wbcnt in ["Strobe", "Ack"]:
            # reg_list.append("%s.WB.MASTER.%s.GTX"%(   baseNode, wbcnt))
            # reg_list.append("%s.WB.MASTER.%s.GBT"%(   baseNode, wbcnt))
            # reg_list.append("%s.WB.MASTER.%s.ExtI2C"%(baseNode, wbcnt))
            # reg_list.append("%s.WB.MASTER.%s.Scan"%(  baseNode, wbcnt))
            # reg_list.append("%s.WB.MASTER.%s.DAC"%(   baseNode, wbcnt))
            counters["WB"]["MASTER"][wbcnt]["GTX"] = readRegister(
                device, "%s.WB.MASTER.%s.GTX" % (baseNode, wbcnt))
            counters["WB"]["MASTER"][wbcnt]["GBT"] = readRegister(
                device, "%s.WB.MASTER.%s.GBT" % (baseNode, wbcnt))
            counters["WB"]["MASTER"][wbcnt]["ExtI2C"] = readRegister(
                device, "%s.WB.MASTER.%s.ExtI2C" % (baseNode, wbcnt))
            counters["WB"]["MASTER"][wbcnt]["Scan"] = readRegister(
                device, "%s.WB.MASTER.%s.Scan" % (baseNode, wbcnt))
            counters["WB"]["MASTER"][wbcnt]["DAC"] = readRegister(
                device, "%s.WB.MASTER.%s.DAC" % (baseNode, wbcnt))

            # wishbone slaves
            for i2c in range(6):
                # reg_list.append("%s.WB.SLAVE.%s.I2C%d"%(baseNode, wbcnt, i2c))
                counters["WB"]["MASTER"][wbcnt]["I2C%d" % i2c] = readRegister(
                    device, "%s.WB.SLAVE.%s.I2C%d" % (baseNode, wbcnt, i2c))
            for slave in [
                    "ExtI2C", "Scan", "T1", "DAC", "ADC", "Clocking",
                    "Counters", "System"
            ]:
                # reg_list.append("%s.WB.SLAVE.%s.%s"%(baseNode, wbcnt, slave))
                counters["WB"]["MASTER"][wbcnt][slave] = readRegister(
                    device, "%s.WB.SLAVE.%s.%s" % (baseNode, wbcnt, slave))

        #CRC counters
        for vfat in range(24):
            # reg_list.append("%s.CRC.VALID.VFAT%d"%(    baseNode, vfat))
            # reg_list.append("%s.CRC.INCORRECT.VFAT%d"%(baseNode, vfat))
            counters["CRC"]["VALID"]["VFAT%d" % vfat] = readRegister(
                device, "%s.CRC.VALID.VFAT%d" % (baseNode, vfat))
            counters["CRC"]["INCORRECT"]["VFAT%d" % vfat] = readRegister(
                device, "%s.CRC.INCORRECT.VFAT%d" % (baseNode, vfat))

        #T1 counters
        for t1src in [
                "GTX_TTC", "GBT_TTC", "INTERNAL", "EXTERNAL", "LOOPBACK",
                "SENT"
        ]:
            for t1 in ["L1A", "CalPulse", "Resync", "BC0"]:
                # reg_list.append("%s.T1.%s.%s"%(baseNode, t1src, t1))
                counters["T1"][t1src][t1] = readRegister(
                    device, "%s.T1.%s.%s" % (baseNode, t1src, t1))

        # reg_list.append("%s.GTX.TRK_ERR"%(baseNode))
        # reg_list.append("%s.GTX.TRG_ERR"%(baseNode))
        # reg_list.append("%s.GTX.DATA_Packets"%(baseNode))
        counters["GTX"]["TRK_ERR"] = readRegister(
            device, "%s.GTX_LINK.TRK_ERR" % (baseNode))
        counters["GTX"]["DATA_Packets"] = readRegister(
            device, "%s.GTX_LINK.DATA_Packets" % (baseNode))
        counters["GBT"]["TRK_ERR"] = readRegister(
            device, "%s.GBT_LINK.TRK_ERR" % (baseNode))
        counters["GBT"]["DATA_Packets"] = readRegister(
            device, "%s.GBT_LINK.DATA_Packets" % (baseNode))

        # reg_vals = readRegisterList(device,reg_list,debug)

        return counters
    setRunMode(ohboard, options.gtx, chip, True)
    pass

if options.testsingle:
    print "Testing single VFAT transactions"
    for vfat in range(24):
        # if (vfat%2 == 0):
        setRunMode(ohboard, options.gtx, chip=vfat, enable=False,debug=True)
        # setRunMode(ohboard, options.gtx, chip=vfat, enable=True,debug=True)
        # else:
        #     setRunMode(ohboard, options.gtx, chip=vfat, enable=False,debug=True)
        #     pass
        pass
    pass

controlRegs = nesteddict()
for control in range(4):
    controls.append(readAllVFATs(ohboard, options.gtx, "ContReg%d"%(control), 0xf0000000, options.debug))
    controlRegs["ctrl%d"%control] = dict(map(lambda chip: (chip, controls[control][chip]&0xff), range(0,24)))
    pass
displayChipInfo(ohboard, options.gtx, chipids)

print "%6s  %6s  %02s  %02s  %02s  %02s"%("chip", "ID", "ctrl0", "ctrl1", "ctrl2", "ctrl3")
for chip in chipids.keys():
    if (int(chip)%8==0):
        print "-------------GEB Column %d-----------------"%(int(chip)/8)
        pass
    print "%s%6s%s  %s0x%04x%s   0x%02x   0x%02x   0x%02x   0x%02x"%(colors.GREEN,chip,colors.ENDC,
                                                                     colors.CYAN,chipids[chip],colors.ENDC,
                                                                     controlRegs["ctrl0"][chip],
                                                                     controlRegs["ctrl1"][chip],