diff --git a/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py b/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py index 1421ddf27f117ef879b864d8d3ec5ab4fb2cd9cd..c4fdc17fcf35801be23f3c242a56cfbd624e6127 100644 --- a/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py +++ b/boards/uniboard1/designs/unb1_test/tb/python/tc_unb1_test.py @@ -69,8 +69,8 @@ from pi_common import * def show_compare_arrays(tc,a,b): import numpy as np - tc.append_log(6, 'Compare array A:\n%s' % np.asarray(a)) - tc.append_log(6, 'With array B:\n%s' % np.asarray(b)) + tc.append_log(5, 'Compare array A:\n%s' % np.asarray(a)) + tc.append_log(5, 'With array B:\n%s' % np.asarray(b)) compared = (np.asarray(a) == np.asarray(b)) tc.append_log(5, 'Result:\n%s' % compared) return (not False in compared) @@ -78,10 +78,10 @@ def show_compare_arrays(tc,a,b): def test_BG_to_DB(tc,io,cmd): if tc.number == 1: use_pps=True - tc.set_section_id('Test BG-DB (pps) - ') + tc.set_section_id('Test BG-DB (pps sync) - ') else: use_pps=False - tc.set_section_id('Test BG-DB (nopps) - ') + tc.set_section_id('Test BG-DB - ') tc.append_log(3, '>>>') tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) @@ -109,9 +109,9 @@ def test_BG_to_DB(tc,io,cmd): for s in tc.spNrs: Db.overwrite_data_buffer(resetptrn,streamNr=s,vLevel=9) - db_ram = [] + # Trigger by reading databuffers: for s in tc.spNrs: - db_ram.append(Db.read_data_buffer(streamNr=s,vLevel=9)) + Db.read_data_buffer(streamNr=s,vLevel=9) if use_pps==True: Bg.write_enable_pps() @@ -124,27 +124,40 @@ def test_BG_to_DB(tc,io,cmd): for s in tc.spNrs: ram = Bg.read_waveform_ram(channelNr=s,vLevel=5) rram=[] - for r in ram: rram.append(list(r)) # () -> [] + for r in ram: + ram_10G = list(r) # () -> [] + # truncate: in 10GbE the data is only sized 700 + ram_10G = ram_10G[:-(blocksize-700)] # [:-(blocksize-samples_per_packet)] + rram.append(ram_10G) bg_ram.append(rram) - db_ram = [] for s in tc.spNrs: - db_ram.append(Db.read_data_buffer(streamNr=s,vLevel=5)) - - - # truncate: in 10GbE the data is only sized 700 - for bg in bg_ram: - bg[0] = bg[0][:-(blocksize-700)] + databuf = Db.read_data_buffer(streamNr=s,vLevel=5) + rram=[] + for r in databuf: + ram_10G = r + # truncate: in 10GbE the data is only sized 700 + ram_10G = ram_10G[:-(blocksize-700)] # [:-(blocksize-samples_per_packet)] + rram.append(ram_10G) + db_ram.append(rram) - for db in db_ram: - db[0] = db[0][:-(blocksize-700)] - #bg_ram[s][0] = bg_ram[s][0][:-(blocksize-samples_per_packet)] - #db_ram[s][0] = db_ram[s][0][:-(blocksize-samples_per_packet)] #print 'bg_ram=',bg_ram #print 'db_ram=',db_ram + tc.append_log(5, 'number of BG streams=%d number of DB streams=%d per stream:' % (len(bg_ram),len(db_ram))) + for st in range(len(bg_ram)): + tc.append_log(5, 'BG=%d blocks with' % len(bg_ram[st])) + for b in range(len(bg_ram[st])): + tc.append_log(5, '%d words' % len(bg_ram[st][b])) + + tc.append_log(5, 'DB=%d blocks with' % len(db_ram[st])) + for b in range(len(db_ram[st])): + tc.append_log(5, '%d words' % len(db_ram[st][b])) + + + tc.set_section_id('Compare (BG==DB) - ') compared = (bg_ram == db_ram) tc.append_log(3, '') @@ -158,6 +171,47 @@ def test_BG_to_DB(tc,io,cmd): Bg.write_disable() +def get_BG_blocksize(tc,io): + nof_streams=3 + blocksize=0 + Bg = pi_diag_block_gen.PiDiagBlockGen(tc,io,nofChannels=nof_streams,ramSizePerChannel=blocksize) + settings = Bg.read_block_gen_settings() + samples_per_packet = settings[0][1] + gapsize = settings[0][3] + blocksize = pow(2, ceil_log2(samples_per_packet+gapsize)) + return blocksize + +def write_BG(tc,io,buf): + tc.set_section_id('Write BG - ') + nof_streams=3 + blocksize=get_BG_blocksize(tc,io) + Bg = pi_diag_block_gen.PiDiagBlockGen(tc,io,nofChannels=nof_streams, ramSizePerChannel=blocksize) + Bg.write_disable() + for s in tc.spNrs: + Bg.write_waveform_ram(buf,channelNr=s) + + +def write_BG_0(tc,io,cmd): + tc.append_log(3, '>>>') + tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) + tc.append_log(3, '>>>') + blocksize=get_BG_blocksize(tc,io) + ptrn = [0]*blocksize + ptrn[blocksize/2]=1 + write_BG(tc,io,ptrn) + + +def write_BG_f(tc,io,cmd): + tc.append_log(3, '>>>') + tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) + tc.append_log(3, '>>>') + blocksize=get_BG_blocksize(tc,io) + ptrn = [0xffffffff]*blocksize + ptrn[blocksize/2]=0xffff7fff + write_BG(tc,io,ptrn) + + + def test_tr_xaui(tc,io,cmd): tc.set_section_id('Read tr xaui status - ') tc.append_log(3, '>>>') @@ -169,16 +223,41 @@ def test_tr_xaui(tc,io,cmd): on_execute(class_definition=PiTrXaui,regmap=REGMAP) +def verify_10GbE_status(tc,item_name,item_value): + no_errors = [0]*len(tc.nodeNrs) + err=[] + for s in range(len(item_value)): err.append(item_value[s][2][0]) + tc.append_log(3,'%s=%s' % (item_name,err)) + if err != no_errors: + tc.set_result('FAILED') + tc.append_log(1,'FAILED') + def test_tr_10GbE(tc,io,cmd): - tc.set_section_id('Read tr 10GbE status - ') + tc.set_section_id('tr_10GbE status - ') tc.append_log(3, '>>>') tc.append_log(1, '>>> %s' % help_text(tc,io,cmd)) tc.append_log(3, '>>>') - tc.append_log(3, '') from pi_tr_10GbE import REGMAP,PiTr10GbE - on_execute(class_definition=PiTr10GbE,regmap=REGMAP) + tr10 = PiTr10GbE(tc,io,nof_inst=1) + + if tc.verbosity > 5: + on_execute(class_definition=PiTr10GbE,regmap=REGMAP) # this reads/shows ALL status + + # set rx/tr _frame_maxlength to 9000 (jumbo) as it inits at 1518 and causing frame errors: + frame_size_jumbo = 9000 + tr10.write_reg(tc.nodeNrs,'REG_TR_10GBE',(REGMAP['rx_frame_maxlength'][2][0]),[frame_size_jumbo]) + tr10.write_reg(tc.nodeNrs,'REG_TR_10GBE',(REGMAP['tx_frame_maxlength'][2][0]),[frame_size_jumbo]) + + + tc.set_section_id('Read/verify tr_10GbE status over Nodes %s - ' % tc.nodeNrs) + tc.append_log(3, '') + + status_names = ['rx_stats_framesErr','tx_stats_framesErr','rx_stats_framesCRCErr', \ + 'tx_stats_framesCRCErr','rx_stats_etherStatsCRCErr','tx_stats_etherStatsCRCErr'] + for stat_name in status_names: + verify_10GbE_status(tc,stat_name,tr10.read_reg(tc.nodeNrs,'REG_TR_10GBE',(REGMAP[stat_name][2][0]),1)) @@ -365,9 +444,11 @@ Cmd['ETH'] = (test_eth, 'using pi_eth to read eth status','') Cmd['REMU'] = (test_remu, 'using pi_remu to load user image (access REG_REMU)','') Cmd['WDI'] = (test_wdi, 'using pi_wdi to reset to image in bank 0 (access REG_WDI)','') Cmd['XAUI'] = (test_tr_xaui, 'using pi_tr_xaui to read xaui status (access REG_TR_XAUI)','') -Cmd['10GBE'] = (test_tr_10GbE,'using pi_tr_10GbE to read 10GbE status (access REG_TR_10GBE)','') +Cmd['10GBE'] = (test_tr_10GbE,'using pi_tr_10GbE to read 10GbE status (access REG_TR_10GBE)','(-n1 for set maxframesize to jumbo)') Cmd['BSN'] = (test_bsn_mon, 'using pi_bsn_monitor to read BSN monitor (access REG_BSN_MONITOR)','') Cmd['BGDB'] = (test_BG_to_DB,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py)','(--sp for addressing streams, -n1 for use pps)') +Cmd['BG0'] = (write_BG_0, 'write test BG pattern ...000000000010000000000...','(--sp for addressing streams)') +Cmd['BGf'] = (write_BG_f, 'write test BG pattern ...ffffffffff7ffffffffff...','(--sp for addressing streams)') Cmd['sleep1'] = (sleep, 'Sleep 1 second','') Cmd['sleep5'] = (sleep, 'Sleep 5 seconds','') Cmd['example'] = (show_help, 'show several example commands','') @@ -377,10 +458,23 @@ Cmd['help'] = (show_help, 'show help on commands','') def help_text(tc,io,cmd): str='' if cmd == 'help': - tc.append_log(0, '>>> Usage [--seq <command(s) separated by ",">]:') + tc.append_log(0, '\n') + tc.append_log(0, '>>> Help:') + tc.append_log(0, 'Usage: %s <nodes> <command sequence> [-v..] [--rep ...]' % sys.argv[0]) + tc.append_log(0, '') + tc.append_log(0, ' <nodes>: use: --unb N --fn N --bn N (N is a number or vector) or:') + tc.append_log(0, ' <nodes>: use: --gn N (N is a number or vector)') + tc.append_log(0, ' <command sequence>: use: --seq <command(s) separated by ",">:') for cmd in sorted(Cmd): tc.append_log(0, ' . %s\t%s %s' % (cmd,Cmd[cmd][1],Cmd[cmd][2])) + tc.append_log(0, ' [-vN]: verbose level N (default=5): %s' % tc.verbose_levels()) + tc.append_log(0, ' [--rep N]: N=number of repeats, where -1 is forever, non-stop') + help_text(tc,io,'example') elif cmd == 'example': + tc.append_log(0, '') + tc.append_log(0, '>>> Examples:') + tc.append_log(0, '') + tc.append_log(0, 'Getting INFO from all nodes on 1 Uniboard: %s --gn 0:7 --seq INFO' % sys.argv[0]) tc.append_log(0, '') tc.append_log(0, '[reset, load user img] sequence: --seq REGMAP,WDI,REGMAP,REMU,REGMAP,INFO') tc.append_log(0, '[flash+start user img] sequence: --seq FLASH,WDI,REGMAP,REMU,REGMAP,INFO -s file.rbf') @@ -389,6 +483,7 @@ def help_text(tc,io,cmd): tc.append_log(0, '[program user image] sequence: --seq FLASH -s file.rbf') tc.append_log(0, '[load user image] sequence: --seq REMU,REGMAP') tc.append_log(0, '[modelsim BG-DB test] arguments: --unb 0 --fn 0 --seq BGDB --sim --sp 0:2') + tc.append_log(0, '\n') else: str = Cmd[cmd][1] return str