From 615926ad0d6e63919ff0e3943ead157d973366c2 Mon Sep 17 00:00:00 2001
From: Leon Hiemstra <hiemstra@astron.nl>
Date: Thu, 20 Nov 2014 09:13:38 +0000
Subject: [PATCH] added BG overwrite functions

---
 .../unb1_test/tb/python/tc_unb1_test.py       | 31 +++++++++++++++----
 1 file changed, 25 insertions(+), 6 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 c4fdc17fcf..90a8246750 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
@@ -49,6 +49,7 @@ Description:
 # System imports
 import sys
 import signal
+import random
 import test_case
 import node_io
 import pi_system_info
@@ -190,8 +191,7 @@ def write_BG(tc,io,buf):
     for s in tc.spNrs:
         Bg.write_waveform_ram(buf,channelNr=s)
 
-
-def write_BG_0(tc,io,cmd):
+def write_BG_00100(tc,io,cmd):
     tc.append_log(3, '>>>')
     tc.append_log(1, '>>> %s' % help_text(tc,io,cmd))
     tc.append_log(3, '>>>')
@@ -200,8 +200,7 @@ def write_BG_0(tc,io,cmd):
     ptrn[blocksize/2]=1
     write_BG(tc,io,ptrn)
 
-
-def write_BG_f(tc,io,cmd):
+def write_BG_ff7ff(tc,io,cmd):
     tc.append_log(3, '>>>')
     tc.append_log(1, '>>> %s' % help_text(tc,io,cmd))
     tc.append_log(3, '>>>')
@@ -210,6 +209,22 @@ def write_BG_f(tc,io,cmd):
     ptrn[blocksize/2]=0xffff7fff
     write_BG(tc,io,ptrn)
 
+def write_BG_rand(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)
+    random.seed(10)
+    ptrn = [random.randint(0,0xffffffff) for r in range(blocksize)]
+    write_BG(tc,io,ptrn)
+
+def write_BG_count(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 = range(blocksize)
+    write_BG(tc,io,ptrn)
 
 
 def test_tr_xaui(tc,io,cmd):
@@ -447,8 +462,10 @@ Cmd['XAUI']    = (test_tr_xaui, 'using pi_tr_xaui to read xaui status (access RE
 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['BGs00100'] = (write_BG_00100,'set test BG pattern ...000000000010000000000...','(--sp for addressing streams)')
+Cmd['BGsff7ff'] = (write_BG_ff7ff,'set test BG pattern ...ffffffffff7ffffffffff...','(--sp for addressing streams)')
+Cmd['BGsrand']  = (write_BG_rand, 'set test BG pattern with pseudo random (seed=10)','(--sp for addressing streams)')
+Cmd['BGscount'] = (write_BG_count,'set test BG pattern with counter data','(--sp for addressing streams)')
 Cmd['sleep1']  = (sleep,        'Sleep 1 second','')
 Cmd['sleep5']  = (sleep,        'Sleep 5 seconds','')
 Cmd['example'] = (show_help,    'show several example commands','')
@@ -465,8 +482,10 @@ def help_text(tc,io,cmd):
         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 ",">:')
+        tc.append_log(0, '')
         for cmd in sorted(Cmd):
             tc.append_log(0, '    .  %s\t%s  %s' % (cmd,Cmd[cmd][1],Cmd[cmd][2]))
+        tc.append_log(0, '')
         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')
-- 
GitLab