Short description of "RandRegTest", the VME Register Test Program used from the SBC of a l1calo crate to test VME I/O on a CMX card RandRegTest.py is a python program which is used to test CMX cards in l1calo crates. This program is run at the command prompt of the crate's Single Board Computer (SBC). RandRegTestexercizes a specified set of VME registers by reading and writing random values. The program is not limited to the CMX card type, nor to testing one card at a time. All VME registers tested must present a 16 bit content which may be written and read back. RandRegTest.py depends on the helper module py_vme.py for performing the VME IO. py_vme uses the l1calo program "vme" (more specifically "vme dump" and "vme edit") for the reading and writing of the registers at the command prompt of the SBC. RandRegTest initializes the registers before starting the main test loop: 0 ) The paramaters provided with command line used to invoke RandRegTest are parsed. The paramters must at least describe the set of VME addresses being tested which is specfied via one or more input files (see below). Additional parameters may be used to override the default behavior (see below). 1) Initialize the content of all registers in the set tested: Write a random intial value (this default may be overridden to be 0x0000) Read it back Complain if it is not the expected value If there was an error, wait and try a second time Wait X s (default is 0.0 s, which may be overridden) Read it again and complain if it is not the expected value or show that this second attempt found the expected value The last content read above is remembered as the expected initial value for that register 2) Each test loop writes a new value into one single register a) Pick a random target register address from the set tested Pick a random target register content (i.e. the NEW value to write) b) "Pre-Check": (i.e. verify that the previous content of the chosen register is still there) Read the content of the register chosen and compare against the known OLD content complain if the NEW content does not match the OLD expected content If there was a mismatch, try a second time: Wait X s (default is 0.0 s, which may be overridden) Read it again and complain if it is not the expected value or show that this second attempt found the expected value c) Modify the content of this loop's chosen target register The register address and content value were chosen in step (a) above. Write this chosen NEW value into this chosen target register d) "Post-Check": (i.e. verify that the intended change did indeed happen) Read this same target register content complain if it is not the NEW expected value If there was a mismatch, try a second time: Wait X s (default is 0.0 s, which may be overridden) Read it again and complain if it is not the expected value or show that this second attempt found the expected value e) "Patrol-Check": (i.e. verify that nothing else was changed) For every register in the set (this default behavior may be overridden, see below) Read that register content complain if it is not the expected value If there was a mismatch, try a second time: Wait X s (default is 0.0 s, which may be overridden) Read it again and complain if it is not the expected value or show that this second attempt found the expected value If the 1st and 2nd Patrol-Check values found were NOT the expected value BUT matched: Adjust the expecatation value to use the value that was read (i.e. "heal" by overwriting the program's formerly expected value and continue testing without additional error messages related to this one hardware error which was already noticed and recorded) Command line parameters available in version V1.3 of RandRegTest: > cmxuser@sbccmx-01python RandRegTest.py > > RandRegTest V1.3 Starting at Tue Feb 25 18:12:12 > ** missing parameter: register address file name ** > > Usage: python RandRegTest.py -r|--reg_addr register_address_file > [-t|--test_loops total_test_loops] > [-p|--patrol_loops total_patrol_loops] > [-w|--wait_on_error seconds_before_2nd_try] > [-z|--init_0x0000] > > -r register_address_file > or --reg_addr register_address_file > > Specify the name of a file defining the set of registers to test. > The content of this file should add members to the array "vme_addr_arr" > e.g.: > vme_addr_arr += ( "0x0070000c", > "0x0070000e" ) > This argument is required. > > -t total_test_loops > or --test_loops total_test_loops > > Specify the desired number of test loops. > This argument is optional and the default is 1 test loop. > > -p total_patrol_loops > or --loops total_patrol_loops > > Specify a desired number of patrol loops for check other registers > after having modified each targeted register. > Specifying a positive number N will check all registers N times. > Specifying a zero will skip all patrol check. > Specifying a negative number -N will check randomly chosen N registers. > This argument is optional and the default is 1 patrol loop > (i.e. check all registers once). > > -w seconds > or --wait_on_error seconds > > Specify an optional wait period after reading an incorrect value > before attempting a second chance read. > This argument is optional and the default is no waiting. > > -z > or --init_0x0000 > > Specify that all registers' content be initialized with 0x0000. > This argument is optional and the default is to initialize with random values. > Note: One usage detail which is not made clear enough in the parameter usage information above is that RandRegTest encourages modular management of the register defintion files. The user may combine multiple register definition files by using the "-r" parameter several times on the same command line ... -r file1 -r file2 ... Example: Here is register definition file called cmx1_bspt_16_dummy_regs.def specifying the block of 16 BSPT test registers from the crate's right side CMX (CMX #1 in slot 20). > # This array holds the set of VME address to test > > vme_addr_arr += ( "0x00780060", > "0x00780062", > "0x00780064", > "0x00780066", > "0x00780068", > "0x0078006a", > "0x0078006c", > "0x0078006e", > "0x00780070", > "0x00780072", > "0x00780074", > "0x00780076", > "0x00780078", > "0x0078007a", > "0x0078007c", > "0x0078007e" ) Example: The command below runs 100 test loops on the block of 16 test registers from the cmx BSPT in slot 20. > cmxuser@sbccmx-01python RandRegTest.py -r cmx1_bspt_16_dummy_regs.def -t 100 Note: For recording and documenting purposes the operator may use the linux "script" command to save a copy of the screen output. The linux "time" command may also be useful, e.g.: > time script -c "python RandRegTest.py -r cmx0_block16_dummy_reg_block.def -t 5000" CMX_SN4_RandRegTest_20140619.log