def add_slave_trigger(seqs, slaveChan): ''' Add the slave trigger to each sequence. ''' pulseLength = slaveChan.pulseParams[ 'length'] * slaveChan.physChan.samplingRate for seq in seqs: # skip if the sequence already starts with a slave trig if hasattr(seq[0], 'qubits') and seq[0].qubits == slaveChan: continue seq.insert(0, TAPulse("TRIG", slaveChan, pulseLength, 1.0, 0.0, 0.0))
def add_slave_trigger(seqs, slaveChan): ''' Add the slave trigger to each sequence. ''' for seq in seqs: # skip if the sequence already starts with a slave trig if hasattr(seq[0], 'channel') and seq[0].channel == slaveChan: continue seq.insert( 0, TAPulse("TRIG", slaveChan, slaveChan.pulseParams['length'], 1.0, 0.0, 0.0))
def add_digitizer_trigger(seqs, trigChan): ''' Add the digitizer trigger to a logical LL (pulse blocks). ''' # Attach a trigger to any pulse block containing a measurement for seq in seqs: for ct in range(len(seq)): if contains_measurement(seq[ct]) and not (hasattr( seq[ct], 'pulses') and trigChan in seq[ct].pulses.keys()): seq[ct] *= TAPulse("TRIG", trigChan, trigChan.pulseParams['length'], 1.0, 0.0, 0.0)
def Id(channel, *args, **kwargs): ''' A delay or no-op in the form of a pulse. Accepts the following pulse signatures: Id(channel, [kwargs]) Id(channel, delay, [kwargs]) ''' params = overrideDefaults(channel, kwargs) if len(args) > 0 and isinstance(args[0], (int, float)): params['length'] = args[0] return TAPulse("Id", channel, params['length'], 0)
def delay(sequences, delay): ''' Delays a sequence by the given amount. ''' if delay <= 0: # no need to inject zero delays return for seq in sequences: # loop through and look for WAIT instructions # use while loop because len(seq) will change as we inject delays ct = 0 while ct < len(seq) - 1: if seq[ct] == ControlFlow.Wait() or seq[ct] == ControlFlow.Sync(): seq.insert(ct + 1, TAPulse("Id", seq[ct + 1].channel, delay, 0)) ct += 1
def Id(qubit, *args, **kwargs): ''' A delay or do-nothing in the form of a pulse i.e. it will take pulseLength+2*bufferTime. Accepts the following pulse signatures: Id(qubit, [kwargs]) Id(qubit, delay, [kwargs]) Id(qubit1, qubit2, [kwargs]) Id((qubit1,qubit2...), delay, [kwargs]) ''' if not isinstance(qubit, tuple): channel = qubit else: channel = Channels.QubitFactory( reduce(operator.add, [q.name for q in qubit])) if len(args) > 0 and isinstance(args[0], Channels.Qubit): channel = Channels.QubitFactory(qubit.name + args[0].name) qubit = (qubit, args[0]) params = overrideDefaults(channel, kwargs) if len(args) > 0 and isinstance(args[0], (int, float)): params['length'] = args[0] numPts = np.round(params['length'] * params['samplingRate']) return TAPulse("Id", qubit, numPts, 0, 0, 0)
def BLANK(chan, width): return TAPulse("BLANK", chan.gateChan, width, 1, 0, 0)
def Ztheta(qubit, angle=0, label='Ztheta', **kwargs): # special cased because it can be done with a frame update return TAPulse(label, qubit, length=0, amp=0, phase=0, frameChange=-angle)