@@ -62,6 +62,20 @@ def __init__(self, host):
6262 :return:
6363 """
6464 self .host = host
65+
66+ # this is just for code introspection
67+ self .devices = None
68+ self .memory_devices = None
69+ self .other_devices = None
70+ self .sbrams = None
71+ self .qdrs = None
72+ self .registers = None
73+ self .tengbes = None
74+ self .snapshots = None
75+ self .system_info = None
76+ self .rcs_info = None
77+ # /just for introspection
78+
6579 self .__reset_device_info ()
6680 LOGGER .debug ('%s: now a CasperFpga' % self .host )
6781
@@ -319,16 +333,19 @@ def write_int(self, device_name, integer, blindwrite=False, word_offset=0):
319333 def __create_memory_devices (self , device_dict , memorymap_dict ):
320334 """
321335 Create memory devices from dictionaries of design information.
322- :param device_dict: raw dictionary of information from tagged blocks in Simulink design, keyed on device name
323- :param memorymap_dict: dictionary of information that would have been in coreinfo.tab - memory bus information
336+ :param device_dict: raw dictionary of information from tagged
337+ blocks in Simulink design, keyed on device name
338+ :param memorymap_dict: dictionary of information that would have been
339+ in coreinfo.tab - memory bus information
324340 :return:
325341 """
326342 # create and add memory devices to the memory device dictionary
327343 for device_name , device_info in device_dict .items ():
328344 if device_name == '' :
329- raise NameError ('There\' s a problem somewhere, got a blank device name?' )
345+ raise NameError ('There\' s a problem somewhere, got a blank '
346+ 'device name?' )
330347 if device_name in self .memory_devices .keys ():
331- raise NameError ('Memory device %s already exists. ' % device_name )
348+ raise NameError ('Memory device %s already exists' % device_name )
332349 # get the class from the known devices, if it exists there
333350 tag = device_info ['tag' ]
334351 try :
@@ -338,16 +355,20 @@ def __create_memory_devices(self, device_dict, memorymap_dict):
338355 pass
339356 else :
340357 if not callable (known_device_class ):
341- raise TypeError ('%s is not a callable Memory class - that\' s a problem.' % known_device_class )
342- new_device = known_device_class .from_device_info (self , device_name , device_info , memorymap_dict )
358+ raise TypeError ('%s is not a callable Memory class - '
359+ 'that\' s a problem.' % known_device_class )
360+ new_device = known_device_class .from_device_info (
361+ self , device_name , device_info , memorymap_dict )
343362 if new_device .name in self .memory_devices .keys ():
344- raise NameError ('Device called %s of type %s already exists in devices list.' %
345- (new_device .name , type (new_device )))
363+ raise NameError (
364+ 'Device called %s of type %s already exists in '
365+ 'devices list.' % (new_device .name , type (new_device )))
346366 self .devices [device_name ] = new_device
347367 self .memory_devices [device_name ] = new_device
348368 container = getattr (self , known_device_container )
349369 setattr (container , device_name , new_device )
350- assert id (getattr (container , device_name )) == id (new_device ) == id (self .memory_devices [device_name ])
370+ assert id (getattr (container , device_name )) == id (new_device )
371+ assert id (new_device ) == id (self .memory_devices [device_name ])
351372 # allow created devices to update themselves with full device info
352373 # link control registers, etc
353374 for name , device in self .memory_devices .items ():
@@ -359,46 +380,53 @@ def __create_memory_devices(self, device_dict, memorymap_dict):
359380 def __create_other_devices (self , device_dict ):
360381 """
361382 Store non-memory device information in a dictionary
362- :param device_dict: raw dictionary of information from tagged blocks in Simulink design, keyed on device name
383+ :param device_dict: raw dictionary of information from tagged
384+ blocks in Simulink design, keyed on device name
363385 :return:
364386 """
365387 for device_name , device_info in device_dict .items ():
366388 if device_name == '' :
367- raise NameError ('There\' s a problem somewhere, got a blank device name?' )
389+ raise NameError ('There\' s a problem somewhere, got a '
390+ 'blank device name?' )
368391 if device_name in self .other_devices .keys ():
369392 raise NameError ('Other device %s already exists.' % device_name )
370393 if device_info ['tag' ] in CASPER_OTHER_DEVICES .keys ():
371394 self .devices [device_name ] = device_info
372395 self .other_devices [device_name ] = device_info
373396
374397 def device_names_by_container (self , container_name ):
375- """Return a list of devices in a certain container.
376398 """
377- return [devname for devname , container in self .memory_devices .iteritems () if container == container_name ]
399+ Return a list of devices in a certain container.
400+ """
401+ return [devname for devname , container
402+ in self .memory_devices .iteritems ()
403+ if container == container_name ]
378404
379405 def devices_by_container (self , container ):
380- """Get devices using container type.
406+ """
407+ Get devices using container type.
381408 """
382409 return getattr (self , container )
383410
384411 def get_system_information (self , filename = None , fpg_info = None ):
385412 """
386413 Get information about the design running on the FPGA.
387- If filename is given, get it from there , otherwise query the host via KATCP.
414+ If filename is given, get it from file , otherwise query the host via KATCP.
388415 :param filename: fpg filename
389416 :param fpg_info: a tuple containing device_info and coreinfo dictionaries
390417 :return: <nothing> the information is populated in the class
391418 """
392419 if (filename is None ) and (fpg_info is None ):
393- raise RuntimeError ('Either filename or parsed fpg data must be given.' )
420+ raise RuntimeError ('Either filename or parsed fpg data '
421+ 'must be given.' )
394422 if filename is not None :
395423 device_dict , memorymap_dict = parse_fpg (filename )
396424 else :
397425 device_dict = fpg_info [0 ]
398426 memorymap_dict = fpg_info [1 ]
399427 # add system registers
400428 device_dict .update (self .__add_sys_registers ())
401- # reset current devices and create new ones from the new design information
429+ # reset current devices, create new ones from the new design information
402430 self .__reset_device_info ()
403431 self .__create_memory_devices (device_dict , memorymap_dict )
404432 self .__create_other_devices (device_dict )
@@ -424,11 +452,38 @@ def estimate_fpga_clock(self):
424452 secondpass += (2 ** 32 )
425453 return (secondpass - firstpass ) / 2000000.0
426454
455+ def check_tx_raw (self , wait_time = 0.2 , checks = 10 ):
456+ """
457+ Check to see whether this host is transmitting packets without
458+ error on all its GBE interfaces.
459+ :param wait_time: seconds to wait between checks
460+ :param checks: times to run check
461+ :return:
462+ """
463+ for gbecore in self .tengbes :
464+ if not gbecore .tx_okay (wait_time = wait_time , checks = checks ):
465+ return False
466+ return True
467+
468+ def check_rx_raw (self , wait_time = 0.2 , checks = 10 ):
469+ """
470+ Check to see whether this host is receiving packets without
471+ error on all its GBE interfaces.
472+ :param wait_time: seconds to wait between checks
473+ :param checks: times to run check
474+ :return:
475+ """
476+ for gbecore in self .tengbes :
477+ if not gbecore .rx_okay (wait_time = wait_time , checks = checks ):
478+ return False
479+ return True
480+
427481 @staticmethod
428482 def __add_sys_registers ():
429- standard_reg = {'tag' : 'xps:sw_reg' , 'mode' : 'one value' , 'io_dir' : 'To Processor' ,
430- 'io_delay' : '1' , 'sample_period' : '1' , 'sim_port' : 'off' , 'show_format' : 'off' ,
431- 'names' : 'reg' , 'bitwidths' : '32' , 'arith_types' : '0' , 'bin_pts' : '0' }
483+ standard_reg = {'tag' : 'xps:sw_reg' , 'io_dir' : 'To Processor' ,
484+ 'io_delay' : '1' , 'sample_period' : '1' , 'names' : 'reg' ,
485+ 'bitwidths' : '32' , 'bin_pts' : '0' , 'arith_types' : '0' ,
486+ 'sim_port' : 'off' , 'show_format' : 'off' , }
432487 sys_registers = {'sys_board_id' : standard_reg .copy (),
433488 'sys_rev' : standard_reg .copy (),
434489 'sys_rev_rcs' : standard_reg .copy (),
0 commit comments