def run(board, tx=None, rx=None, out=None): # Local references ctrl = board.getCtrl() ttc = board.getTTC() buf = board.getBuffer() cm = board.channelMgr() txCm = hlp.channelMgr(board,tx) rxCm = hlp.channelMgr(board,rx) logging.info('Capturing data stream') # Capture the buffers ttc.forceBTest() if isinstance(board,mp7.MP7Controller) and board.kind() == mp7.kMP7Sim: logging.debug('Sleep 10 secs because simulation is slow') time.sleep(10) # And check it's done cm.waitCaptureDone() logging.info('Capture completed') rxData = rxCm.readBuffers(mp7.RxTxSelector.kRx) txData = txCm.readBuffers(mp7.RxTxSelector.kTx) # Dump if out: os.system('mkdir -p '+out) mp7.BoardDataFactory.saveToFile(rxData, os.path.join(out, 'rx_summary.txt')) mp7.BoardDataFactory.saveToFile(txData, os.path.join(out, 'tx_summary.txt')) return rxData, txData
def run(board, tx=None, rx=None, out='data'): # Local references ctrl = board.getCtrl() txCm = hlp.channelMgr(board,tx) rxCm = hlp.channelMgr(board,rx) rxData = rxCm.readBuffers(mp7.RxTxSelector.kRx) txData = txCm.readBuffers(mp7.RxTxSelector.kTx) os.system('mkdir -p '+out) mp7.BoardDataFactory.saveToFile(rxData, os.path.join(out, 'rx_summary.txt')) mp7.BoardDataFactory.saveToFile(txData, os.path.join(out, 'tx_summary.txt')) return rxData, txData
def run(board, enablechans=None, tdr_fmt=None, dmx_hdrfmt=None, dmx_valfmt=None, s1_bc0fmt=None): ''' Configures the MP7 formatter. Arguments: * board - The MP7Controller FunctorInterface for that board * tdr_fmt - TDR header formatter options. Valid values: None , or map with keys 'strip' and 'insert', each value True or False * dmx_hdrfmt - Demux header formatter options. Valid values: same as tdr_fmt * dmx_valfmt - Demux datavalid-override formatter options. Valid values: None, 'disable', or map with keys 'start' and 'stop', each value a 2-tuple of ints (i.e. (bx, clock_cycle)) * s1_bc0fmt - Stage-1 formatter options. Valid values: None, 'disable', or int (the bx number) ''' logging.notice("Configuring formatters") cm = hlp.channelMgr(board,enablechans) fmt = board.getFormatter() ctrl = board.getCtrl() datapath = board.getDatapath() if ( not any([tdr_fmt, dmx_hdrfmt, dmx_valfmt, s1_bc0fmt]) ): logging.warn('Nothing to do') return if tdr_fmt is not None: cm.configureHdrFormatters(mp7.FormatterKind.kTDRFormatter, tdr_fmt['strip'], tdr_fmt['insert']) if dmx_hdrfmt is not None : cm.configureHdrFormatters(mp7.FormatterKind.kDemuxFormatter, dmx_hdrfmt['strip'], dmx_hdrfmt['insert']) if dmx_valfmt is not None: # print mp7.orbit.Point(*dmx_valfmt['start']),mp7.orbit.Point(*dmx_valfmt['stop']) if dmx_valfmt == 'disable': cm.disableDVFormatters() else: cm.configureDVFormatters(mp7.orbit.Point(*dmx_valfmt['start']),mp7.orbit.Point(*dmx_valfmt['stop']))
def run( board, enablechans=None, orbittag=False, polarity='std' ): #, alignTo=None, alignMargin=3): #, config=True, align=True, check=True, forcepattern=None, threeg=False, dmx_delays=False): cm = hlp.channelMgr(board, enablechans) cm.configureRxMGTs(orbittag, polarity == 'std')
def run(board, enablechans=None, alignTo=None, alignMargin=3, alignFreeze=False, dmx_delays=False): cm = hlp.channelMgr(board, enablechans) logging.notice('Aligning links') delays = None if dmx_delays: #delays = {} #nMaxMps = 12 #clockRatio = 6 #nMpOutputs = 6 #for mp in xrange(nMaxMps): # for c in xrange(nMpOutputs): # delays[c*nMaxMps+mp] = mp*clockRatio delays = {} nMaxMps = 6 nMaxMps_2 = 12 clockRatio = 6 nMpOutputs = 6 nMpOutputs_2 = 12 for mp in xrange(nMaxMps - 1): for c in xrange(nMpOutputs): delays[c * nMaxMps + mp] = mp * clockRatio for mp in xrange(nMaxMps, nMaxMps_2): for c in xrange(nMpOutputs, nMpOutputs_2): delays[c * nMaxMps + mp - 6] = mp * clockRatio - 6 if alignTo: p = mp7.orbit.Point(alignTo[0], alignTo[1]) args = (p, ) if delays == None else (p, delays) cm.align(*args) else: args = (alignMargin, ) if delays == None else (delays, alignMargin) cm.minimizeAndAlign(*args) if alignFreeze: cm.freezeAlignment()
def run(board, enablechans): board.checkTTC() logging.info('Measuring clocks') cm = hlp.channelMgr(board, enablechans) clkInfoMap = cm.refClkReport() for i in cm.pickMGTIDs().channels(): id = "[{0:02d}]".format(i) logging.info('-> Channel '+id) logging.info(' RefClk = %s', clkInfoMap['RefClk'+id]) logging.info(' RxClk = %s', clkInfoMap['RxClk'+id]) logging.info(' TxClk = %s', clkInfoMap['TxClk'+id])
def run(board, group, bankId, depth, enablechans=None): idmap = { 'rx': mp7.RxTxSelector.kRx, 'tx': mp7.RxTxSelector.kTx, } bkind = idmap[group] cm = hlp.channelMgr(board,enablechans) pc = mp7.LatencyPathConfigurator(bankId, depth) logging.info('Configuring buffers in latency mode: bank id = %d, latency = %d', bankId, depth ) cm.configureBuffers(bkind, pc)
def run(board, enablechans=None, polarity='std', loopback=False, pattern=None): cm = hlp.channelMgr(board,enablechans) cm.configureTxMGTs(loopback, polarity=='std') if pattern == 'std': cm.setupTx2RxPattern() elif pattern == '3g': cm.setupTx2Rx3GPattern() elif pattern =='orbittag': cm.setupTx2RxOrbitPattern() elif pattern == 'none': logging.debug('Loopback pattern generation disabled')
def run(board, enablechans=None): cm = hlp.channelMgr(board, enablechans) aligns = cm.readAlignmentStatus() for ch in sorted(aligns): status = aligns[ch] log = logging.info if (status.marker and status.errors == 0) else logging.error logging.info('id %02d: marker %s, pos %s, frozen %s, errors %d' % (ch, 'OK' if (status.marker == True) else 'Missing', status.position, 'Yes' if (status.frozen == True) else 'No', status.errors))
def run(board, sel, mode, enablechans=None, data_uri=None, bx_range=(mp7.orbit.Point(0),None)): depth = board.getBuffer().getBufferSize() idmap = { 'rx': mp7.RxTxSelector.kRx, 'tx': mp7.RxTxSelector.kTx, } m = board.getMetric() # Prepare the data to be loaded into the RAMs if data_uri is not None: data = mp7.BoardDataFactory.generate(data_uri, depth, True) else: data = None bkind = idmap[sel] bmode = mp7.PathConfigurator.Mode.names['k'+mode] # Build the bx range start_p, stop_p = bx_range logging.info('Configuring with bx range %s', bx_range) if not (stop_p is None or isinstance(stop_p,mp7.orbit.Point)): raise ArgumentError('Stop point is not an instance of mp7.orbit.Point') if stop_p is None: pc = mp7.TestPathConfigurator(bmode, start_p, m) else: pc = mp7.TestPathConfigurator(bmode, start_p, stop_p, m) cm = hlp.channelMgr(board,enablechans) logging.info('Configuring %s buffers %s in %s mode', sel, cm.getDescriptor().pickAllIDs().channels(), mode) cm.configureBuffers(bkind, pc) if data: logging.info('Loading data from %s ', data_uri) # if a pattern is supposed to be loaded, clear first cm.clearBuffers(bkind) cm.loadPatterns(bkind, data) else: # otherwise clear only buffers configured in capture mode cm.clearBuffers(bkind, mp7.ChanBufferNode.kCapture)
def configure(self, controller): '''Applies the requested configuration to the buffers Args: ''' m = controller.getMetric() cm = hlp.channelMgr(controller, self._enable) # Search for the requested config self._log.debug('%s play: %s cap: %s', self._mode, self._playRng, self._capRng) # Find what mode rx and tx buffers must be configured with rxMode, txMode = self.getRxTxModes() rxConfig = self._makeCfgtr(controller, rxMode) # And apply it cm.configureBuffers(mp7.kRx, rxConfig) txConfig = self._makeCfgtr(controller, txMode) # And apply it cm.configureBuffers(mp7.kTx, txConfig)
def run(board, enablechans=None, repeat=1, wait=5, clear=False): cm = hlp.channelMgr(board,enablechans) errcntr = 0 errtime = [] for i in xrange(repeat): if i is not 0: time.sleep(wait) try: logging.info('==> Running check %d',i) cm.checkMGTs() except mp7.exception as e: errcntr += 1 errtime.append(datetime.now()) logging.error(e) if clear: board.channelMgr().clearLinkCounters() elog = logging.info if errcntr==0 else logging.error elog('Summary: %d checks failed',errcntr) for i,t in enumerate(errtime): elog( ' -> Fail #%i timestamp: %s', i, str(t) )
def run(board, mode, chset, src, add, inject=None): cm = hlp.channelMgr(board) # Set Stage1 Board ID ctrl = board.getCtrl() ctrl.getNode('board_id').write(0x2300) ctrl.getClient().dispatch() logging.debug('Applying default buffer config') rxlatency = mp7.LatencyPathConfigurator(0, 1) cm.configureBuffers(mp7.kRx, rxlatency) txlatency = mp7.LatencyPathConfigurator(0, 1) cm.configureBuffers(mp7.kTx, txlatency) # Stage 1 fibre mapping # Even channels, if chset == 'test': lInsEven = [0] lInsOdd = [1] lOuts = [38] elif chset == 'testsim': lInsEven = [0] #[ 2*i for i in xrange(18) ] # captures right away lInsOdd = [1] #[ 2*i+1 for i in xrange(18) ] # captured after 1 bx lOuts = [4] #range(38,54) # outputs right away elif chset == 'testsimB': lInsEven = [4] #[ 2*i for i in xrange(18) ] # captures right away lInsOdd = [5] #[ 2*i+1 for i in xrange(18) ] # captured after 1 bx lOuts = [8] #range(38,54) # outputs right away elif chset == 'full': lInsEven = range( 0, 36, 2) # [ 2*i for i in xrange(18) ] # captures right away lInsOdd = range(1, 36, 2) #[ 2*i+1 for i in xrange(18) ] # captured twice lOuts = range(38, 54) # outputs right away elif chset == 'debug': lInsEven = range(0, 36) lInsOdd = [] lOuts = [] else: raise ArgumentError('chset can either be test or full') # latPropagationCyc = 32 # tx->mgt->rx latTx2Rx = 39 # for rx->algo->tx latRx2Tx = 4 # inBaseLatency = latPropagationCyc-latRx2Tx # outBaseLatency = latPropagationCyc-latRx2Tx lIns = lInsEven + lInsOdd # mode = 'algo' if mode == 'algo': # Data sources inSrc = mp7.kRx outSrc = mp7.kRx # Data destination inDest = mp7.kTx outDest = mp7.kTx inBaseLatency = latPropagationCyc - latRx2Tx outBaseLatency = latPropagationCyc - latRx2Tx elif mode == 'loop': # Data sources inSrc = mp7.kTx outSrc = mp7.kRx # Data destination inDest = mp7.kRx outDest = mp7.kTx inBaseLatency = latPropagationCyc - latTx2Rx outBaseLatency = latPropagationCyc - latRx2Tx print 'inBaseLatency', inBaseLatency print 'outBaseLatency', outBaseLatency else: raise ArgumentError('Unknown mode ' + mode) if src == 'counts': # Data source logging.debug('Configuring pattern generation on tx %s (inputs)', sorted(lIns)) patt = mp7.TestPathConfigurator(mp7.PathConfigurator.kPattern, mp7.orbit.Point(0), board.getMetric()) hlp.channelMgr(board, lIns).configureBuffers(inSrc, patt) # Outputs logging.debug('Configuring pattern generation on rx %s (outputs)', sorted(lOuts)) patt = mp7.TestPathConfigurator(mp7.PathConfigurator.kPattern3G, mp7.orbit.Point(0), board.getMetric()) hlp.channelMgr(board, lOuts).configureBuffers(outSrc, patt) elif src == 'events': # Data source, tx buffers of input channels logging.debug('Configuring playback generation on %s %s (inputs)', inSrc, sorted(lIns)) play = mp7.TestPathConfigurator(mp7.PathConfigurator.kPlayOnce, mp7.orbit.Point(0), board.getMetric()) hlp.channelMgr(board, lIns).configureBuffers(inSrc, play) logging.debug('Configuring strobed playback on %s %s (outputs)', outSrc, sorted(lOuts)) play = mp7.TestPathConfigurator(mp7.PathConfigurator.kPlayOnce3G, mp7.orbit.Point(0), board.getMetric()) hlp.channelMgr(board, lOuts).configureBuffers(outSrc, play) # Loading events from file # Input events first # rxevents = mp7.BoardDataFactory.readFromFile('events/s1golden-clean-strobed/rx_summary.txt') # txevents = mp7.BoardDataFactory.readFromFile('events/s1golden-clean-strobed/tx_summary.txt') if inject is None: rxevents = mp7.BoardDataFactory.generate('generate://pattern') txevents = mp7.BoardDataFactory.generate( 'generate://3gpattern') else: logging.info('Injecting events from %s', inject) rxevents = mp7.BoardDataFactory.generate('file://' + inject + '/rx_summary.txt') txevents = mp7.BoardDataFactory.generate('file://' + inject + '/tx_summary.txt') hlp.channelMgr(board, lIns).loadPatterns(inSrc, rxevents) hlp.channelMgr(board, lOuts).loadPatterns(outSrc, txevents) else: raise ArgumentError('WTF!?!?') # Real latency buffer configuration # Increase the latency to capture 2 bx ahead inLatency = inBaseLatency + add logging.debug( 'Configuring latency buffers even=%s, odd=%s, latency=%d', lInsEven, lInsOdd, inLatency) # Dummy inout channels txlatency = mp7.LatencyPathConfigurator(1, inLatency) hlp.channelMgr(board, lInsEven).configureBuffers(inDest, txlatency) txlatency = mp7.LatencyPathConfigurator(2, inLatency) hlp.channelMgr(board, lInsOdd).configureBuffers(inDest, txlatency) # Increase the latency to capture 2 bx ahead outLatency = outBaseLatency + add logging.debug('Configuring latency buffers outs=%s, latency=%d', lOuts, outLatency) # Dummy output channels txlatency = mp7.LatencyPathConfigurator(3, outLatency) hlp.channelMgr(board, lOuts).configureBuffers(outDest, txlatency)