qick.averager_program
Several helper classes for writing qubit experiments.
Functions
|
create a new QickSweep object that merges the update and reset functions of multiple QickSweeps into one. |
Classes
|
Abstract QickSweep class. |
|
AveragerProgram class is an abstract base class for programs which do loops over experiments in hardware. |
|
NDAveragerProgram class, for experiments that sweep over multiple variables in qick. |
|
QickSweep class, describes a sweeps over a qick register. |
|
RAveragerProgram class, for qubit experiments that sweep over a variable (whose value is stored in expt_pts). |
- class qick.averager_program.AveragerProgram(soccfg, cfg)[source]
Bases:
AcquireProgramAveragerProgram class is an abstract base class for programs which do loops over experiments in hardware. It consists of a template program which takes care of the loop and acquire methods that talk to the processor to stream single shot data in real-time and then reshape and average it appropriately.
- Parameters:
soccfg (QickConfig) – This can be either a QickSoc object (if the program is running on the QICK) or a QickCOnfig (if running remotely).
cfg (dict) – Configuration dictionary
- COUNTER_ADDR = 1
- __init__(soccfg, cfg)[source]
Constructor for the AveragerProgram, calls make program at the end. For classes that inherit from this, if you want it to do something before the program is made and compiled: either do it before calling this __init__ or put it in the initialize method.
- initialize()[source]
Abstract method for initializing the program and can include any instructions that are executed once at the beginning of the program.
- make_program()[source]
A template program which repeats the instructions defined in the body() method the number of times specified in self.cfg[“reps”].
- acquire(soc, readouts_per_experiment=None, save_experiments=None, load_pulses=True, **kwargs)[source]
This method optionally loads pulses on to the SoC, configures the ADC readouts, loads the machine code representation of the AveragerProgram onto the SoC, starts the program and streams the data into the Python, returning it as a set of numpy arrays. config requirements: “reps” = number of repetitions;
- Parameters:
soc (QickSoc) – Qick object
threshold (int) – threshold
angle (list) – rotation angle
readouts_per_experiment (int) – readouts per experiment
save_experiments (list) – saved readouts (by default, save all readouts)
load_pulses (bool) – If true, loads pulses into the tProc
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – If true, displays progress bar
- Returns:
- acquire_decimated(soc, readouts_per_experiment=None, load_pulses=True, **kwargs)[source]
This method acquires the raw (downconverted and decimated) data sampled by the ADC. This method is slow and mostly useful for lining up pulses or doing loopback tests.
config requirements: “reps” = number of tProc loop repetitions; “soft_avgs” = number of Python loop repetitions;
The data is returned as a list of ndarrays (one ndarray per readout channel). There are two possible array formats. reps = 1: 2D array with dimensions (2, length), indices (I/Q, sample) reps > 1: 3D array with dimensions (reps, 2, length), indices (rep, I/Q, sample) readouts_per_experiment>1: 3D array with dimensions (reps, expts, 2, length), indices (rep, expt, I/Q, sample)
- Parameters:
soc (QickSoc) – Qick object
load_pulses (bool) – If true, loads pulses into the tProc
readouts_per_experiment (int) – readouts per experiment (all will be saved)
start_src (str) – “internal” (tProc starts immediately) or “external” (each soft_avg waits for an external trigger)
progress (bool) – If true, displays progress bar
- Returns:
iq_list (
list) - list of lists of averaged decimated I and Q data
- run_rounds(soc, readouts_per_experiment=None, load_pulses=True, **kwargs)[source]
Run the program and wait until it completes, once or multiple times. No data will be saved.
- Parameters:
soc (QickSoc) – Qick object
load_pulses (bool) – if True, load pulse envelopes and buffer weights
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – if true, displays progress bar
step_rounds (bool) – Return after setting up and preparing the first round. You will need to step through and complete the acquisition with prepare_round(), finish_round(), and finish_acquire().
- ABSOLUTE_FREQS = False
- FLIP_DOWNCONVERSION = False
- GAUSS_BUG = True
- USER_DURATIONS = False
- add_DRAG(ch, name, sigma, length, delta, alpha=0.5, det=0, maxv=None, even_length=False)
Adds a DRAG pulse to the envelope library. DRAG with constant detuning is implemented as defined in https://doi.org/10.1103/PhysRevLett.116.020501.
The envelope will peak at length/2.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float or float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
delta (float) – anharmonicity of the qubit, the difference between f_ge and f_ef (units of MHz)
alpha (float) – alpha parameter of DRAG (order-1 scale factor)
det (float) – constant detuning (units of MHz)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_cosine(ch, name, length, maxv=None, even_length=False)
Adds a cosine to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_envelope(ch, name, idata=None, qdata=None)
Adds a waveform to the list of envelope waveforms available for this channel. The I and Q arrays must be of equal length, and the length must be divisible by the samples-per-clock of this generator. If either array is omitted, zeros will be used for that component.
If this channel uses a real-only envelope, qdata must be omitted or all zeros.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray or None) – I data
qdata (numpy.ndarray or None) – Q data
- add_gauss(ch, name, sigma, length, maxv=None, even_length=False)
Adds a Gaussian to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_pulse(ch, name, idata=None, qdata=None)
Adds a waveform to the waveform library within the program.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray) – I data, 16-bit
qdata (numpy.ndarray) – Q data, 16-bit
- add_triangle(ch, name, length, maxv=None, even_length=False)
Adds a triangle to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- append_instruction(name, *args)
Append instruction to the program list
- asm()
Returns assembly representation of program as string, should be compatible with the parse_prog from the parser module.
- Returns:
asm file
- Return type:
- bin()
Returns binary representation of program as string.
- Returns:
Compiled program in binary format
- Return type:
- ch_page(gen_ch)
Gets tProc register page associated with generator channel.
- ch_page_ro(ro_ch)
Gets tProc register page associated with tProc-controlled readout channel.
- compare_program(fname)
For debugging purposes to compare binary compilation of parse_prog with the compile.
- compile(debug=False)
Compiles program to machine code.
- compile_instruction(inst, labels, debug=False)
Converts an assembly instruction into a machine bytecode.
- config_all(soc, load_envelopes=True, reset=False, load_mem=True)
Load the waveform memory, gens, ROs, and program memory as specified for this program. The decimated+accumulated buffers are not configured, since those should be re-configured for each acquisition. The tProc is set to internal start before any other configuration is done, to prevent spurious external starts.
- Parameters:
reset (bool) – Force-stop the tProc before loading the program. This option only affects tProc v1, where the reset takes several ms. For tProc v2, where reset is easy, we always do the reset.
- config_bufs(soc, enable_avg=True, enable_buf=True)
Configure the readout buffers specified in this program. This is usually called as part of an acquire() method.
- config_gens(soc)
Configure the signal generators specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- config_readouts(soc)
Configure the readout channels specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- convert_immediate(val)
Convert the register value to ensure that it is positive and not too large. Throws an error if you ever try to use a value greater than 2**31 as an immediate value.
- declare_gen(ch, nqz=1, mixer_freq=None, mixer_fullscale=False, mux_freqs=None, mux_gains=None, mux_phases=None, ro_ch=None)
Add a channel to the program’s list of signal generators.
If this is a generator with a mixer (interpolated or muxed generator), you may define a mixer frequency.
If this is a muxed generator, the mux_freqs list must be long enough to define all the tones you will play. (in other words, if your mask list ever enables tone 2 you must define at least 3 freqs+gains) If your mux gen supports gains and/or phases and you define them, those lists must be the same length. If you don’t define gains or phases, they will be set to defaults (max positive gain, zero phase).
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
nqz (int, optional) – Nyquist zone (must be 1 or 2). Setting the NQZ to 2 increases output power in the 2nd/3rd Nyquist zones.
mixer_freq (float, optional) – Mixer frequency (in MHz)
mixer_fullscale (bool) – DACs with mixers have a built-in scale factor of 0.7 to prevent overflow (see https://docs.amd.com/r/en-US/pg269-rf-data-converter/RF-DAC-Numerical-Controlled-Oscillator-and-Mixer). If this is set to True, the scale factor will be bypassed and you will get the full DAC range.
mux_freqs (list of float, optional) – Tone frequencies for the muxed generator (in MHz). For tProc v1 programs these should be given as offsets relative to the digital mixer frequency. For tProc v2 they should be given as absolute frequencies. Positive and negative values are allowed.
mux_gains (list of float, optional) – Tone amplitudes for the muxed generator (in range -1 to 1).
mux_phases (list of float, optional) – Phases for the muxed generator (in degrees).
ro_ch (int, optional) – readout channel for frequency-matching mixer and mux freqs
- declare_readout(ch, length, freq=None, phase=0, sel='product', gen_ch=None, edge_counting=False, high_threshold=0, low_threshold=0, weights=None)
Add a channel to the program’s list of readouts. Duration units depend on the program type: tProc v1 programs use integer number of samples, tProc v2 programs use float us.
- Parameters:
ch (int) – readout channel number (index in ‘readouts’ list)
freq (float) – downconverting frequency (MHz)
phase (float) – phase (degrees)
length (int or float) – readout length (number of decimated samples for tProc v1, us for tProc v2)
sel (str) – output select (‘product’, ‘dds’, ‘input’)
gen_ch (int) – generator channel (use None if you don’t want the downconversion frequency to be rounded to a valid DAC frequency or be offset by the DAC mixer frequency)
edge_counting (bool) – Sets edge counting mode on or off
high_threshold (int) – Sets the edge counting threshold level to go above to trigger a single count
low_threshold (int) – Sets the edge counting threshold level to go below to reset the trigger for next count
weights (numpy.ndarray) – Array of int16, shape (N, 2), representing an IQ array by which to multiply the readout window. Can only be used if this readout channel has a weighted buffer. If left as None, the weights will be set to [2**15-2, 0] (the maximum positive real value). If used, N must equal the number of decimated samples in the readout window.
- decrement_timestamps(t)
- default_pulse_registers(ch, **kwargs)
Set default values for pulse parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_pulse_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_pulse_registers.
- default_readout_registers(ch, **kwargs)
Set default values for readout parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_readout_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_readout_registers.
- dump_prog()
Dump the program to a dictionary. This output contains all the information necessary to run the program. In other words, it will have the low-level ASM and pulse+envelope data, but not higher-level structures. Caution: don’t modify the sub-dictionaries of this dict! You will be modifying the original program (this is not a deep copy).
- finish_acquire()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
- Returns:
Data in the same format that would be returned by acquire()/acquire_decimated().
- Return type:
- finish_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This runs the round by starting the tProc (if using internal start), then collecting and processing the data.
- Returns:
True if more rounds remain to be run. This is meant to be used to control a while loop.
- Return type:
- gentypes = {'axis_sg_int4_v1': <class 'qick.asm_v1.InterpolatedGenManager'>, 'axis_sg_mux4_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v2': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v3': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux8_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_signal_gen_v4': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v5': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v6': <class 'qick.asm_v1.FullSpeedGenManager'>}
- get_max_timestamp(gens=True, ros=True, gen_t0=None)
Calculate the max timestamp among the specified channels.
- get_raw()
Get the raw integer I/Q values (before normalizing to the readout window, averaging across reps, removing the readout offset, or thresholding). This can be called after acquire().
- Returns:
Array of I/Q values for each readout channel. The array dimensions correspond to the loop dimensions, data is in time order.
- Return type:
- get_rounds()
Get the results from each round, before averaging over rounds. This can be called after acquire() or acquire_decimated().
- Returns:
Array of I/Q values for each readout channel. Same dimensions as the return value from acquire()/acquire_decimated().
- Return type:
- get_shots()
Get the shot-by-shot threshold decisions. This can be called after acquire().
- Returns:
Array of shots for each readout channel.
- Return type:
- get_time_axis(ro_index, length_only=False)
Get an array usable as the time axis for plotting decimated data.
- Parameters:
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample. If length_only=True, an int is returned.
- Return type:
numpy.ndarray of float, or int
- get_time_axis_ddr4(ro_ch, data)
Get an array usable as the time axis for plotting DDR4 data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – DDR4 data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample.
- Return type:
- get_time_axis_mr(ro_ch, data)
Get an array usable as the time axis for plotting MR data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – MR data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per MR sample.
- Return type:
- get_timestamp(gen_ch=None, ro_ch=None)
- hex()
Returns hex representation of program as string.
- Returns:
Compiled program in hex format
- Return type:
- instructions = {'bitw': {'bin': 85, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'bitwi': {'bin': 22, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'comment': {'fmt': ()}, 'condj': {'bin': 49, 'fmt': ((0, 53), (2, 46), (1, 36), (3, 31), (4, 0)), 'repr': '{0}, ${1}, {2}, ${3}, @{4}', 'type': 'J2'}, 'end': {'bin': 63, 'fmt': (), 'repr': '', 'type': 'J1'}, 'loopnz': {'bin': 48, 'fmt': ((0, 53), (1, 41), (1, 36), (2, 0)), 'repr': '{0}, ${1}, @{2}', 'type': 'J1'}, 'math': {'bin': 80, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'mathi': {'bin': 18, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'memr': {'bin': 86, 'fmt': ((0, 53), (1, 41), (2, 36)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memri': {'bin': 23, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'memw': {'bin': 87, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memwi': {'bin': 24, 'fmt': ((0, 53), (1, 31), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'popi': {'bin': 17, 'fmt': ((0, 53), (1, 41)), 'repr': '{0}, ${1}', 'type': 'I'}, 'pushi': {'bin': 16, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 0)), 'repr': '{0}, ${1}, ${2}, {3}', 'type': 'I'}, 'read': {'bin': 83, 'fmt': ((1, 53), (0, 50), (2, 46), (3, 41)), 'repr': '{0}, {1}, {2} ${3}', 'type': 'R'}, 'regwi': {'bin': 25, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'set': {'bin': 81, 'fmt': ((1, 53), (0, 50), (2, 36), (7, 31), (3, 26), (4, 21), (5, 16), (6, 11)), 'repr': '{0}, {1}, ${2}, ${3}, ${4}, ${5}, ${6}, ${7}', 'type': 'R'}, 'setb': {'bin': 88, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'setbi': {'bin': 26, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'seti': {'bin': 19, 'fmt': ((1, 53), (0, 50), (2, 36), (3, 0)), 'repr': '{0}, {1}, ${2}, {3}', 'type': 'I'}, 'sync': {'bin': 82, 'fmt': ((0, 53), (1, 31)), 'repr': '{0}, ${1}', 'type': 'R'}, 'synci': {'bin': 20, 'fmt': ((0, 0),), 'repr': '{0}', 'type': 'I'}, 'wait': {'bin': 84, 'fmt': ((1, 53), (0, 50), (2, 31)), 'repr': '{0}, {1}, ${2}', 'type': 'R'}, 'waiti': {'bin': 21, 'fmt': ((0, 50), (1, 0)), 'repr': '{0}, {1}', 'type': 'I'}}
- label(name)
Add line number label to the labels dictionary. This labels the instruction by its position in the program list. The loopz and condj commands use this label information.
- Parameters:
name (str) – Label name
- load_envelopes(soc)
Loads envelopes that were added using add_envelope into the SoC’s signal generator memories. Also load weight arrays for weighted buffers.
- Parameters:
soc (QickSoc) – Qick object
- load_prog(progdict)
Load the program from a dictionary.
- measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None)
Wrapper method that combines an ADC trigger, a pulse, and (optionally) the appropriate wait and a sync_all. You must have already run set_pulse_registers for this channel.
If you use wait=True, it’s recommended to also specify a nonzero syncdelay.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int or list of int) – generator channel(s) (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – Pause tProc execution until the end of the ADC readout window
syncdelay (int, optional) – The number of additional tProc cycles to delay in the sync_all
- op_codes = {'!=': 5, '&': 0, '*': 10, '+': 8, '-': 9, '<': 2, '<<': 4, '<=': 3, '==': 4, '>': 0, '>=': 1, '>>': 5, '^': 2, 'lower': 5, 'upper': 10, '|': 1, '~': 3}
- prepare_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This sets up the round by preparing data structures and configuring the firmware, including arming the tProc for external start (if used).
The first round is prepared for you by acquire()/acquire_decimated()/run_rounds().
- print_sg_mem(sg_idx=0, gen_file=False)
Prints the content of the SG envelope table memory to be loaded in an RTL simulation. This assumes that the envelopes defined for this channel are contiguous in memory and start at address 0.
- pulse(ch, t='auto')
Play the pulse currently programmed into the registers for this generator channel. You must have already run set_pulse_registers for this channel.
- readout(ch, t)
Play the pulse currently programmed into the registers for this tProc-controlled readout channel. You must have already run set_readout_registers for this channel.
- reset_phase(gen_ch: Optional[Union[int, List[int]]] = None, ro_ch: Optional[Union[int, List[int]]] = None, t: int = 0)
Reset the phase of generator and tproc-controlled readout channels at tproc time t. This will play an empty pulse that lasts 3 fabric clock cycles, just to trigger the phase reset.
This command is designed to be transparent to previous ‘set_pulse/readout_registers()’ calls. i.e. the register values set using ‘set_pulse/readout_registers()’ before this command will remain the same after this command. However, pulse registers set using other functions will need to be re-set, e.g. if a pulse register value was set by directly calling ‘regwi()’, calling this function will overwrite that register value, and user need to redo the ‘regwi()’ after this phase reset.
- Parameters:
gen_ch – generator channel(s) to reset phase (index in ‘gens’ list)
ro_ch – tProc-controlled readout channel(s) to reset phase (index in ‘readouts’ list)
t – the number of tProc cycles at which the phase reset happens
- reset_timestamps(gen_t0=None)
- run(soc, load_prog=True, load_envelopes=True, start_src='internal')
Load the program into the tProcessor and start it. Because there is in general no way to tell when a program is done running, there is no guarantee that the program will be done before this method returns. If you want that guarantee, use run_rounds().
- Parameters:
soc (QickSoc) – The QickSoc that will execute this program.
load_prog (bool) – Load the program before starting the tProc.
load_envelopes (bool) – Load the generator envelopes before starting the tProc. If load_prog is False, load_envelopes is ignored.
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger).
- safe_regwi(rp, reg, imm, comment=None)
Due to the way the instructions are setup immediate values can only be 30bits before not loading properly. This comes up mostly when trying to regwi values into registers, especially the _frequency_ and _phase_ pulse registers. safe_regwi can be used wherever one might use regwi and will detect if the value is >2**30 and if so will break it into two steps, putting in the first 30 bits shifting it over and then adding the last two.
- set_pulse_registers(ch, **kwargs)
Set the pulse parameters including frequency, phase, address of pulse, gain, stdysel, mode register (compiled from length and other flags), outsel, and length. The time is scheduled when you call pulse(). See the write_regs() method of the relevant generator manager for the list of supported pulse styles.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
style (str) – Pulse style (“const”, “arb”, “flat_top”)
freq (int) – Frequency (register value)
phase (int) – Phase (register value)
gain (int) – Gain (DAC units)
phrst (int) – If 1, it resets the phase coherent accumulator
stdysel (str) – Selects what value is output continuously by the signal generator after the generation of a pulse. If “last”, it is the last calculated sample of the pulse. If “zero”, it is a zero value.
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If “product”, the output is the product of table and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the table for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles in the flat portion of the pulse, used for “const” and “flat_top” styles
waveform (str) – Name of the envelope waveform loaded with add_envelope(), used for “arb” and “flat_top” styles
mask (list of int) – for a muxed signal generator, the list of tones to enable for this pulse
- set_readout_registers(ch, **kwargs)
Set the readout parameters including frequency, mode, outsel, and length. The time is scheduled when you call readout().
- Parameters:
ch (int) – readout channel (index in ‘readouts’ list)
freq (int) – Frequency (register value)
phrst (int) – If 1, it resets the phase coherent accumulator
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. The input comes from the ADC and is purely real. If “product”, the output is the product of input and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the input for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles for which these readout parameters are defined.
- set_reads_per_shot(reads_per_shot)
Override the default count of readout triggers per shot. This should be called after setup_acquire(). You probably shouldn’t be using this method; the default value is usually correct.
- set_timestamp(val, gen_ch=None, ro_ch=None)
- setup_acquire(counter_addr, loop_dims, avg_level)
Set the parameters needed to define the data acquisition. Since the number of readouts per shot is set based on calls to trigger(), this should be called after the program has been fully defined.
- setup_and_measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None, **kwargs)
Set up a pulse on this generator channel, and immediately do a measurement with it. This is a wrapper around set_pulse_registers() and measure(), and takes the arguments from both. You can only run this on a single generator channel.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int) – generator channel (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – refer to measure()
syncdelay (int, optional) – refer to measure()
**kwargs (dict) – Pulse parameters: refer to set_pulse_registers()
- setup_and_pulse(ch, t='auto', **kwargs)
Set up a pulse on this generator channel, and immediately play it. This is a wrapper around set_pulse_registers() and pulse(), and takes the arguments from both. You can only run this on a single generator channel.
- setup_counter(counter_addr, loop_dims)
Set the parameters needed to track the progress of the program. This is a subset of setup_acquire(), appropriate for programs where you have no readouts. You should use this if you’re updating a tProc counter and want to use it to track program progress.
- soccfg_methods = ['freq2reg', 'freq2reg_adc', 'reg2freq', 'reg2freq_adc', 'cycles2us', 'us2cycles', 'deg2reg', 'reg2deg', 'roundfreq', 'get_maxv']
- sreg(gen_ch, name)
Gets tProc special register number associated with a generator channel and register name.
- sreg_ro(ro_ch, name)
Gets tProc special register number associated with a readout channel and register name.
- sync_all(t=0, gen_t0=None)
Sets the tProc reference time to the point where all generator pulses and readout windows are complete, plus additional time t. This does not pause the tProc. gen_t0 is an optional list of additional delays for each individual generator channel, e.g. when the channels are on different tiles so they don’t natively sync.
This does nothing if the firmware has no generators or readouts.
- trigger(adcs=None, pins=None, ddr4=False, mr=False, adc_trig_offset=270, t=0, width=10, rp=0, r_out=16)
Pulse the readout(s) and marker pin(s) with a specified pulse width at a specified time t+adc_trig_offset. If no readouts are specified, the adc_trig_offset is not applied.
- Parameters:
adcs (list of int) – List of readout channels to trigger (index in ‘readouts’ list)
pins (list of int) – List of marker pins to pulse. Use the pin numbers in the QickConfig printout.
ddr4 (bool) – If True, trigger the DDR4 buffer.
mr (bool) – If True, trigger the MR buffer.
adc_trig_offset (int, optional) – Offset time at which the ADC is triggered (in tProc cycles)
t (int, optional) – The number of tProc cycles at which the ADC trigger starts
width (int, optional) – The width of the trigger pulse, in tProc cycles
rp (int, optional) – Register page
r_out (int, optional) – Register number
- class qick.averager_program.RAveragerProgram(soccfg, cfg)[source]
Bases:
AcquireProgramRAveragerProgram class, for qubit experiments that sweep over a variable (whose value is stored in expt_pts). It is an abstract base class similar to the AveragerProgram, except has an outer loop which allows one to sweep a parameter in the real-time program rather than looping over it in software. This can be more efficient for short duty cycles. Acquire gathers data from both ADCs 0 and 1.
- Parameters:
cfg (dict) – Configuration dictionary
- COUNTER_ADDR = 1
- __init__(soccfg, cfg)[source]
Constructor for the RAveragerProgram, calls make program at the end so for classes that inherit from this if you want it to do something before the program is made and compiled either do it before calling this __init__ or put it in the initialize method.
- initialize()[source]
Abstract method for initializing the program and can include any instructions that are executed once at the beginning of the program.
- make_program()[source]
A template program which repeats the instructions defined in the body() method the number of times specified in self.cfg[“reps”].
- get_expt_pts()[source]
Method for calculating experiment points (for x-axis of plots) based on the config.
- Returns:
Numpy array of experiment points
- Return type:
- acquire(soc, readouts_per_experiment=None, save_experiments=None, load_pulses=True, **kwargs)[source]
This method optionally loads pulses on to the SoC, configures the ADC readouts, loads the machine code representation of the AveragerProgram onto the SoC, starts the program and streams the data into the Python, returning it as a set of numpy arrays. config requirements: “reps” = number of repetitions;
- Parameters:
soc (QickSoc) – Qick object
threshold (int) – threshold
angle (list) – rotation angle
readouts_per_experiment (int) – readouts per experiment
save_experiments (list) – saved readouts (by default, save all readouts)
load_pulses (bool) – If true, loads pulses into the tProc
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – If true, displays progress bar
- Returns:
- run_rounds(soc, readouts_per_experiment=None, load_pulses=True, **kwargs)[source]
Run the program and wait until it completes, once or multiple times. No data will be saved.
- Parameters:
soc (QickSoc) – Qick object
load_pulses (bool) – if True, load pulse envelopes and buffer weights
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – if true, displays progress bar
step_rounds (bool) – Return after setting up and preparing the first round. You will need to step through and complete the acquisition with prepare_round(), finish_round(), and finish_acquire().
- ABSOLUTE_FREQS = False
- FLIP_DOWNCONVERSION = False
- GAUSS_BUG = True
- USER_DURATIONS = False
- acquire_decimated(soc, rounds=1, load_envelopes=True, start_src='internal', progress=True, remove_offset=True, step_rounds=False, extra_args=None)
Acquire data using the decimating readout.
- Parameters:
soc (QickSoc) – Qick object
rounds (int) – number of times to rerun the program, averaging results in software (aka “soft averages”)
load_envelopes (bool) – if True, load pulse envelopes and buffer weights
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – if true, displays progress bar
remove_offset (bool) – Subtract the readout’s IQ offset, if any.
step_rounds (bool) – Return after setting up the acquisition and preparing the first round. You will need to step through and complete the acquisition with prepare_round(), finish_round(), and finish_acquire().
extra_args (dict or None) – If the data-processing methods have been overriden and need extra arguments, those are supplied here and will be added to acquire_params.
- Returns:
decimated values, averaged over rounds (float) dimensions for a single-rep, single-read program : (length, 2) multi-rep or multi-read: (n_reps*n_reads, length, 2) multi-rep and multi-read: (n_reps, n_reads, length, 2)
- Return type:
- add_DRAG(ch, name, sigma, length, delta, alpha=0.5, det=0, maxv=None, even_length=False)
Adds a DRAG pulse to the envelope library. DRAG with constant detuning is implemented as defined in https://doi.org/10.1103/PhysRevLett.116.020501.
The envelope will peak at length/2.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float or float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
delta (float) – anharmonicity of the qubit, the difference between f_ge and f_ef (units of MHz)
alpha (float) – alpha parameter of DRAG (order-1 scale factor)
det (float) – constant detuning (units of MHz)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_cosine(ch, name, length, maxv=None, even_length=False)
Adds a cosine to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_envelope(ch, name, idata=None, qdata=None)
Adds a waveform to the list of envelope waveforms available for this channel. The I and Q arrays must be of equal length, and the length must be divisible by the samples-per-clock of this generator. If either array is omitted, zeros will be used for that component.
If this channel uses a real-only envelope, qdata must be omitted or all zeros.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray or None) – I data
qdata (numpy.ndarray or None) – Q data
- add_gauss(ch, name, sigma, length, maxv=None, even_length=False)
Adds a Gaussian to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_pulse(ch, name, idata=None, qdata=None)
Adds a waveform to the waveform library within the program.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray) – I data, 16-bit
qdata (numpy.ndarray) – Q data, 16-bit
- add_triangle(ch, name, length, maxv=None, even_length=False)
Adds a triangle to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- append_instruction(name, *args)
Append instruction to the program list
- asm()
Returns assembly representation of program as string, should be compatible with the parse_prog from the parser module.
- Returns:
asm file
- Return type:
- bin()
Returns binary representation of program as string.
- Returns:
Compiled program in binary format
- Return type:
- ch_page(gen_ch)
Gets tProc register page associated with generator channel.
- ch_page_ro(ro_ch)
Gets tProc register page associated with tProc-controlled readout channel.
- compare_program(fname)
For debugging purposes to compare binary compilation of parse_prog with the compile.
- compile(debug=False)
Compiles program to machine code.
- compile_instruction(inst, labels, debug=False)
Converts an assembly instruction into a machine bytecode.
- config_all(soc, load_envelopes=True, reset=False, load_mem=True)
Load the waveform memory, gens, ROs, and program memory as specified for this program. The decimated+accumulated buffers are not configured, since those should be re-configured for each acquisition. The tProc is set to internal start before any other configuration is done, to prevent spurious external starts.
- Parameters:
reset (bool) – Force-stop the tProc before loading the program. This option only affects tProc v1, where the reset takes several ms. For tProc v2, where reset is easy, we always do the reset.
- config_bufs(soc, enable_avg=True, enable_buf=True)
Configure the readout buffers specified in this program. This is usually called as part of an acquire() method.
- config_gens(soc)
Configure the signal generators specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- config_readouts(soc)
Configure the readout channels specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- convert_immediate(val)
Convert the register value to ensure that it is positive and not too large. Throws an error if you ever try to use a value greater than 2**31 as an immediate value.
- declare_gen(ch, nqz=1, mixer_freq=None, mixer_fullscale=False, mux_freqs=None, mux_gains=None, mux_phases=None, ro_ch=None)
Add a channel to the program’s list of signal generators.
If this is a generator with a mixer (interpolated or muxed generator), you may define a mixer frequency.
If this is a muxed generator, the mux_freqs list must be long enough to define all the tones you will play. (in other words, if your mask list ever enables tone 2 you must define at least 3 freqs+gains) If your mux gen supports gains and/or phases and you define them, those lists must be the same length. If you don’t define gains or phases, they will be set to defaults (max positive gain, zero phase).
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
nqz (int, optional) – Nyquist zone (must be 1 or 2). Setting the NQZ to 2 increases output power in the 2nd/3rd Nyquist zones.
mixer_freq (float, optional) – Mixer frequency (in MHz)
mixer_fullscale (bool) – DACs with mixers have a built-in scale factor of 0.7 to prevent overflow (see https://docs.amd.com/r/en-US/pg269-rf-data-converter/RF-DAC-Numerical-Controlled-Oscillator-and-Mixer). If this is set to True, the scale factor will be bypassed and you will get the full DAC range.
mux_freqs (list of float, optional) – Tone frequencies for the muxed generator (in MHz). For tProc v1 programs these should be given as offsets relative to the digital mixer frequency. For tProc v2 they should be given as absolute frequencies. Positive and negative values are allowed.
mux_gains (list of float, optional) – Tone amplitudes for the muxed generator (in range -1 to 1).
mux_phases (list of float, optional) – Phases for the muxed generator (in degrees).
ro_ch (int, optional) – readout channel for frequency-matching mixer and mux freqs
- declare_readout(ch, length, freq=None, phase=0, sel='product', gen_ch=None, edge_counting=False, high_threshold=0, low_threshold=0, weights=None)
Add a channel to the program’s list of readouts. Duration units depend on the program type: tProc v1 programs use integer number of samples, tProc v2 programs use float us.
- Parameters:
ch (int) – readout channel number (index in ‘readouts’ list)
freq (float) – downconverting frequency (MHz)
phase (float) – phase (degrees)
length (int or float) – readout length (number of decimated samples for tProc v1, us for tProc v2)
sel (str) – output select (‘product’, ‘dds’, ‘input’)
gen_ch (int) – generator channel (use None if you don’t want the downconversion frequency to be rounded to a valid DAC frequency or be offset by the DAC mixer frequency)
edge_counting (bool) – Sets edge counting mode on or off
high_threshold (int) – Sets the edge counting threshold level to go above to trigger a single count
low_threshold (int) – Sets the edge counting threshold level to go below to reset the trigger for next count
weights (numpy.ndarray) – Array of int16, shape (N, 2), representing an IQ array by which to multiply the readout window. Can only be used if this readout channel has a weighted buffer. If left as None, the weights will be set to [2**15-2, 0] (the maximum positive real value). If used, N must equal the number of decimated samples in the readout window.
- decrement_timestamps(t)
- default_pulse_registers(ch, **kwargs)
Set default values for pulse parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_pulse_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_pulse_registers.
- default_readout_registers(ch, **kwargs)
Set default values for readout parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_readout_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_readout_registers.
- dump_prog()
Dump the program to a dictionary. This output contains all the information necessary to run the program. In other words, it will have the low-level ASM and pulse+envelope data, but not higher-level structures. Caution: don’t modify the sub-dictionaries of this dict! You will be modifying the original program (this is not a deep copy).
- finish_acquire()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
- Returns:
Data in the same format that would be returned by acquire()/acquire_decimated().
- Return type:
- finish_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This runs the round by starting the tProc (if using internal start), then collecting and processing the data.
- Returns:
True if more rounds remain to be run. This is meant to be used to control a while loop.
- Return type:
- gentypes = {'axis_sg_int4_v1': <class 'qick.asm_v1.InterpolatedGenManager'>, 'axis_sg_mux4_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v2': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v3': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux8_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_signal_gen_v4': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v5': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v6': <class 'qick.asm_v1.FullSpeedGenManager'>}
- get_max_timestamp(gens=True, ros=True, gen_t0=None)
Calculate the max timestamp among the specified channels.
- get_raw()
Get the raw integer I/Q values (before normalizing to the readout window, averaging across reps, removing the readout offset, or thresholding). This can be called after acquire().
- Returns:
Array of I/Q values for each readout channel. The array dimensions correspond to the loop dimensions, data is in time order.
- Return type:
- get_rounds()
Get the results from each round, before averaging over rounds. This can be called after acquire() or acquire_decimated().
- Returns:
Array of I/Q values for each readout channel. Same dimensions as the return value from acquire()/acquire_decimated().
- Return type:
- get_shots()
Get the shot-by-shot threshold decisions. This can be called after acquire().
- Returns:
Array of shots for each readout channel.
- Return type:
- get_time_axis(ro_index, length_only=False)
Get an array usable as the time axis for plotting decimated data.
- Parameters:
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample. If length_only=True, an int is returned.
- Return type:
numpy.ndarray of float, or int
- get_time_axis_ddr4(ro_ch, data)
Get an array usable as the time axis for plotting DDR4 data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – DDR4 data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample.
- Return type:
- get_time_axis_mr(ro_ch, data)
Get an array usable as the time axis for plotting MR data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – MR data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per MR sample.
- Return type:
- get_timestamp(gen_ch=None, ro_ch=None)
- hex()
Returns hex representation of program as string.
- Returns:
Compiled program in hex format
- Return type:
- instructions = {'bitw': {'bin': 85, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'bitwi': {'bin': 22, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'comment': {'fmt': ()}, 'condj': {'bin': 49, 'fmt': ((0, 53), (2, 46), (1, 36), (3, 31), (4, 0)), 'repr': '{0}, ${1}, {2}, ${3}, @{4}', 'type': 'J2'}, 'end': {'bin': 63, 'fmt': (), 'repr': '', 'type': 'J1'}, 'loopnz': {'bin': 48, 'fmt': ((0, 53), (1, 41), (1, 36), (2, 0)), 'repr': '{0}, ${1}, @{2}', 'type': 'J1'}, 'math': {'bin': 80, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'mathi': {'bin': 18, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'memr': {'bin': 86, 'fmt': ((0, 53), (1, 41), (2, 36)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memri': {'bin': 23, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'memw': {'bin': 87, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memwi': {'bin': 24, 'fmt': ((0, 53), (1, 31), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'popi': {'bin': 17, 'fmt': ((0, 53), (1, 41)), 'repr': '{0}, ${1}', 'type': 'I'}, 'pushi': {'bin': 16, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 0)), 'repr': '{0}, ${1}, ${2}, {3}', 'type': 'I'}, 'read': {'bin': 83, 'fmt': ((1, 53), (0, 50), (2, 46), (3, 41)), 'repr': '{0}, {1}, {2} ${3}', 'type': 'R'}, 'regwi': {'bin': 25, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'set': {'bin': 81, 'fmt': ((1, 53), (0, 50), (2, 36), (7, 31), (3, 26), (4, 21), (5, 16), (6, 11)), 'repr': '{0}, {1}, ${2}, ${3}, ${4}, ${5}, ${6}, ${7}', 'type': 'R'}, 'setb': {'bin': 88, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'setbi': {'bin': 26, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'seti': {'bin': 19, 'fmt': ((1, 53), (0, 50), (2, 36), (3, 0)), 'repr': '{0}, {1}, ${2}, {3}', 'type': 'I'}, 'sync': {'bin': 82, 'fmt': ((0, 53), (1, 31)), 'repr': '{0}, ${1}', 'type': 'R'}, 'synci': {'bin': 20, 'fmt': ((0, 0),), 'repr': '{0}', 'type': 'I'}, 'wait': {'bin': 84, 'fmt': ((1, 53), (0, 50), (2, 31)), 'repr': '{0}, {1}, ${2}', 'type': 'R'}, 'waiti': {'bin': 21, 'fmt': ((0, 50), (1, 0)), 'repr': '{0}, {1}', 'type': 'I'}}
- label(name)
Add line number label to the labels dictionary. This labels the instruction by its position in the program list. The loopz and condj commands use this label information.
- Parameters:
name (str) – Label name
- load_envelopes(soc)
Loads envelopes that were added using add_envelope into the SoC’s signal generator memories. Also load weight arrays for weighted buffers.
- Parameters:
soc (QickSoc) – Qick object
- load_prog(progdict)
Load the program from a dictionary.
- measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None)
Wrapper method that combines an ADC trigger, a pulse, and (optionally) the appropriate wait and a sync_all. You must have already run set_pulse_registers for this channel.
If you use wait=True, it’s recommended to also specify a nonzero syncdelay.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int or list of int) – generator channel(s) (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – Pause tProc execution until the end of the ADC readout window
syncdelay (int, optional) – The number of additional tProc cycles to delay in the sync_all
- op_codes = {'!=': 5, '&': 0, '*': 10, '+': 8, '-': 9, '<': 2, '<<': 4, '<=': 3, '==': 4, '>': 0, '>=': 1, '>>': 5, '^': 2, 'lower': 5, 'upper': 10, '|': 1, '~': 3}
- prepare_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This sets up the round by preparing data structures and configuring the firmware, including arming the tProc for external start (if used).
The first round is prepared for you by acquire()/acquire_decimated()/run_rounds().
- print_sg_mem(sg_idx=0, gen_file=False)
Prints the content of the SG envelope table memory to be loaded in an RTL simulation. This assumes that the envelopes defined for this channel are contiguous in memory and start at address 0.
- pulse(ch, t='auto')
Play the pulse currently programmed into the registers for this generator channel. You must have already run set_pulse_registers for this channel.
- readout(ch, t)
Play the pulse currently programmed into the registers for this tProc-controlled readout channel. You must have already run set_readout_registers for this channel.
- reset_phase(gen_ch: Optional[Union[int, List[int]]] = None, ro_ch: Optional[Union[int, List[int]]] = None, t: int = 0)
Reset the phase of generator and tproc-controlled readout channels at tproc time t. This will play an empty pulse that lasts 3 fabric clock cycles, just to trigger the phase reset.
This command is designed to be transparent to previous ‘set_pulse/readout_registers()’ calls. i.e. the register values set using ‘set_pulse/readout_registers()’ before this command will remain the same after this command. However, pulse registers set using other functions will need to be re-set, e.g. if a pulse register value was set by directly calling ‘regwi()’, calling this function will overwrite that register value, and user need to redo the ‘regwi()’ after this phase reset.
- Parameters:
gen_ch – generator channel(s) to reset phase (index in ‘gens’ list)
ro_ch – tProc-controlled readout channel(s) to reset phase (index in ‘readouts’ list)
t – the number of tProc cycles at which the phase reset happens
- reset_timestamps(gen_t0=None)
- run(soc, load_prog=True, load_envelopes=True, start_src='internal')
Load the program into the tProcessor and start it. Because there is in general no way to tell when a program is done running, there is no guarantee that the program will be done before this method returns. If you want that guarantee, use run_rounds().
- Parameters:
soc (QickSoc) – The QickSoc that will execute this program.
load_prog (bool) – Load the program before starting the tProc.
load_envelopes (bool) – Load the generator envelopes before starting the tProc. If load_prog is False, load_envelopes is ignored.
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger).
- safe_regwi(rp, reg, imm, comment=None)
Due to the way the instructions are setup immediate values can only be 30bits before not loading properly. This comes up mostly when trying to regwi values into registers, especially the _frequency_ and _phase_ pulse registers. safe_regwi can be used wherever one might use regwi and will detect if the value is >2**30 and if so will break it into two steps, putting in the first 30 bits shifting it over and then adding the last two.
- set_pulse_registers(ch, **kwargs)
Set the pulse parameters including frequency, phase, address of pulse, gain, stdysel, mode register (compiled from length and other flags), outsel, and length. The time is scheduled when you call pulse(). See the write_regs() method of the relevant generator manager for the list of supported pulse styles.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
style (str) – Pulse style (“const”, “arb”, “flat_top”)
freq (int) – Frequency (register value)
phase (int) – Phase (register value)
gain (int) – Gain (DAC units)
phrst (int) – If 1, it resets the phase coherent accumulator
stdysel (str) – Selects what value is output continuously by the signal generator after the generation of a pulse. If “last”, it is the last calculated sample of the pulse. If “zero”, it is a zero value.
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If “product”, the output is the product of table and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the table for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles in the flat portion of the pulse, used for “const” and “flat_top” styles
waveform (str) – Name of the envelope waveform loaded with add_envelope(), used for “arb” and “flat_top” styles
mask (list of int) – for a muxed signal generator, the list of tones to enable for this pulse
- set_readout_registers(ch, **kwargs)
Set the readout parameters including frequency, mode, outsel, and length. The time is scheduled when you call readout().
- Parameters:
ch (int) – readout channel (index in ‘readouts’ list)
freq (int) – Frequency (register value)
phrst (int) – If 1, it resets the phase coherent accumulator
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. The input comes from the ADC and is purely real. If “product”, the output is the product of input and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the input for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles for which these readout parameters are defined.
- set_reads_per_shot(reads_per_shot)
Override the default count of readout triggers per shot. This should be called after setup_acquire(). You probably shouldn’t be using this method; the default value is usually correct.
- set_timestamp(val, gen_ch=None, ro_ch=None)
- setup_acquire(counter_addr, loop_dims, avg_level)
Set the parameters needed to define the data acquisition. Since the number of readouts per shot is set based on calls to trigger(), this should be called after the program has been fully defined.
- setup_and_measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None, **kwargs)
Set up a pulse on this generator channel, and immediately do a measurement with it. This is a wrapper around set_pulse_registers() and measure(), and takes the arguments from both. You can only run this on a single generator channel.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int) – generator channel (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – refer to measure()
syncdelay (int, optional) – refer to measure()
**kwargs (dict) – Pulse parameters: refer to set_pulse_registers()
- setup_and_pulse(ch, t='auto', **kwargs)
Set up a pulse on this generator channel, and immediately play it. This is a wrapper around set_pulse_registers() and pulse(), and takes the arguments from both. You can only run this on a single generator channel.
- setup_counter(counter_addr, loop_dims)
Set the parameters needed to track the progress of the program. This is a subset of setup_acquire(), appropriate for programs where you have no readouts. You should use this if you’re updating a tProc counter and want to use it to track program progress.
- soccfg_methods = ['freq2reg', 'freq2reg_adc', 'reg2freq', 'reg2freq_adc', 'cycles2us', 'us2cycles', 'deg2reg', 'reg2deg', 'roundfreq', 'get_maxv']
- sreg(gen_ch, name)
Gets tProc special register number associated with a generator channel and register name.
- sreg_ro(ro_ch, name)
Gets tProc special register number associated with a readout channel and register name.
- sync_all(t=0, gen_t0=None)
Sets the tProc reference time to the point where all generator pulses and readout windows are complete, plus additional time t. This does not pause the tProc. gen_t0 is an optional list of additional delays for each individual generator channel, e.g. when the channels are on different tiles so they don’t natively sync.
This does nothing if the firmware has no generators or readouts.
- trigger(adcs=None, pins=None, ddr4=False, mr=False, adc_trig_offset=270, t=0, width=10, rp=0, r_out=16)
Pulse the readout(s) and marker pin(s) with a specified pulse width at a specified time t+adc_trig_offset. If no readouts are specified, the adc_trig_offset is not applied.
- Parameters:
adcs (list of int) – List of readout channels to trigger (index in ‘readouts’ list)
pins (list of int) – List of marker pins to pulse. Use the pin numbers in the QickConfig printout.
ddr4 (bool) – If True, trigger the DDR4 buffer.
mr (bool) – If True, trigger the MR buffer.
adc_trig_offset (int, optional) – Offset time at which the ADC is triggered (in tProc cycles)
t (int, optional) – The number of tProc cycles at which the ADC trigger starts
width (int, optional) – The width of the trigger pulse, in tProc cycles
rp (int, optional) – Register page
r_out (int, optional) – Register number
- class qick.averager_program.AbsQickSweep(prog: QickProgram, label=None)[source]
Bases:
objectAbstract QickSweep class.
- __init__(prog: QickProgram, label=None)[source]
- Parameters:
prog – QickProgram in which the sweep will run.
label – label to be used for the loop tag in qick asm program.
- class qick.averager_program.QickSweep(prog: QickProgram, reg: QickRegister, start, stop, expts: int, label=None)[source]
Bases:
AbsQickSweepQickSweep class, describes a sweeps over a qick register.
- __init__(prog: QickProgram, reg: QickRegister, start, stop, expts: int, label=None)[source]
- Parameters:
prog – QickProgram in which the sweep happens.
reg – QickRegister object associated to the register to sweep.
start – start value of the register to sweep, in physical units
stop – stop value of the register to sweep, in physical units
expts – number of experiment points from start to stop value.
label – label to be used for the loop tag in qick asm program.
- qick.averager_program.merge_sweeps(sweeps: List[QickSweep]) AbsQickSweep[source]
create a new QickSweep object that merges the update and reset functions of multiple QickSweeps into one. This is useful when multiple registers need to be updated at the same time in one sweep. :param sweeps: list of “QickSweep”s :return:
- class qick.averager_program.NDAveragerProgram(soccfg, cfg)[source]
Bases:
QickRegisterManagerMixin,AcquireProgramNDAveragerProgram class, for experiments that sweep over multiple variables in qick. The order of experiment runs follow outer->inner: reps, sweep_n,… sweep_0.
- Parameters:
cfg (dict) – Configuration dictionary
- COUNTER_ADDR = 1
- __init__(soccfg, cfg)[source]
Constructor for the NDAveragerProgram. Make the ND sweep asm commands.
- initialize()[source]
Abstract method for initializing the program. Should include the instructions that will be executed once at the beginning of the qick program.
- ABSOLUTE_FREQS = False
- FLIP_DOWNCONVERSION = False
- GAUSS_BUG = True
- USER_DURATIONS = False
- acquire_decimated(soc, rounds=1, load_envelopes=True, start_src='internal', progress=True, remove_offset=True, step_rounds=False, extra_args=None)
Acquire data using the decimating readout.
- Parameters:
soc (QickSoc) – Qick object
rounds (int) – number of times to rerun the program, averaging results in software (aka “soft averages”)
load_envelopes (bool) – if True, load pulse envelopes and buffer weights
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – if true, displays progress bar
remove_offset (bool) – Subtract the readout’s IQ offset, if any.
step_rounds (bool) – Return after setting up the acquisition and preparing the first round. You will need to step through and complete the acquisition with prepare_round(), finish_round(), and finish_acquire().
extra_args (dict or None) – If the data-processing methods have been overriden and need extra arguments, those are supplied here and will be added to acquire_params.
- Returns:
decimated values, averaged over rounds (float) dimensions for a single-rep, single-read program : (length, 2) multi-rep or multi-read: (n_reps*n_reads, length, 2) multi-rep and multi-read: (n_reps, n_reads, length, 2)
- Return type:
- add_DRAG(ch, name, sigma, length, delta, alpha=0.5, det=0, maxv=None, even_length=False)
Adds a DRAG pulse to the envelope library. DRAG with constant detuning is implemented as defined in https://doi.org/10.1103/PhysRevLett.116.020501.
The envelope will peak at length/2.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float or float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
delta (float) – anharmonicity of the qubit, the difference between f_ge and f_ef (units of MHz)
alpha (float) – alpha parameter of DRAG (order-1 scale factor)
det (float) – constant detuning (units of MHz)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_cosine(ch, name, length, maxv=None, even_length=False)
Adds a cosine to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_envelope(ch, name, idata=None, qdata=None)
Adds a waveform to the list of envelope waveforms available for this channel. The I and Q arrays must be of equal length, and the length must be divisible by the samples-per-clock of this generator. If either array is omitted, zeros will be used for that component.
If this channel uses a real-only envelope, qdata must be omitted or all zeros.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray or None) – I data
qdata (numpy.ndarray or None) – Q data
- add_gauss(ch, name, sigma, length, maxv=None, even_length=False)
Adds a Gaussian to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
sigma (float) – Standard deviation of the Gaussian (in fabric clocks or us)
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- add_pulse(ch, name, idata=None, qdata=None)
Adds a waveform to the waveform library within the program.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the pulse
idata (numpy.ndarray) – I data, 16-bit
qdata (numpy.ndarray) – Q data, 16-bit
- add_sweep(sweep: AbsQickSweep)[source]
Add a layer of register sweep to the qick asm program. The order of sweeping will follow first added first sweep. :param sweep: :return:
- add_triangle(ch, name, length, maxv=None, even_length=False)
Adds a triangle to the envelope library. The envelope will peak at length/2. Duration units depend on the program type: tProc v1 programs use integer number of fabric clocks, tProc v2 programs use float us.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
name (str) – Name of the envelope
length (int or float) – Total envelope length (in fabric clocks or us)
maxv (float) – Value at the peak (if None, the max value for this generator will be used)
even_length (bool) – If length is in us, round the envelope length to an even number of fabric clock cycles. This is useful for flat_top pulses, where the envelope gets split into two halves.
- append_instruction(name, *args)
Append instruction to the program list
- asm()
Returns assembly representation of program as string, should be compatible with the parse_prog from the parser module.
- Returns:
asm file
- Return type:
- bin()
Returns binary representation of program as string.
- Returns:
Compiled program in binary format
- Return type:
- ch_page(gen_ch)
Gets tProc register page associated with generator channel.
- ch_page_ro(ro_ch)
Gets tProc register page associated with tProc-controlled readout channel.
- compare_program(fname)
For debugging purposes to compare binary compilation of parse_prog with the compile.
- compile(debug=False)
Compiles program to machine code.
- compile_instruction(inst, labels, debug=False)
Converts an assembly instruction into a machine bytecode.
- config_all(soc, load_envelopes=True, reset=False, load_mem=True)
Load the waveform memory, gens, ROs, and program memory as specified for this program. The decimated+accumulated buffers are not configured, since those should be re-configured for each acquisition. The tProc is set to internal start before any other configuration is done, to prevent spurious external starts.
- Parameters:
reset (bool) – Force-stop the tProc before loading the program. This option only affects tProc v1, where the reset takes several ms. For tProc v2, where reset is easy, we always do the reset.
- config_bufs(soc, enable_avg=True, enable_buf=True)
Configure the readout buffers specified in this program. This is usually called as part of an acquire() method.
- config_gens(soc)
Configure the signal generators specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- config_readouts(soc)
Configure the readout channels specified in this program. This is usually called as part of an acquire() method.
- Parameters:
soc (QickSoc) – the QickSoc that will execute this program
- convert_immediate(val)
Convert the register value to ensure that it is positive and not too large. Throws an error if you ever try to use a value greater than 2**31 as an immediate value.
- declare_gen(ch, nqz=1, mixer_freq=None, mixer_fullscale=False, mux_freqs=None, mux_gains=None, mux_phases=None, ro_ch=None)
Add a channel to the program’s list of signal generators.
If this is a generator with a mixer (interpolated or muxed generator), you may define a mixer frequency.
If this is a muxed generator, the mux_freqs list must be long enough to define all the tones you will play. (in other words, if your mask list ever enables tone 2 you must define at least 3 freqs+gains) If your mux gen supports gains and/or phases and you define them, those lists must be the same length. If you don’t define gains or phases, they will be set to defaults (max positive gain, zero phase).
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
nqz (int, optional) – Nyquist zone (must be 1 or 2). Setting the NQZ to 2 increases output power in the 2nd/3rd Nyquist zones.
mixer_freq (float, optional) – Mixer frequency (in MHz)
mixer_fullscale (bool) – DACs with mixers have a built-in scale factor of 0.7 to prevent overflow (see https://docs.amd.com/r/en-US/pg269-rf-data-converter/RF-DAC-Numerical-Controlled-Oscillator-and-Mixer). If this is set to True, the scale factor will be bypassed and you will get the full DAC range.
mux_freqs (list of float, optional) – Tone frequencies for the muxed generator (in MHz). For tProc v1 programs these should be given as offsets relative to the digital mixer frequency. For tProc v2 they should be given as absolute frequencies. Positive and negative values are allowed.
mux_gains (list of float, optional) – Tone amplitudes for the muxed generator (in range -1 to 1).
mux_phases (list of float, optional) – Phases for the muxed generator (in degrees).
ro_ch (int, optional) – readout channel for frequency-matching mixer and mux freqs
- declare_readout(ch, length, freq=None, phase=0, sel='product', gen_ch=None, edge_counting=False, high_threshold=0, low_threshold=0, weights=None)
Add a channel to the program’s list of readouts. Duration units depend on the program type: tProc v1 programs use integer number of samples, tProc v2 programs use float us.
- Parameters:
ch (int) – readout channel number (index in ‘readouts’ list)
freq (float) – downconverting frequency (MHz)
phase (float) – phase (degrees)
length (int or float) – readout length (number of decimated samples for tProc v1, us for tProc v2)
sel (str) – output select (‘product’, ‘dds’, ‘input’)
gen_ch (int) – generator channel (use None if you don’t want the downconversion frequency to be rounded to a valid DAC frequency or be offset by the DAC mixer frequency)
edge_counting (bool) – Sets edge counting mode on or off
high_threshold (int) – Sets the edge counting threshold level to go above to trigger a single count
low_threshold (int) – Sets the edge counting threshold level to go below to reset the trigger for next count
weights (numpy.ndarray) – Array of int16, shape (N, 2), representing an IQ array by which to multiply the readout window. Can only be used if this readout channel has a weighted buffer. If left as None, the weights will be set to [2**15-2, 0] (the maximum positive real value). If used, N must equal the number of decimated samples in the readout window.
- decrement_timestamps(t)
- default_pulse_registers(ch, **kwargs)
Set default values for pulse parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_pulse_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_pulse_registers.
- default_readout_registers(ch, **kwargs)
Set default values for readout parameters. If any registers can be written at this point, write them in order to save time later.
This is optional (you can set all parameters in set_readout_registers). You can only call this method once per channel. There cannot be any overlap between the parameters defined here and the parameters you define in set_readout_registers.
- dump_prog()
Dump the program to a dictionary. This output contains all the information necessary to run the program. In other words, it will have the low-level ASM and pulse+envelope data, but not higher-level structures. Caution: don’t modify the sub-dictionaries of this dict! You will be modifying the original program (this is not a deep copy).
- finish_acquire()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
- Returns:
Data in the same format that would be returned by acquire()/acquire_decimated().
- Return type:
- finish_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This runs the round by starting the tProc (if using internal start), then collecting and processing the data.
- Returns:
True if more rounds remain to be run. This is meant to be used to control a while loop.
- Return type:
- gentypes = {'axis_sg_int4_v1': <class 'qick.asm_v1.InterpolatedGenManager'>, 'axis_sg_mux4_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v2': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux4_v3': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_sg_mux8_v1': <class 'qick.asm_v1.MultiplexedGenManager'>, 'axis_signal_gen_v4': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v5': <class 'qick.asm_v1.FullSpeedGenManager'>, 'axis_signal_gen_v6': <class 'qick.asm_v1.FullSpeedGenManager'>}
- get_gen_reg(gen_ch: int, name: str) QickRegister
Gets tProc register page and address associated with gen_ch and register name. Creates a QickRegister object for return.
- Parameters:
gen_ch – generator channel number
name – name of the qick register, as in QickProgram.pulse_registers
- Returns:
QickRegister
- get_max_timestamp(gens=True, ros=True, gen_t0=None)
Calculate the max timestamp among the specified channels.
- get_raw()
Get the raw integer I/Q values (before normalizing to the readout window, averaging across reps, removing the readout offset, or thresholding). This can be called after acquire().
- Returns:
Array of I/Q values for each readout channel. The array dimensions correspond to the loop dimensions, data is in time order.
- Return type:
- get_rounds()
Get the results from each round, before averaging over rounds. This can be called after acquire() or acquire_decimated().
- Returns:
Array of I/Q values for each readout channel. Same dimensions as the return value from acquire()/acquire_decimated().
- Return type:
- get_shots()
Get the shot-by-shot threshold decisions. This can be called after acquire().
- Returns:
Array of shots for each readout channel.
- Return type:
- get_time_axis(ro_index, length_only=False)
Get an array usable as the time axis for plotting decimated data.
- Parameters:
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample. If length_only=True, an int is returned.
- Return type:
numpy.ndarray of float, or int
- get_time_axis_ddr4(ro_ch, data)
Get an array usable as the time axis for plotting DDR4 data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – DDR4 data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per decimated sample.
- Return type:
- get_time_axis_mr(ro_ch, data)
Get an array usable as the time axis for plotting MR data.
- Parameters:
ro_ch (int) – readout channel (index in ‘readouts’ list)
data (numpy.ndarray) – MR data array, the returned array will have the same length.
- Returns:
An array starting at 0 and spaced by the time (in us) per MR sample.
- Return type:
- get_timestamp(gen_ch=None, ro_ch=None)
- hex()
Returns hex representation of program as string.
- Returns:
Compiled program in hex format
- Return type:
- instructions = {'bitw': {'bin': 85, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'bitwi': {'bin': 22, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'comment': {'fmt': ()}, 'condj': {'bin': 49, 'fmt': ((0, 53), (2, 46), (1, 36), (3, 31), (4, 0)), 'repr': '{0}, ${1}, {2}, ${3}, @{4}', 'type': 'J2'}, 'end': {'bin': 63, 'fmt': (), 'repr': '', 'type': 'J1'}, 'loopnz': {'bin': 48, 'fmt': ((0, 53), (1, 41), (1, 36), (2, 0)), 'repr': '{0}, ${1}, @{2}', 'type': 'J1'}, 'math': {'bin': 80, 'fmt': ((0, 53), (3, 46), (1, 41), (2, 36), (4, 31)), 'repr': '{0}, ${1}, ${2} {3} ${4}', 'type': 'R'}, 'mathi': {'bin': 18, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 46), (4, 0)), 'repr': '{0}, ${1}, ${2} {3} {4}', 'type': 'I'}, 'memr': {'bin': 86, 'fmt': ((0, 53), (1, 41), (2, 36)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memri': {'bin': 23, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'memw': {'bin': 87, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'memwi': {'bin': 24, 'fmt': ((0, 53), (1, 31), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'popi': {'bin': 17, 'fmt': ((0, 53), (1, 41)), 'repr': '{0}, ${1}', 'type': 'I'}, 'pushi': {'bin': 16, 'fmt': ((0, 53), (1, 41), (2, 36), (3, 0)), 'repr': '{0}, ${1}, ${2}, {3}', 'type': 'I'}, 'read': {'bin': 83, 'fmt': ((1, 53), (0, 50), (2, 46), (3, 41)), 'repr': '{0}, {1}, {2} ${3}', 'type': 'R'}, 'regwi': {'bin': 25, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'set': {'bin': 81, 'fmt': ((1, 53), (0, 50), (2, 36), (7, 31), (3, 26), (4, 21), (5, 16), (6, 11)), 'repr': '{0}, {1}, ${2}, ${3}, ${4}, ${5}, ${6}, ${7}', 'type': 'R'}, 'setb': {'bin': 88, 'fmt': ((0, 53), (2, 36), (1, 31)), 'repr': '{0}, ${1}, ${2}', 'type': 'R'}, 'setbi': {'bin': 26, 'fmt': ((0, 53), (1, 41), (2, 0)), 'repr': '{0}, ${1}, {2}', 'type': 'I'}, 'seti': {'bin': 19, 'fmt': ((1, 53), (0, 50), (2, 36), (3, 0)), 'repr': '{0}, {1}, ${2}, {3}', 'type': 'I'}, 'sync': {'bin': 82, 'fmt': ((0, 53), (1, 31)), 'repr': '{0}, ${1}', 'type': 'R'}, 'synci': {'bin': 20, 'fmt': ((0, 0),), 'repr': '{0}', 'type': 'I'}, 'wait': {'bin': 84, 'fmt': ((1, 53), (0, 50), (2, 31)), 'repr': '{0}, {1}, ${2}', 'type': 'R'}, 'waiti': {'bin': 21, 'fmt': ((0, 50), (1, 0)), 'repr': '{0}, {1}', 'type': 'I'}}
- label(name)
Add line number label to the labels dictionary. This labels the instruction by its position in the program list. The loopz and condj commands use this label information.
- Parameters:
name (str) – Label name
- load_envelopes(soc)
Loads envelopes that were added using add_envelope into the SoC’s signal generator memories. Also load weight arrays for weighted buffers.
- Parameters:
soc (QickSoc) – Qick object
- load_prog(progdict)
Load the program from a dictionary.
- measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None)
Wrapper method that combines an ADC trigger, a pulse, and (optionally) the appropriate wait and a sync_all. You must have already run set_pulse_registers for this channel.
If you use wait=True, it’s recommended to also specify a nonzero syncdelay.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int or list of int) – generator channel(s) (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – Pause tProc execution until the end of the ADC readout window
syncdelay (int, optional) – The number of additional tProc cycles to delay in the sync_all
- new_gen_reg(gen_ch: int, name: Optional[str] = None, init_val=None, reg_type: Optional[str] = None, tproc_reg=False) QickRegister
Declare a new register in the generator register page. Address automatically adds 1 one when each time a new register in the same page is declared.
- Parameters:
gen_ch – generator channel number
name – name of the new register. Optional.
init_val – initial value for the register, when reg_type is provided, the reg_val should be in the unit of the corresponding type.
reg_type – {“freq”, “time”, “phase”, “adc_freq”} or None, type of the register.
tproc_reg – if True, the new register created will not be associated to a specific generator or readout channel. It will still be on the same page as the gen_ch for math calculations. This is usually used for a time register in t_processor, where we want to calculate “us2cycles” with the t_proc fabric clock rate instead of the generator clock rate.
- Returns:
QickRegister
- new_reg(page: int, addr: Optional[int] = None, name: Optional[str] = None, init_val=None, reg_type: Optional[str] = None, gen_ch: Optional[int] = None, ro_ch: Optional[int] = None)
Declare a new register in a specific page.
- Parameters:
page – register page
addr – address of the new register. If None, the function will automatically try to find the next available address.
name – name of the new register. Optional.
init_val – initial value for the register, when reg_type is provided, the reg_val should be in the physical unit of the corresponding type. i.e. freq in MHz, time in us, phase in deg.
reg_type – {“freq”, “time”, “phase”, “adc_freq”} or None, type of the register
gen_ch – generator channel numer to which the register is associated with, for unit convert.
ro_ch – readout channel numer to which the register is associated with, for unit convert.
- Returns:
QickRegister
- op_codes = {'!=': 5, '&': 0, '*': 10, '+': 8, '-': 9, '<': 2, '<<': 4, '<=': 3, '==': 4, '>': 0, '>=': 1, '>>': 5, '^': 2, 'lower': 5, 'upper': 10, '|': 1, '~': 3}
- prepare_round()
Used with the step_rounds argument to acquire()/acquire_decimated()/run_rounds().
This sets up the round by preparing data structures and configuring the firmware, including arming the tProc for external start (if used).
The first round is prepared for you by acquire()/acquire_decimated()/run_rounds().
- print_sg_mem(sg_idx=0, gen_file=False)
Prints the content of the SG envelope table memory to be loaded in an RTL simulation. This assumes that the envelopes defined for this channel are contiguous in memory and start at address 0.
- pulse(ch, t='auto')
Play the pulse currently programmed into the registers for this generator channel. You must have already run set_pulse_registers for this channel.
- readout(ch, t)
Play the pulse currently programmed into the registers for this tProc-controlled readout channel. You must have already run set_readout_registers for this channel.
- reset_phase(gen_ch: Optional[Union[int, List[int]]] = None, ro_ch: Optional[Union[int, List[int]]] = None, t: int = 0)
Reset the phase of generator and tproc-controlled readout channels at tproc time t. This will play an empty pulse that lasts 3 fabric clock cycles, just to trigger the phase reset.
This command is designed to be transparent to previous ‘set_pulse/readout_registers()’ calls. i.e. the register values set using ‘set_pulse/readout_registers()’ before this command will remain the same after this command. However, pulse registers set using other functions will need to be re-set, e.g. if a pulse register value was set by directly calling ‘regwi()’, calling this function will overwrite that register value, and user need to redo the ‘regwi()’ after this phase reset.
- Parameters:
gen_ch – generator channel(s) to reset phase (index in ‘gens’ list)
ro_ch – tProc-controlled readout channel(s) to reset phase (index in ‘readouts’ list)
t – the number of tProc cycles at which the phase reset happens
- reset_timestamps(gen_t0=None)
- run(soc, load_prog=True, load_envelopes=True, start_src='internal')
Load the program into the tProcessor and start it. Because there is in general no way to tell when a program is done running, there is no guarantee that the program will be done before this method returns. If you want that guarantee, use run_rounds().
- Parameters:
soc (QickSoc) – The QickSoc that will execute this program.
load_prog (bool) – Load the program before starting the tProc.
load_envelopes (bool) – Load the generator envelopes before starting the tProc. If load_prog is False, load_envelopes is ignored.
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger).
- safe_regwi(rp, reg, imm, comment=None)
Due to the way the instructions are setup immediate values can only be 30bits before not loading properly. This comes up mostly when trying to regwi values into registers, especially the _frequency_ and _phase_ pulse registers. safe_regwi can be used wherever one might use regwi and will detect if the value is >2**30 and if so will break it into two steps, putting in the first 30 bits shifting it over and then adding the last two.
- set_pulse_registers(ch, **kwargs)
Set the pulse parameters including frequency, phase, address of pulse, gain, stdysel, mode register (compiled from length and other flags), outsel, and length. The time is scheduled when you call pulse(). See the write_regs() method of the relevant generator manager for the list of supported pulse styles.
- Parameters:
ch (int) – generator channel (index in ‘gens’ list)
style (str) – Pulse style (“const”, “arb”, “flat_top”)
freq (int) – Frequency (register value)
phase (int) – Phase (register value)
gain (int) – Gain (DAC units)
phrst (int) – If 1, it resets the phase coherent accumulator
stdysel (str) – Selects what value is output continuously by the signal generator after the generation of a pulse. If “last”, it is the last calculated sample of the pulse. If “zero”, it is a zero value.
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If “product”, the output is the product of table and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the table for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles in the flat portion of the pulse, used for “const” and “flat_top” styles
waveform (str) – Name of the envelope waveform loaded with add_envelope(), used for “arb” and “flat_top” styles
mask (list of int) – for a muxed signal generator, the list of tones to enable for this pulse
- set_readout_registers(ch, **kwargs)
Set the readout parameters including frequency, mode, outsel, and length. The time is scheduled when you call readout().
- Parameters:
ch (int) – readout channel (index in ‘readouts’ list)
freq (int) – Frequency (register value)
phrst (int) – If 1, it resets the phase coherent accumulator
mode (str) – Selects whether the output is “oneshot” or “periodic”
outsel (str) – Selects the output source. The output is complex. The input comes from the ADC and is purely real. If “product”, the output is the product of input and DDS. If “dds”, the output is the DDS only. If “input”, the output is from the input for the real part, and zeros for the imaginary part. If “zero”, the output is always zero.
length (int) – The number of fabric clock cycles for which these readout parameters are defined.
- set_reads_per_shot(reads_per_shot)
Override the default count of readout triggers per shot. This should be called after setup_acquire(). You probably shouldn’t be using this method; the default value is usually correct.
- set_timestamp(val, gen_ch=None, ro_ch=None)
- setup_acquire(counter_addr, loop_dims, avg_level)
Set the parameters needed to define the data acquisition. Since the number of readouts per shot is set based on calls to trigger(), this should be called after the program has been fully defined.
- setup_and_measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None, **kwargs)
Set up a pulse on this generator channel, and immediately do a measurement with it. This is a wrapper around set_pulse_registers() and measure(), and takes the arguments from both. You can only run this on a single generator channel.
- Parameters:
adcs (list of int) – readout channels (index in ‘readouts’ list)
pulse_ch (int) – generator channel (index in ‘gens’ list)
adc_trig_offset (int, optional) – refer to trigger()
t (int, optional) – refer to pulse()
wait (bool, optional) – refer to measure()
syncdelay (int, optional) – refer to measure()
**kwargs (dict) – Pulse parameters: refer to set_pulse_registers()
- setup_and_pulse(ch, t='auto', **kwargs)
Set up a pulse on this generator channel, and immediately play it. This is a wrapper around set_pulse_registers() and pulse(), and takes the arguments from both. You can only run this on a single generator channel.
- setup_counter(counter_addr, loop_dims)
Set the parameters needed to track the progress of the program. This is a subset of setup_acquire(), appropriate for programs where you have no readouts. You should use this if you’re updating a tProc counter and want to use it to track program progress.
- soccfg_methods = ['freq2reg', 'freq2reg_adc', 'reg2freq', 'reg2freq_adc', 'cycles2us', 'us2cycles', 'deg2reg', 'reg2deg', 'roundfreq', 'get_maxv']
- sreg(gen_ch, name)
Gets tProc special register number associated with a generator channel and register name.
- sreg_ro(ro_ch, name)
Gets tProc special register number associated with a readout channel and register name.
- sync_all(t=0, gen_t0=None)
Sets the tProc reference time to the point where all generator pulses and readout windows are complete, plus additional time t. This does not pause the tProc. gen_t0 is an optional list of additional delays for each individual generator channel, e.g. when the channels are on different tiles so they don’t natively sync.
This does nothing if the firmware has no generators or readouts.
- trigger(adcs=None, pins=None, ddr4=False, mr=False, adc_trig_offset=270, t=0, width=10, rp=0, r_out=16)
Pulse the readout(s) and marker pin(s) with a specified pulse width at a specified time t+adc_trig_offset. If no readouts are specified, the adc_trig_offset is not applied.
- Parameters:
adcs (list of int) – List of readout channels to trigger (index in ‘readouts’ list)
pins (list of int) – List of marker pins to pulse. Use the pin numbers in the QickConfig printout.
ddr4 (bool) – If True, trigger the DDR4 buffer.
mr (bool) – If True, trigger the MR buffer.
adc_trig_offset (int, optional) – Offset time at which the ADC is triggered (in tProc cycles)
t (int, optional) – The number of tProc cycles at which the ADC trigger starts
width (int, optional) – The width of the trigger pulse, in tProc cycles
rp (int, optional) – Register page
r_out (int, optional) – Register number
- wait_all(t=0)
Pause the tProc until all readout windows are complete, plus additional time t. This does not increment the tProc reference time.
This does nothing if the firmware has no readouts.
- Parameters:
t (int, optional) – The time offset in tProc cycles
- make_program()[source]
Make the N dimensional sweep program. The program will run initialize once at the beginning, then iterate over all the sweep parameters and run the body. The whole sweep will repeat for cfg[“reps”] number of times.
- acquire(soc, readouts_per_experiment=None, save_experiments: Optional[List] = None, load_pulses=True, **kwargs)[source]
This method optionally loads pulses on to the SoC, configures the ADC readouts, loads the machine code representation of the AveragerProgram onto the SoC, starts the program and streams the data into the Python, returning it as a set of numpy arrays. Note here the buf data has “reps” as the outermost axis, and the first swept parameter corresponds to the innermost axis.
config requirements: “reps” = number of repetitions;
- Parameters:
soc – Qick object
threshold – threshold
angle – rotation angle
readouts_per_experiment – readouts per experiment
save_experiments – saved readouts (by default, save all readouts)
load_pulses – If true, loads pulses into the tProc
start_src – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress – If true, displays progress bar
- Returns:
- run_rounds(soc, readouts_per_experiment=None, load_pulses=True, **kwargs)[source]
Run the program and wait until it completes, once or multiple times. No data will be saved.
- Parameters:
soc (QickSoc) – Qick object
load_pulses (bool) – if True, load pulse envelopes and buffer weights
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
progress (bool) – if true, displays progress bar
step_rounds (bool) – Return after setting up and preparing the first round. You will need to step through and complete the acquisition with prepare_round(), finish_round(), and finish_acquire().