qick.asm_v1
Assembly language wrapper class and auxiliary functions for the v1 tProcessor.
Classes
|
Manages the envelope and pulse information for a signal generator channel. |
|
Generic class for managing registers that will be written to a tProc-controlled block (signal generator or readout). |
|
Base class for tProc v1 programs with shot counting and readout acquisition. |
|
Manager for the full-speed (non-interpolated, non-muxed) signal generators. |
|
Manager for the interpolated signal generators. |
|
Manager for the muxed signal generators. |
|
QickProgram is a Python representation of the QickSoc processor assembly program. |
|
A qick register object that keeps the page, address, generator/readout channel and register type information, provides functions that make it easier to set register value given input values in physical units. |
|
A mixin class for QickProgram that provides manager functions for getting and declaring new qick registers. |
|
Manages the frequency and mode registers for a tProc-controlled readout channel. |
- class qick.asm_v1.AbsRegisterManager(prog, tproc_ch, ch_name)[source]
Bases:
ABCGeneric class for managing registers that will be written to a tProc-controlled block (signal generator or readout).
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- set_reg(name, val, comment=None, defaults=False)[source]
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- set_defaults(kwargs)[source]
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- class qick.asm_v1.ReadoutManager(prog, ro_ch)[source]
Bases:
AbsRegisterManagerManages the frequency and mode registers for a tProc-controlled readout channel.
- PARAMS_REQUIRED = ['freq', 'length']
- PARAMS_OPTIONAL = ['phrst', 'mode', 'outsel']
- check_params(params)[source]
Check whether the parameters defined for a pulse are supported and sufficient for this generator and pulse type. Raise an exception if there is a problem.
- Parameters:
params (dict) – Parameter values
- get_mode_code(length, outsel=None, mode=None, phrst=None)[source]
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters:
length (int) – The number of ADC fabric cycles in the pulse
outsel (str) –
Selects the output source. The output is complex. Tables define envelopes for I and Q. The default is “product”.
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.
mode (str) – Selects whether the output is “oneshot” or “periodic”. The default is “oneshot”.
phrst (int) – If 1, it resets the phase coherent accumulator. The default is 0.
- Returns:
Compiled mode code in binary
- Return type:
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- set_defaults(kwargs)
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- set_reg(name, val, comment=None, defaults=False)
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- class qick.asm_v1.AbsGenManager(prog, gen_ch)[source]
Bases:
AbsRegisterManagerManages the envelope and pulse information for a signal generator channel.
- PARAMS_REQUIRED = {}
- PARAMS_OPTIONAL = {}
- check_params(params)[source]
Check whether the parameters defined for a pulse are supported and sufficient for this generator and pulse type. Raise an exception if there is a problem.
- Parameters:
params (dict) – Parameter values
- get_mode_code(length, mode=None, outsel=None, stdysel=None, phrst=None)[source]
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters:
length (int) – The number of DAC fabric cycles in the pulse
mode (str) – Selects whether the output is “oneshot” or “periodic”. The default is “oneshot”.
outsel (str) –
Selects the output source. The output is complex. Tables define envelopes for I and Q. The default is “product”.
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.
stdysel (str) –
Selects what value is output continuously by the signal generator after the generation of a pulse. The default is “zero”.
If “last”, it is the last calculated sample of the pulse.
If “zero”, it is a zero value.
phrst (int) – If 1, it resets the phase coherent accumulator. The default is 0.
- Returns:
Compiled mode code in binary
- Return type:
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- set_defaults(kwargs)
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- set_reg(name, val, comment=None, defaults=False)
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- set_registers(kwargs)
Set pulse parameters. This is called by QickProgram.set_pulse_registers().
- Parameters:
kwargs (dict) – Parameter values
- abstract write_regs(params, defaults)
- class qick.asm_v1.FullSpeedGenManager(prog, gen_ch)[source]
Bases:
AbsGenManagerManager for the full-speed (non-interpolated, non-muxed) signal generators.
- PARAMS_REQUIRED = {'arb': ['style', 'freq', 'phase', 'gain', 'waveform'], 'const': ['style', 'freq', 'phase', 'gain', 'length'], 'flat_top': ['style', 'freq', 'phase', 'gain', 'length', 'waveform']}
- PARAMS_OPTIONAL = {'arb': ['phrst', 'stdysel', 'mode', 'outsel'], 'const': ['phrst', 'stdysel', 'mode'], 'flat_top': ['phrst', 'stdysel']}
- write_regs(params, defaults)[source]
Write whichever pulse registers are fully determined by the defined parameters.
The following pulse styles are supported:
const: A constant (rectangular) pulse. There is no outsel setting for this pulse style; “dds” is always used.
arb: An arbitrary-envelope pulse.
flat_top: A flattop pulse with arbitrary ramps. The waveform is played in three segments: ramp up, flat, and ramp down. To use these pulses one should use add_envelope to add the ramp waveform which should go from 0 to maxamp and back down to zero with the up and down having the same length, the first half will be used as the ramp up and the second half will be used as the ramp down.
If the waveform is not of even length, the middle sample will be skipped. It’s recommended to use an even-length waveform with flat_top.
There is no outsel setting for flat_top; the ramps always use “product” and the flat segment always uses “dds”. There is no mode setting; it is always “oneshot”.
- Parameters:
params (dict) – Pulse parameters
defaults – These are default values, which don’t need to be rewritten for every pulse
- get_mode_code(**kwargs)[source]
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters:
length (int) – The number of DAC fabric cycles in the pulse
mode (str) – Selects whether the output is “oneshot” or “periodic”. The default is “oneshot”.
outsel (str) –
Selects the output source. The output is complex. Tables define envelopes for I and Q. The default is “product”.
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.
stdysel (str) –
Selects what value is output continuously by the signal generator after the generation of a pulse. The default is “zero”.
If “last”, it is the last calculated sample of the pulse.
If “zero”, it is a zero value.
phrst (int) – If 1, it resets the phase coherent accumulator. The default is 0.
- Returns:
Compiled mode code in binary
- Return type:
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- __init__(prog, gen_ch)
- check_params(params)
Check whether the parameters defined for a pulse are supported and sufficient for this generator and pulse type. Raise an exception if there is a problem.
- Parameters:
params (dict) – Parameter values
- set_defaults(kwargs)
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- set_reg(name, val, comment=None, defaults=False)
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- class qick.asm_v1.InterpolatedGenManager(prog, gen_ch)[source]
Bases:
AbsGenManagerManager for the interpolated signal generators.
- PARAMS_REQUIRED = {'arb': ['style', 'freq', 'phase', 'gain', 'waveform'], 'const': ['style', 'freq', 'phase', 'gain', 'length'], 'flat_top': ['style', 'freq', 'phase', 'gain', 'length', 'waveform']}
- PARAMS_OPTIONAL = {'arb': ['phrst', 'stdysel', 'mode', 'outsel'], 'const': ['phrst', 'stdysel', 'mode'], 'flat_top': ['phrst', 'stdysel']}
- write_regs(params, defaults)[source]
Write whichever pulse registers are fully determined by the defined parameters.
The following pulse styles are supported:
const: A constant (rectangular) pulse. There is no outsel setting for this pulse style; “dds” is always used.
arb: An arbitrary-envelope pulse.
flat_top: A flattop pulse with arbitrary ramps. The waveform is played in three segments: ramp up, flat, and ramp down. To use these pulses one should use add_envelope to add the ramp waveform which should go from 0 to maxamp and back down to zero with the up and down having the same length, the first half will be used as the ramp up and the second half will be used as the ramp down.
If the waveform is not of even length, the middle sample will be skipped. It’s recommended to use an even-length waveform with flat_top.
There is no outsel setting for flat_top; the ramps always use “product” and the flat segment always uses “dds”. There is no mode setting; it is always “oneshot”.
- Parameters:
params (dict) – Pulse parameters
defaults – These are default values, which don’t need to be rewritten for every pulse
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- __init__(prog, gen_ch)
- check_params(params)
Check whether the parameters defined for a pulse are supported and sufficient for this generator and pulse type. Raise an exception if there is a problem.
- Parameters:
params (dict) – Parameter values
- get_mode_code(length, mode=None, outsel=None, stdysel=None, phrst=None)
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters:
length (int) – The number of DAC fabric cycles in the pulse
mode (str) – Selects whether the output is “oneshot” or “periodic”. The default is “oneshot”.
outsel (str) –
Selects the output source. The output is complex. Tables define envelopes for I and Q. The default is “product”.
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.
stdysel (str) –
Selects what value is output continuously by the signal generator after the generation of a pulse. The default is “zero”.
If “last”, it is the last calculated sample of the pulse.
If “zero”, it is a zero value.
phrst (int) – If 1, it resets the phase coherent accumulator. The default is 0.
- Returns:
Compiled mode code in binary
- Return type:
- set_defaults(kwargs)
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- set_reg(name, val, comment=None, defaults=False)
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- class qick.asm_v1.MultiplexedGenManager(prog, gen_ch)[source]
Bases:
AbsGenManagerManager for the muxed signal generators.
- PARAMS_REQUIRED = {'const': ['style', 'mask', 'length']}
- PARAMS_OPTIONAL = {'const': []}
- write_regs(params, defaults)[source]
Write whichever pulse registers are fully determined by the defined parameters.
Only the “const” pulse style, with the “mask” and “length” parameters, is supported. The frequency and gain are set at program initialization.
- Parameters:
params (dict) – Pulse parameters
defaults – These are default values, which don’t need to be rewritten for every pulse
- PULSE_REGISTERS = ['freq', 'phase', 'addr', 'gain', 'mode', 't', 'addr2', 'gain2', 'mode2', 'mode3']
- __init__(prog, gen_ch)
- check_params(params)
Check whether the parameters defined for a pulse are supported and sufficient for this generator and pulse type. Raise an exception if there is a problem.
- Parameters:
params (dict) – Parameter values
- get_mode_code(length, mode=None, outsel=None, stdysel=None, phrst=None)
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters:
length (int) – The number of DAC fabric cycles in the pulse
mode (str) – Selects whether the output is “oneshot” or “periodic”. The default is “oneshot”.
outsel (str) –
Selects the output source. The output is complex. Tables define envelopes for I and Q. The default is “product”.
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.
stdysel (str) –
Selects what value is output continuously by the signal generator after the generation of a pulse. The default is “zero”.
If “last”, it is the last calculated sample of the pulse.
If “zero”, it is a zero value.
phrst (int) – If 1, it resets the phase coherent accumulator. The default is 0.
- Returns:
Compiled mode code in binary
- Return type:
- set_defaults(kwargs)
Set default values for parameters. This is called by QickProgram.set_default_registers().
- Parameters:
kwargs (dict) – Parameter values
- set_reg(name, val, comment=None, defaults=False)
Wrapper around regwi. Looks up the register name and keeps track of whether the register already has a default value.
- class qick.asm_v1.QickProgram(soccfg)[source]
Bases:
AbsQickProgramQickProgram is a Python representation of the QickSoc processor assembly program. It can be used to compile simple assembly programs and also contains macros to help make it easy to configure and schedule pulses.
- 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'}}
- op_codes = {'!=': 5, '&': 0, '*': 10, '+': 8, '-': 9, '<': 2, '<<': 4, '<=': 3, '==': 4, '>': 0, '>=': 1, '>>': 5, '^': 2, 'lower': 5, 'upper': 10, '|': 1, '~': 3}
- 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'>}
- GAUSS_BUG = True
- sreg(gen_ch, name)[source]
Gets tProc special register number associated with a generator channel and register name.
- ch_page_ro(ro_ch)[source]
Gets tProc register page associated with tProc-controlled readout channel.
- sreg_ro(ro_ch, name)[source]
Gets tProc special register number associated with a readout channel and register name.
- add_pulse(ch, name, idata=None, qdata=None)[source]
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
- default_pulse_registers(ch, **kwargs)[source]
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.
- set_pulse_registers(ch, **kwargs)[source]
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)[source]
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.
- default_readout_registers(ch, **kwargs)[source]
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.
- readout(ch, t)[source]
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.
- setup_and_pulse(ch, t='auto', **kwargs)[source]
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_and_measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None, **kwargs)[source]
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()
- pulse(ch, t='auto')[source]
Play the pulse currently programmed into the registers for this generator channel. You must have already run set_pulse_registers for this channel.
- safe_regwi(rp, reg, imm, comment=None)[source]
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.
- sync_all(t=0, gen_t0=None)[source]
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.
- wait_all(t=0)[source]
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
- trigger(adcs=None, pins=None, ddr4=False, mr=False, adc_trig_offset=270, t=0, width=10, rp=0, r_out=16)[source]
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
- measure(adcs, pulse_ch, pins=None, adc_trig_offset=270, t='auto', wait=False, syncdelay=None)[source]
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
- reset_phase(gen_ch: Optional[Union[int, List[int]]] = None, ro_ch: Optional[Union[int, List[int]]] = None, t: int = 0)[source]
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
- convert_immediate(val)[source]
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.
- compile_instruction(inst, labels, debug=False)[source]
Converts an assembly instruction into a machine bytecode.
- label(name)[source]
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
- hex()[source]
Returns hex representation of program as string.
- Returns:
Compiled program in hex format
- Return type:
- bin()[source]
Returns binary representation of program as string.
- Returns:
Compiled program in binary format
- Return type:
- asm()[source]
Returns assembly representation of program as string, should be compatible with the parse_prog from the parser module.
- Returns:
asm file
- Return type:
- compare_program(fname)[source]
For debugging purposes to compare binary compilation of parse_prog with the compile.
- ABSOLUTE_FREQS = False
- FLIP_DOWNCONVERSION = False
- 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_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.
- 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
- 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)
- 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).
- get_max_timestamp(gens=True, ros=True, gen_t0=None)
Calculate the max timestamp among the specified channels.
- get_timestamp(gen_ch=None, ro_ch=None)
- 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.
- 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.
- 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).
- set_timestamp(val, gen_ch=None, ro_ch=None)
- soccfg_methods = ['freq2reg', 'freq2reg_adc', 'reg2freq', 'reg2freq_adc', 'cycles2us', 'us2cycles', 'deg2reg', 'reg2deg', 'roundfreq', 'get_maxv']
- class qick.asm_v1.AcquireProgram(*args, **kwargs)[source]
Bases:
AcquireMixin,QickProgramBase class for tProc v1 programs with shot counting and readout acquisition. You will need to define the acquisition structure with setup_acquire().
- ABSOLUTE_FREQS = False
- FLIP_DOWNCONVERSION = False
- GAUSS_BUG = True
- USER_DURATIONS = False
- __init__(*args, **kwargs)
Constructor method
- acquire(soc, rounds=1, load_envelopes=True, start_src='internal', threshold=None, angle=None, progress=True, remove_offset=True, step_rounds=False, extra_args=None)
Acquire data using the accumulated 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
start_src (str) – “internal” (tProc starts immediately) or “external” (each round waits for an external trigger)
threshold (float or list of float) – The threshold(s) to apply to the I values after rotation. Length-normalized units (same units as the output of acquire()). If scalar, the same threshold will be applied to all readout channels. A list must have length equal to the number of declared readout channels.
angle (float or list of float) – The angle to rotate the I/Q values by before applying the threshold. Units of radians. If scalar, the same angle will be applied to all readout channels. A list must have length equal to the number of declared readout channels.
progress (bool) – if true, displays progress bar
remove_offset (bool) – Some readouts (muxed and tProc-configured) introduce a small fixed offset to the I and Q values of every decimated sample. This subtracts that offset, if any, before returning the averaged IQ values or rotating to apply software thresholding.
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:
averaged IQ values (float) divided by the length of the RO window, and averaged over reps and rounds if threshold is defined, the I values will be the fraction of points over threshold dimensions for a simple averaging program: (n_ch, n_reads, 2) dimensions for a program with multiple expts/steps: (n_ch, n_reads, n_expts, 2)
- Return type:
- 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).
- run_rounds(soc, rounds=1, load_envelopes=True, start_src='internal', progress=True, step_rounds=False)
Run the program and wait until it completes, once or multiple times. No data will be saved.
- Parameters:
soc (QickSoc) – Qick object
rounds (int) – number of times to rerun the program
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
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().
- 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.asm_v1.QickRegister(prog: QickProgram, page: int, addr: int, reg_type: Optional[str] = None, gen_ch: Optional[int] = None, ro_ch: Optional[int] = None, init_val=None, name: Optional[str] = None)[source]
Bases:
objectA qick register object that keeps the page, address, generator/readout channel and register type information, provides functions that make it easier to set register value given input values in physical units.
- __init__(prog: QickProgram, page: int, addr: int, reg_type: Optional[str] = None, gen_ch: Optional[int] = None, ro_ch: Optional[int] = None, init_val=None, name: Optional[str] = None)[source]
- Parameters:
prog – qick program in which the register is used.
page – page of the register
addr – address of the register in the register page (referred as “register number” in some other places)
reg_type – {“freq”, “time”, “phase”, “adc_freq”} or None, type of the register, used for automatic converting to physical values.
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.
init_val – initial value of the register. If reg_type is not None, the value should be in its physical unit. i.e. freq in MHz, time in us, phase in deg.
name – If None, an auto generated name based on the register page and address will be used
- reg2val(reg)[source]
converts a qick register value to its value in physical units :param reg: :return:
- set_to(a: Union[QickRegister, float, int], operator: str = '+', b: Union[QickRegister, float, int] = 0, physical_unit=True)[source]
a shorthand function that sets the register value using different asm commands based on the input type.
if input “a” is a number, “operator” and “b” will be neglected, “a”(or the register integer that corresponds to “a”) will be assigned to the current register
if input “a” is a QickRegister and “b” is a number, the register will be set to the “mathi” result between “a” and “b”. (when physical_unit==True, “b” will be auto-converted from physical value to register value based on the register type)
if both “a” and “b” are QickRegisters, the register will be set to the “math” result between “a” and “b”.
- Parameters:
a – first operand register or a constant value
operator – {“+”, “-”, “*”}. math symbol supported by “math” and “mathi” asm commands
b – second operand register or a constant value
physical_unit – when True, the constant value operands should be in its physical unit and will be automatically converted to the register integer before assignment.
- Returns:
- class qick.asm_v1.QickRegisterManagerMixin(*args, **kwargs)[source]
Bases:
objectA mixin class for QickProgram that provides manager functions for getting and declaring new qick registers.
- 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)[source]
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
- get_gen_reg(gen_ch: int, name: str) QickRegister[source]
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
- new_gen_reg(gen_ch: int, name: Optional[str] = None, init_val=None, reg_type: Optional[str] = None, tproc_reg=False) QickRegister[source]
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