def _check_awg_nr(self, awg_nr): """ Checks that the given AWG index is valid for the device. """ if self.devtype == 'HDAWG8' and (awg_nr < 0 or awg_nr > 3): raise zibase.ziValueError( 'Invalid AWG index of {} detected!'.format(awg_nr)) elif self.devtype == 'HDAWG4' and (awg_nr < 0 or awg_nr > 1): raise zibase.ziValueError( 'Invalid AWG index of {} detected!'.format(awg_nr))
def _check_awg_nr(self, awg_nr) -> None: """ Checks that the given AWG index is valid for the device. """ if (awg_nr != 0): raise zibase.ziValueError( 'Invalid AWG index of {} detected!'.format(awg_nr))
def _ensure_activity(self, awg_nr, mask_value=None, timeout=5, verbose=False): """ Record DIO data and test whether there is activity on the bits activated in the DIO protocol for the given AWG. """ if verbose: print("Testing DIO activity for AWG {}".format(awg_nr)) vld_mask = 1 << self.geti('awgs/{}/dio/valid/index'.format(awg_nr)) vld_polarity = self.geti('awgs/{}/dio/valid/polarity'.format(awg_nr)) strb_mask = (1 << self.geti('awgs/{}/dio/strobe/index'.format(awg_nr))) strb_slope = self.geti('awgs/{}/dio/strobe/slope'.format(awg_nr)) if mask_value is None: mask_value = self.geti('awgs/{}/dio/mask/value'.format(awg_nr)) cw_mask = mask_value << self.geti( 'awgs/{}/dio/mask/shift'.format(awg_nr)) for i in range(timeout): valid = True data = self.getv('raw/dios/0/data') if data is None: raise zibase.ziValueError('Failed to get DIO snapshot!') vld_activity = 0 strb_activity = 0 cw_activity = 0 for d in data: cw_activity |= (d & cw_mask) vld_activity |= (d & vld_mask) strb_activity |= (d & strb_mask) if cw_activity != cw_mask: print( "Did not see all codeword bits toggle! Got 0x{:08x}, expected 0x{:08x}." .format(cw_activity, cw_mask)) valid = False if vld_polarity != 0 and vld_activity != vld_mask: print("Did not see valid bit toggle!") valid = False if strb_slope != 0 and strb_activity != strb_mask: print("Did not see valid bit toggle!") valid = False if valid: return True return False
def _set_dio_calibration_delay(self, value): # Sanity check the value if value < 0 or value > 15: raise zibase.ziValueError( 'Trying to set DIO calibration delay to invalid value! Expected value in range 0 to 15. Got {}.' .format(value)) log.info('Setting DIO calibration delay to {}'.format(value)) # Store the value self._dio_calibration_delay = value # And configure the delays self.setd('raw/dios/0/delays/*', self._dio_calibration_delay)