From f7a59e4d3f21bc4e240fe5a62697b7198b2f4c2e Mon Sep 17 00:00:00 2001
From: Leon Hiemstra <hiemstra@astron.nl>
Date: Wed, 12 Nov 2014 09:35:06 +0000
Subject: [PATCH] extra

---
 .../unb1_test/tb/python/tc_unb1_test.py       | 84 ++++++++++---------
 1 file changed, 44 insertions(+), 40 deletions(-)

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 049a5f5911..d73cc739a4 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
@@ -94,9 +94,11 @@ def test_BG_to_DB(tc,io,cmd,use_pps=False):
     blocksize          = pow(2, ceil_log2(samples_per_packet+gapsize))
 
     Bg = pi_diag_block_gen.PiDiagBlockGen(tc,io,nofChannels=nof_streams, ramSizePerChannel=blocksize)
+    #Bg.write_block_gen_settings(samplesPerPacket=700, blocksPerSync=781250, gapSize=300, memLowAddr=0, memHighAddr=701, BSNInit=42)
     Db = pi_diag_data_buffer.PiDiagDataBuffer(tc,io,nofStreams=nof_streams,ramSizePerStream=blocksize)
-    resetptrn = [7]*samples_per_packet + [0]*(blocksize-samples_per_packet)
-    Db.overwrite_all_data_buffers(resetptrn, vLevel=9)
+    resetptrn = [0xffffffff]*samples_per_packet + [0]*(blocksize-samples_per_packet)
+    for s in tc.spNrs:
+        Db.overwrite_data_buffer(resetptrn,streamNr=s,vLevel=9)
 
     if use_pps==True:
         Bg.write_enable_pps()
@@ -104,15 +106,16 @@ def test_BG_to_DB(tc,io,cmd,use_pps=False):
     else:
         Bg.write_enable()
 
+
     bg_ram = []
-    for s in range(nof_streams):
+    for s in tc.spNrs:
         ram = Bg.read_waveform_ram(channelNr=s,vLevel=5)
         rram=[]
         for r in ram: rram.append(list(r)) # () -> []
         bg_ram.append(rram)
 
     db_ram = []
-    for s in range(nof_streams):
+    for s in tc.spNrs:
         db_ram.append(Db.read_data_buffer(streamNr=s,vLevel=5))
 
     tc.set_section_id('Compare (BG==DB) - ')
@@ -122,6 +125,7 @@ def test_BG_to_DB(tc,io,cmd,use_pps=False):
     tc.append_log(3, '')
     if compared==False: tc.set_result('FAILED')
     show_compare_arrays(tc,bg_ram,db_ram)
+    Bg.write_disable()
 
 def test_BG_to_DB_pps(tc,io,cmd):
     return test_BG_to_DB(tc,io,cmd,use_pps=True)
@@ -169,33 +173,31 @@ def test_info(tc,io,cmd):
     tc.append_log(3, '>>>')
     tc.append_log(1, '>>> %s' % help_text(tc,io,cmd))
     tc.append_log(3, '>>>')
-    
-    info = pi_system_info.PiSystemInfo(tc, io)
-
-    tc.append_log(1, '>>> reading REGMAPs')
-    info.make_register_info()
-    tc.append_log(3, '')
-    #info.read_reg_map()
-    #tc.append_log(3, '')
-    info.read_system_info()
-    tc.append_log(3, '')
-    info.read_use_phy()
-    tc.append_log(3, '')
-    design_name = info.read_design_name()
-    tc.append_log(1, '>>> design_name=%s' % design_name)
-    tc.append_log(3, '')
-    info.read_stamps()
-    tc.append_log(3, '')
-    info.read_design_note()
 
-    expected_design_name = tc.gpString
-    if cmd==3 and expected_design_name != '':
-        tc.set_section_id('Verify System Info - ')
-        tc.append_log(1, '>>> Verifying design_name == %s' % expected_design_name)
-        for name in design_name:
-            if (name != expected_design_name): 
-                tc.set_result('FAILED')
-                tc.append_log(2, '>>> design_name mismatch!! (%s != %s)' % (name,expected_design_name))
+    with node_io.NodeIO(tc.nodeImages, tc.base_ip) as temp_io:
+        info = pi_system_info.PiSystemInfo(tc, temp_io)
+        tc.append_log(1, '>>> reading REGMAPs')
+        info.make_register_info()
+        tc.append_log(3, '')
+        info.read_system_info()
+        tc.append_log(3, '')
+        info.read_use_phy()
+        tc.append_log(3, '')
+        design_name = info.read_design_name()
+        tc.append_log(1, '>>> design_name=%s' % design_name)
+        tc.append_log(3, '')
+        info.read_stamps()
+        tc.append_log(3, '')
+        info.read_design_note()
+    
+        expected_design_name = tc.gpString
+        if cmd==3 and expected_design_name != '':
+            tc.set_section_id('Verify System Info - ')
+            tc.append_log(1, '>>> Verifying design_name == %s' % expected_design_name)
+            for name in design_name:
+                if (name != expected_design_name): 
+                    tc.set_result('FAILED')
+                    tc.append_log(2, '>>> design_name mismatch!! (%s != %s)' % (name,expected_design_name))
 
 
     
@@ -250,17 +252,19 @@ def test_remu(tc,io,cmd):
     tc.append_log(3, '>>>')
 
     dummy_tc = test_case.Testcase('Dummy TB - ', '')
-    dummy_tc.set_result('PASSED')
+    with node_io.NodeIO(tc.nodeImages, tc.base_ip) as temp_io:
+        dummy_tc.set_result('PASSED')
     
-    Remu = pi_remu.PiRemu(dummy_tc, io)
-    try:
-        Remu.write_user_reconfigure()
-    except:
-        pass # ignoring FAILED
+        Remu = pi_remu.PiRemu(dummy_tc, temp_io)
+        try:
+            Remu.write_user_reconfigure()
+        except:
+            pass # ignoring FAILED
 
-    if dummy_tc.get_result() == 'FAILED':
-        tc.append_log(1, 'Result=%s but ignoring this' % dummy_tc.get_result())
+        if dummy_tc.get_result() == 'FAILED':
+            tc.append_log(1, 'Result=%s but ignoring this' % dummy_tc.get_result())
 
+    del dummy_tc
     tc.append_log(3, '')
 
 
@@ -331,8 +335,8 @@ Cmd = {
    10 : ('XAUI'   , test_tr_xaui, 'using pi_tr_xaui to read xaui status (access REG_TR_XAUI)',''),
    11 : ('10GBE'  , test_tr_10GbE,'using pi_tr_10GbE to read 10GbE status (access REG_TR_10GBE)',''),
    12 : ('BSN'    , test_bsn_mon, 'using pi_bsn_monitor to read BSN monitor (access REG_BSN_MONITOR)',''),
-   13 : ('BGDB'   , test_BG_to_DB,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py)',''),
-   14 : ('BGDBpps', test_BG_to_DB_pps,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py) using PPS',''),
+   13 : ('BGDB'   , test_BG_to_DB,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py)','(--sp for addressing streams)'),
+   14 : ('BGDBpps', test_BG_to_DB_pps,'using BG (pi_diag_block_gen.py) and DB (pi_diag_data_buffer.py) using PPS','(--sp for addressing streams)'),
    15 : ('EXAMPLE', show_example, 'show several example commands',''),
   100 : ('HELP'   , show_help,    'show help on commands','')
 }
-- 
GitLab