qick.asm_v2

Functions

QickSpan(loop, span)

Convenience shortcut for building multi-dimensional QickParams.

QickSweep1D(loop, start, end)

Convenience shortcut for a one-dimensional QickParam.

Classes

AbsGenManager(prog, gen_ch)

Manages the envelope and pulse information for a signal generator channel.

AbsRegisterManager(prog, chcfg, ch_name)

Generic class for managing registers that will be written to a tProc-controlled block (signal generator or readout).

AcquireProgramV2(*args, **kwargs)

Base class for tProc v2 programs with shot counting and readout acquisition.

AsmInst

AsmV2(*args, **kwargs)

A list of tProc v2 assembly instructions.

AveragerProgramV2(soccfg, reps, final_delay)

Use this as a base class to build looping programs.

Call

CloseLoop

CondJump

ConfigReadout(*args, **kwargs)

Delay(*args, **kwargs)

End

IncReg

Jump

Label

Macro

MultiplexedGenManager(prog, gen_ch)

Manager for the muxed signal generators.

OpenLoop

Pulse(*args, **kwargs)

QickParam(start[, spans])

Defines a parameter for use in pulses or times.

QickProgramV2(soccfg)

Base class for all tProc v2 programs.

QickPulse(prog, ch_mgr[, params])

A pulse is mostly just a list of waveforms.

QickRawParam(par, start, spans[, quantize])

QickRegisterV2(addr[, init])

A user-allocated data register, possibly with an initial (swept) value.

ReadDmem

ReadInput

ReadWmem

ReadoutManager(prog, ro_ch)

Manages the configurations for a dynamically configured readout channel.

Resync(*args, **kwargs)

SimpleClass()

StandardGenManager(prog, gen_ch)

Manager for the full-speed and interpolated signal generators.

TimedMacro(*args, **kwargs)

Timed instructions have parameters corresponding to times or durations.

Trigger(*args, **kwargs)

Wait(*args, **kwargs)

Waveform(freq, phase, env, gain, length, conf)

WriteDmem

WriteLabel

WriteReg

WriteWmem

class qick.asm_v2.QickParam(start: float, spans: dict = {})[source]

Bases: object

Defines a parameter for use in pulses or times. This may be a floating-point scalar or a multi-dimensional sweep. This class isn’t usually instantiated by user code: if you want to make a sweep, it’s easier to use QickSweep1D or <start_val>+QickSpan+QickSpan….

The lifecycle of the various sweep classes:

User code builds a QickParam from scalars, QickSpans, and QickParams.

When the pulse or timed instruction is defined, the QickParam might get additional scalar operations (mostly, if it’s a readout freq for an RO that’s freq-matched with a mixer generator). (are there cases where delay_auto values might get added to sweeps?) Then it gets converted to a QickRawParam by to_int. The QickRawParam may be scaled by int or Fraction multiplication, or offset by an int, e.g. to convert from flat-top to ramp gain, to apply mixer freq to a freq-matched RO freq. These are in-place operations. The “quantize” parameter ensures that the scaled QickRawParams will get stepped in the same way.

When the loop dims are known, the QickRawParam gets divided into steps by to_steps. The same QickRawParam may be used for multiple Waveforms.

QickRawParam gets converted back to QickParam to get user units by float division. This is used to get pulse durations; the resulting QickParam may get operated on and get used for an auto time. It is also used by get_pulse_param, but we will probably use get_actual_values instead?

get_actual_values works as follows:

derived_param and conversion_from_derived_param are updated whenever a new QickParam is created by scalar operation. Note that if the same QickParam is used in two places, the derived_param pointer gets overwritten. Pulse and timed-instruction parameters are copied at use, so get_pulse_param and get_time_param are safe. Code that calls get_actual_values directly on a QickParam relies on the step sizes being the same everywhere a sweep is used.

raw_param and raw_scale are set by to_int. Normally the QickRawParam created by to_int is then stepped.

When get_actual_values is called on the pulse parameter, it recurses through the derived_param pointers until it finds the QickParam that got converted by to_int. Then raw_param is used to get the rounded+stepped QickRawParam.

get_rounded(loop_counts: dict[str, int] = None) QickParam[source]

Calculate the param values after rounding to ASM units. loop_counts parameter is optional and will be used to compute steps if they have not already been computed.

Parameters:

loop_counts (dict[str, int]) – Number of iterations for each loop, outermost first.

to_array(loop_counts, all_loops=False)[source]

Calculate the sweep points. This calculation is based on the span values in the sweep. If you call this on a QickParam that you defined, the result will differ from the actual sweep points due to rounding. If you want exact actual values, use get_actual_values() or call this on an already-rounded QickParam (like one returned by get_pulse_param()/get_time_param().

Parameters:
  • loop_counts (dict[str, int]) – Number of iterations for each loop, outermost first.

  • all_loops (bool) – If a loop in loop_counts doesn’t increment this QickParam, include it in the output array as a dimension of size 1.

Returns:

values – Each dimension corresponds to a loop in loop_counts.

Return type:

numpy.ndarray

get_actual_values(loop_counts: dict[str, int]) np.ndarray[source]

Calculate the actual sweep points after rounding to ASM units.

Parameters:

loop_counts (dict[str, int]) – Number of iterations for each loop, outermost first.

Returns:

values – Each dimension corresponds to a loop in loop_counts. The size of the dimension is 1 if the loop does not increment this QickParam.

Return type:

numpy.ndarray

qick.asm_v2.QickSweep1D(loop, start, end)[source]

Convenience shortcut for a one-dimensional QickParam.

Parameters:
  • loop (str) – The name of the loop to use for the sweep.

  • start (float) – The desired value at the start of the loop.

  • end (float) – The desired value at the end of the loop.

qick.asm_v2.QickSpan(loop, span)[source]

Convenience shortcut for building multi-dimensional QickParams. A QickSpan equals 0 at the start of the specified loop, and the specified “span” value at the end of the loop. You may sum QickSpans and floats to build a multi-dimensional QickParam.

Parameters:
  • loop (str) – The name of the loop to use for the sweep.

  • span (float) – The desired value at the end of the loop. Can be positive or negative.

class qick.asm_v2.SimpleClass[source]

Bases: object

class qick.asm_v2.QickRawParam(par: str, start: int, spans: Dict[str, int], quantize: int = 1)[source]

Bases: SimpleClass

to_rounded()[source]

Reverse the conversion from QickParam to QickRawParam. This is used by QickParam.get_rounded().

class qick.asm_v2.QickPulse(prog: QickProgramV2, ch_mgr: AbsRegisterManager, params: dict = {})[source]

Bases: SimpleClass

A pulse is mostly just a list of waveforms. It also contains some metadata to allow the rounded/swept values of the original pulse parameters to be extracted. You will not normally instantiate this class yourself. Use QickProgramV2.add_pulse() instead.

Parameters:
  • params (dict) – Parameter values

  • ch_mgr (AbsRegisterManager) – The generator or readout manager associated with this pulse’s definition. Used to calculate pulse lengths.

add_wave(waveform)[source]

Add a Waveform or a waveform name to this pulse.

class qick.asm_v2.QickRegisterV2(addr: int, init: Optional[QickParam] = None)[source]

Bases: SimpleClass

A user-allocated data register, possibly with an initial (swept) value.

This is for internal use; user code should not use this class.

class qick.asm_v2.Macro[source]

Bases: SimpleNamespace

class qick.asm_v2.AsmInst[source]

Bases: Macro

class qick.asm_v2.Label[source]

Bases: Macro

class qick.asm_v2.WriteLabel[source]

Bases: Macro

class qick.asm_v2.End[source]

Bases: Macro

class qick.asm_v2.WriteReg[source]

Bases: Macro

class qick.asm_v2.IncReg[source]

Bases: Macro

class qick.asm_v2.ReadWmem[source]

Bases: Macro

class qick.asm_v2.WriteWmem[source]

Bases: Macro

class qick.asm_v2.ReadDmem[source]

Bases: Macro

class qick.asm_v2.WriteDmem[source]

Bases: Macro

class qick.asm_v2.ReadInput[source]

Bases: Macro

class qick.asm_v2.Jump[source]

Bases: Macro

class qick.asm_v2.Call[source]

Bases: Macro

class qick.asm_v2.CondJump[source]

Bases: Macro

class qick.asm_v2.OpenLoop[source]

Bases: Macro

class qick.asm_v2.CloseLoop[source]

Bases: Macro

class qick.asm_v2.TimedMacro(*args, **kwargs)[source]

Bases: Macro

Timed instructions have parameters corresponding to times or durations.

Add additional methods used for handling these time parameters.

class qick.asm_v2.Delay(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.Wait(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.Resync(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.Pulse(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.ConfigReadout(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.Trigger(*args, **kwargs)[source]

Bases: TimedMacro

class qick.asm_v2.AsmV2(*args, **kwargs)[source]

Bases: object

A list of tProc v2 assembly instructions. You can think of this as a code snippet that you can insert in a program.

append_macro(macro)[source]

Add a macro to the program’s macro list.

Parameters:

macro (Macro) – macro to be added

extend_macros(asm)[source]

Append all the given instructions onto this list of instructions. Named by analogy to Python list.extend().

Parameters:

asm (AsmV2) – instruction list to append

asm_inst(inst, addr_inc=1)[source]

Add a macro-wrapped ASM instruction to the program’s macro list. If you are mixing ASM and macros (you probably are), this is what you want to use.

Parameters:
  • inst (dict) – ASM instruction in dictionary format

  • addr_inc (int) – number of machine-code words this instruction will occupy. Only used for WAIT.

label(label)[source]

Apply the specified label to the next instruction. If the next instruction is a macro that expands to multiple ASM instructions, the label goes on the first ASM instruction. That’s what you want.

Parameters:

label (str) – label to be applied

nop()[source]

Do a NOP instruction. This is a no-op - it doesn’t do anything except waste a tProcessor cycle.

end()[source]

Do an END instruction, which will end execution. This is implemented as an infinite loop (the v2 doesn’t really have an “end” state).

jump(label)[source]

Do a JUMP instruction, jumping to the location of the specified label.

call(label)[source]

Do a CALL instruction, storing the current program counter and jumping to the location of the specified label. The next RET instruction will cause the program to jump back to the CALL. This is used to call subroutines, where a subroutine is defined as a block of code starting with a label and ending with a RET.

ret()[source]

Do a RET instruction, returning from a CALL.

set_ext_counter(addr=1, val=0)[source]

Set one of the externally readable registers. This is usually used to initialize the shot counter.

Parameters:
  • addr (int) – register number, 1 or 2

  • val (int) – value to write (signed 32-bit)

inc_ext_counter(addr=1, val=1)[source]

Increment one of the externally readable registers. This is usually used to increment the shot counter.

Parameters:
  • addr (int) – register number, 1 or 2

  • val (int) – value to add (signed 32-bit)

write_reg(dst, src)[source]

Write to a register.

Parameters:
  • dst (str) – Name of destination register

  • src (int or str) – Literal value, or name of source register

inc_reg(dst, src)[source]

Increment a register.

Parameters:
  • dst (str) – Name of destination register

  • src (int or str) – Literal value, or name of source register

read_wmem(name)[source]

Copy a waveform from waveform memory to waveform registers. This is usually used in combination with write_wmem() to make changes to a waveform. You will usually get the waveform name using QickProgramV2.list_pulse_waveforms().

Parameters:

name (str) – Waveform name

write_wmem(name)[source]

Copy a waveform from waveform registers to waveform memory. This is usually used in combination with read_wmem() to make changes to a waveform. You will usually get the waveform name using QickProgramV2.list_pulse_waveforms().

Parameters:

name (str) – Waveform name

read_dmem(dst, addr)[source]

Copy a number from data memory to a register. The memory address can be specified as an int or a register.

Parameters:
  • dst (str) – Name of destination register

  • addr (int or str) – Literal address, or name of register

write_dmem(addr, src)[source]

Copy a number into data memory. Both the value and the memory address can be specified as an int or a register.

Parameters:
  • addr (int or str) – Literal address, or name of register

  • src (int or str) – Literal value, or name of source register

read_input(ro_ch)[source]

Read an accumulated I/Q value from one of the tProc inputs. The readout must have already pushed the value into the input, otherwise you will get a stale value. The value you read gets stored in two special registers (s_port_l/s_port_h or I/Q) until you are ready to use it. :param ro_ch: readout channel (index in ‘readouts’ list) :type ro_ch: int

cond_jump(label, arg1, test, op=None, arg2=None)[source]

Do a conditional jump (do a test, then jump if the test passes). A test is done by executing an operation on two operands and testing the resulting value. If val2 and reg2 are both None, the test will just use reg1, no operation.

Parameters:
  • label (str) – the label to jump to

  • arg1 (str) – the name of the register for operand 1

  • test (str) – the name of the test: 1/0 (always/never), Z/NZ (==0/!=0), S/NS (<0/>=0), F/NF (external flag)

  • op (str) – the name of the operation: +, -, AND (bitwise AND, &), or ASR (shift-right, >>)

  • arg2 (int or str) – 24-bit signed value or register name for operand 2

read_and_jump(ro_ch, component, threshold, test, label)[source]

Read an input I/Q value and jump based on a threshold. This just combines read_input() and cond_jump(). As noted in read_input(), you must be sure your readout has already completed.

Parameters:
  • ro_ch (int) – readout channel (index in ‘readouts’ list)

  • component (str) – I or Q

  • threshold (int or str) – 24-bit signed value or register name

  • test (str) – “>=” or “<”

  • label (str) – the label to jump to

open_loop(n, name=None)[source]

Start a loop. This will use a register. If you’re using AveragerProgramV2, you should use add_loop() instead.

Parameters:
  • n (int) – number of iterations

  • name (str) – number of iterations

close_loop()[source]

End whatever loop you’re in. This will increment whatever sweeps are tied to this loop.

delay(t, tag=None)[source]

Increment the reference time. This will have the effect of delaying all timed instructions executed after this one.

Parameters:
  • t (float or QickParam) – time (us)

  • tag (str) – arbitrary name for use with get_time_param()

delay_auto(t=0, gens=True, ros=True, tag=None)[source]

Set the reference time to the end of the last pulse/readout, plus the specified value. You can select whether this accounts for pulses, readout windows, or both.

Parameters:
  • t (float or QickParam) – time (us)

  • gens (bool) – check the ends of generator pulses

  • ros (bool) – check the ends of readout windows

  • tag (str) – arbitrary name for use with get_time_param()

wait(t, tag=None)[source]

Pause tProc execution until the time reaches the specified value, relative to the reference time.

Parameters:
  • t (float) – time (us)

  • tag (str) – arbitrary name for use with get_time_param()

wait_auto(t=0, gens=False, ros=True, tag=None, no_warn=False)[source]

Pause tProc execution until the time reaches the specified value, relative to the end of the last pulse/readout. You can select whether this accounts for pulses, readout windows, or both.

Parameters:
  • t (float) – time (us)

  • gens (bool) – check the ends of generator pulses

  • ros (bool) – check the ends of readout windows

  • tag (str) – arbitrary name for use with get_time_param()

  • no_warn (bool) – don’t warn if the “auto” logic results in a swept wait which gets rounded up to a scalar

resync(t=0.05, tag=None)[source]

Apply the appropriate delay to create some slack between the execution and reference times. In other words, increment the reference time to ensure it exceeds the execution time by at least t. This will never decrement the reference time, so if the slack already exceeded t it won’t change.

This is useful if your program waits for external input for an unknown time. Without resyncing, you run the risk that you will run out of slack and your future timed instructions will pile up on each other.

Cautions:

  • The appropriate delay is computed at execution time, so it is not generally possible to determine at compile time how much delay will be added.

  • The amount of delay added will fluctuate by tens of ns.

  • If t=0, you will probably end up with a small negative slack due to this macro’s execution time. Better to keep t positive (the default is safe).

If you know (or can put an upper bound on) how long your program waits, you may prefer to use delay().

Parameters:
  • t (float or QickParam) – time (us)

  • tag (str) – arbitrary name for use with get_time_param()

pulse(ch, name, t=0, tag=None)[source]

Play a pulse.

Parameters:
  • ch (int) – generator channel (index in ‘gens’ list)

  • name (str) – pulse name (as used in add_pulse()) If you use the special name “dummypulse”, a zero-gain pulse will be added for you, for stopping periodic pulses from repeating.

  • t (float, QickParam, or "auto") – time (us), or the end of the last pulse on this generator

  • tag (str) – arbitrary name for use with get_time_param()

send_readoutconfig(ch, name, t=0, tag=None)[source]

Send a previously defined readout config to a readout.

Parameters:
  • ch (int) – readout channel (index in ‘readouts’ list)

  • name (str) – config name (as used in add_readoutconfig())

  • t (float or QickParam) – time (us)

  • tag (str) – arbitrary name for use with get_time_param()

trigger(ros=None, tts=None, pins=None, t=0, width=None, ddr4=False, mr=False, tag=None)[source]

Pulse readout triggers and output pins.

Parameters:
  • ros (list of int) – Readout channels to trigger (index in ‘readouts’ list).

  • tts (list of int) – Time tagger blocks to arm (index in ‘time_taggers’ list). Note that the time tagger captures data only for the duration of the arm signal; you must therefore pay attention to the width parameter. This differs from the other readouts and buffers, which don’t care about the width of the trigger pulse.

  • pins (list of int) – Output pins to trigger (index in output pins list in QickConfig printout).

  • t (float, QickParam, or None) – Time (us). If None, the current value of the time register (s_out_time) will be used; in this case, the channel timestamps will not be updated.

  • width (float or QickParam) – Pulse width (us), default of 10 cycles of the tProc timing clock.

  • ddr4 (bool) – Trigger the DDR4 buffer.

  • mr (bool) – Trigger the MR buffer.

  • tag (str) – arbitrary name for use with get_time_param()

class qick.asm_v2.AbsRegisterManager(prog, chcfg, ch_name)[source]

Bases: ABC

Generic class for managing registers that will be written to a tProc-controlled block (signal generator or readout).

make_pulse(kwargs)[source]

Set pulse parameters. This is called by QickProgramV2.add_pulse().

Parameters:

kwargs (dict) – Parameter values

cfg2reg(outsel, mode, stdysel, phrst)[source]

Creates generator config register value, by setting flags. The bit ordering here is the one expected by the input to sg_translator. The translator will remap the bits to whatever the peripheral expects.

Parameters:
  • 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”.

  • stdysel (str) –

    Selects what value is output continuously by the signal generator after the generation of a waveform. The default is “zero”.

    • If “last”, it is the last calculated sample of the waveform.

    • 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:

int

class qick.asm_v2.AbsGenManager(prog, gen_ch)[source]

Bases: AbsRegisterManager

Manages the envelope and pulse information for a signal generator channel.

param_hash(params)[source]

Returns a hashable value that can be used to check whether the same set of parameters will result in the same pulse definition on different generators.

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

Returns:

Parameter dictionary to be stored with the pulse. Scalar numeric parameters are converted to QickParam, QickParams are copied.

Return type:

dict

class qick.asm_v2.StandardGenManager(prog, gen_ch)[source]

Bases: AbsGenManager

Manager for the full-speed and interpolated signal generators.

param_hash(params)[source]

Returns a hashable value that can be used to check whether the same set of parameters will result in the same pulse definition on different generators.

params2pulse(par)[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_pulse to add the ramp envelope 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 envelope is not of even length, the middle sample will be skipped. It’s recommended to use an even-length envelope 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:

par (dict) – Pulse parameters

class qick.asm_v2.MultiplexedGenManager(prog, gen_ch)[source]

Bases: AbsGenManager

Manager for the muxed signal generators.

class qick.asm_v2.ReadoutManager(prog, ro_ch)[source]

Bases: AbsRegisterManager

Manages the configurations for a dynamically configured readout channel.

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

params2pulse(par)[source]

Write whichever pulse registers are fully determined by the defined parameters.

Parameters:

par (dict) – Pulse parameters

class qick.asm_v2.QickProgramV2(soccfg)[source]

Bases: AsmV2, AbsQickProgram

Base class for all tProc v2 programs.

Parameters:

soccfg (QickConfig) – The QICK firmware configuration dictionary.

load_prog(progdict)[source]

Load the program from a dictionary.

compile_datamem()[source]

Generate the data that should be written to data memory before running the program. For basic QICK programs no data needs to be written, and this method returns no values. If you need to write data, you should override this method.

Returns:

data to write

Return type:

numpy.ndarray of int or None

compile()[source]

Fills self.binprog with a binary representation of the program.

asm()[source]

Convert the program instructions to printable ASM.

Returns:

text ASM

Return type:

str

add_raw_pulse(name, waveforms, gen_ch=None, ro_ch=None)[source]

Add a pulse defined as a list of waveforms. The waveforms can be defined as raw Waveform objects, or names of waveforms that are already defined in the program.

This is usually only useful for testing and debugging. If you need the pulse length to be defined (e.g. if playing this pulse on a generator), you must specify one of gen_ch and ro_ch.

Parameters:
  • name (str) – name of the pulse

  • waveforms (list of Waveform or str) – waveforms that will be concatenated for this pulse

  • gen_ch (int or list of int) – generator channel (index in ‘gens’ list)

  • ro_ch (int or list of int) – readout channel (index in ‘readouts’ list)

add_pulse(ch, name, **kwargs)[source]

Add a pulse to the program’s pulse library. See the relevant generator manager for the list of supported pulse styles and parameters.

Parameters:
  • ch (int or list of int) – Generator channel (index in ‘gens’ list). The use of one pulse definition for multiple generators is experimental. The generators must be of the same type and running at the same sampling frequency, and if an envelope is used it must be defined on all generators at the same address.

  • name (str) – name of the pulse

  • ro_ch (int or None, optional) – Readout channel to frequency-match to. For a muxed generator, pass this argument to declare_gen() instead.

  • style (str) – Pulse style (“const”, “arb”, “flat_top”)

  • freq (int) – Frequency (MHz)

  • phase (int) – Phase (degrees)

  • gain (int) – Gain (-1.0 to 1.0, relative to the max amplitude for this generator and pulse style)

  • 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 (float) – The duration (us) of the flat portion of the pulse, used for “const” and “flat_top” styles

  • envelope (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

add_readoutconfig(ch, name, **kwargs)[source]

Add a readout config to the program’s pulse library. The “mode” and “length” parameters have no useful effect and should probably never be used.

Parameters:
  • ch (int or list of int) – Readout channel (index in ‘readouts’ list). The use of one readoutconfig for multiple readouts is experimental. The readouts must be of the same type and running at the same sampling frequency.

  • name (str) – name of the config

  • freq (float or QickParam) – Frequency (MHz)

  • phase (float or QickParam) – Phase (degrees)

  • phrst (int) – If 1, it resets the DDS phase. The default is 0.

  • mode (str) – Selects whether the output is “oneshot” (the default) or “periodic.”

  • outsel (str) – Selects the output source. The input is real, the output is complex. If “product” (the default), 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. If “zero”, the output is always zero.

  • length (float or QickParam) – The duration (us) of the config pulse. The default is the shortest possible length.

  • 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)

list_pulse_waveforms(pulsename, exclude_special=True)[source]

Get the names of the waveforms in a given pulse. This is normally useful if you need to loop over them in your program, for example to change some parameter.

Parameters:
  • pulsename (str) – Name of the pulse

  • exclude_special (bool) – Exclude the “dummy” and “phrst” waveforms (which have no parameters you’d want to manipulate) from the list

Returns:

Waveform names

Return type:

list of str

list_pulse_params(pulsename)[source]

Get the list of parameters you can look up for a given pulse with get_pulse_param().

Parameters:

pulsename (str) – Name of the pulse

Returns:

Parameter names

Return type:

list of str

get_pulse_param(pulsename, parname, as_array=False)[source]

Get the fully rounded value of a pulse parameter, in the same units that are used to specify the parameter in add_pulse(). By default, a swept parameter will be returned as a QickParam. If instead you ask for an array, the array will have a dimension for each loop where the parameter is swept. The dimensions will be ordered by the loop order.

The rounded value is only available after the program has been compiled (or run). So you can’t call this method from inside your program definition.

Parameters:
  • pulsename (str) – Name of the pulse

  • parname (str) – Name of the parameter

  • as_array (bool) – If the parameter is swept, return an array instead of a QickParam

Returns:

Parameter value

Return type:

float, QickParam, or numpy.ndarray

list_time_params(tag)[source]

Get the list of parameters you can look up for a given timed instruction with get_time_param().

Returns:

Parameter names

Return type:

list of str

get_time_param(tag, parname, as_array=False)[source]

Get the fully rounded value of a time parameter of a timed instruction, in microseconds. You must have supplied a “tag” for the timed instruction.

By default, a swept parameter will be returned as a QickParam. If instead you ask for an array, the array will have a dimension for each loop where the parameter is swept. The dimensions will be ordered by the loop order.

The rounded value is only available after the program has been compiled (or run). So you can’t call this method from inside your program definition.

Parameters:
  • tag (str) – Tag for the timed instruction.

  • parname (str) – Name of the parameter

  • as_array (bool) – If the parameter is swept, return an array instead of a QickParam

Returns:

Parameter value

Return type:

float, QickParam or numpy.ndarray

add_reg(name: Optional[str] = None, addr: Optional[int] = None, init: Optional[QickRawParam] = None, allow_reuse: bool = False)[source]

Declare a new data register.

Parameters:
  • name (str) – Requested register name, must be unused. If None, a name will be chosen for you and returned.

  • addr (int) – Requested register address, must be unused. If None, an address will be chosen for you.

  • init (QickRawParam) – Initial value, to be swept in loops. This is used for swept times, and is not recommended for user code.

  • allow_reuse (bool) – Allow reusing the same name. This is usually used for scratch registers that get used briefly. “init” and “addr” params must be None.

Returns:

Register name

Return type:

str

print_pmem2hex()[source]

Prints the content of the PMEM in Hexadecimal format to dump it in an RTL simulation using the command $readmemh()

print_wmem2hex()[source]

Prints the content of the WMEM in Hexadecimal format to dump it in an RTL simulation using the command $readmemh() NOTE: AXIS Data to WMEM words mapping is done in qproc_mem_ctrl.sv

class qick.asm_v2.AcquireProgramV2(*args, **kwargs)[source]

Bases: AcquireMixin, QickProgramV2

Base class for tProc v2 programs with shot counting and readout acquisition. You will need to define the acquisition structure with setup_acquire(). If you just want shot counting and run_rounds(), you can use setup_counter().

class qick.asm_v2.AveragerProgramV2(soccfg, reps, final_delay, final_wait=0, initial_delay=1.0, reps_innermost=False, before_reps=None, after_reps=None, cfg=None)[source]

Bases: AcquireProgramV2

Use this as a base class to build looping programs. You are responsible for writing _initialize() and _body(); you may optionally write a _cleanup(). The content of your _body() - a “shot” - will be run inside nested loops, where the outermost loop is run “reps” times, and you can add loop levels with add_loop(). The returned data will be averaged over the “reps” axis.

This is similar to the NDAveragerProgram from tProc v1. (Note that the order of user loops is reversed: first added is outermost, not innermost)

Parameters:
  • soccfg (QickConfig) – The QICK firmware configuration dictionary.

  • cfg (dict) – Your program configuration dictionary. There are no required entries, this is for your use and can be accessed as self.cfg in your _initialize() and _body().

  • reps (int) – Number of iterations in the “reps” loop.

  • final_delay (float) – Amount of time (in us) to add at the end of the shot timeline, after the end of the last pulse or readout. If your experiment requires a gap between shots (e.g. qubit relaxation time), use this parameter. The total length of your shot timeline should allow enough time for the tProcessor to execute your commands, and for the CPU to read the accumulated buffers; the default of 1 us usually guarantees this, and 0 will be fine for simple programs with sparse timelines. A value of None will disable this behavior (and you should insert appropriate delay/delay_auto statements in your body). This parameter is often called “relax_delay.”

  • final_wait (float) – Amount of time (in us) to pause tProc execution at the end of each shot, after the end of the last readout. The default of 0 is usually appropriate. A value of None will disable this behavior (and you should insert appropriate wait/wait_auto statements in your body).

  • initial_delay (float) – Amount of time (in us) to add to the timeline before starting to run the loops. This should allow enough time for the tProcessor to execute your initialization commands. The default of 1 us is usually sufficient. A value of None will disable this behavior (and you should insert appropriate delay/delay_auto statements in your initialization).

  • reps_innermost (bool) – If true, the “reps” loop will be the innermost loop (sweep once and take N shots at each step). Time-varying fluctuations will tend to appear as wiggles/jumps. If false, reps will be outermost (sweep N times and take 1 shot at each step). Time-varying fluctuations will tend to be averaged out.

  • before_reps (AsmV2) – Instructions to execute before the contents of the “reps” loop.

  • after_reps (AsmV2) – Instructions to execute after the contents of the “reps” loop.

compile()[source]

Fills self.binprog with a binary representation of the program.

add_loop(name, count, exec_before=None, exec_after=None)[source]

Add a loop level to the program. The first level added will be the outermost loop (after the reps loop).

exec_before and exec_after allow you to specify instructions that should execute at this loop level (inside this loop, before or after the contents of the loop). This might be useful for configuring readouts or triggering external equipment.

Parameters:
  • name (str) – Name of this loop level. This should match the name used in your sweeps.

  • count (int) – Number of iterations for this loop.

  • exec_before (AsmV2) – Instructions to execute before the contents of this loop.

  • exec_after (AsmV2) – Instructions to execute after the contents of this loop.