Q1ASM User guide#
Q1ASM is an assembly language used to program the sequencers.
Assembly syntax#
An assembly source file consists of a sequence of lines. Each line contains a directive or a code instruction (optionally followed by a comment), or a comment.
Case Sensitivity: The entire syntax is case-sensitive.
Comments: Begin with a hash symbol (
#). The assembler ignores all comments.
Directives#
The .DEF directive creates a user-defined alias. .DEF <name> <value> allows you to assign a symbolic <name> to a <value>.
<name>: Starts with a letter (cannot start with a number). Consists of uppercase/lowercase letters and/or numbers.<value>: The string literal that will replace<name>. Can be any string (e.g., 42, R63).
Code#
A source line has the following format:
[label:] instruction argument,argument,... [comment]
Fields are separated by whitespace (spaces or tabs). Operands may also be separated by whitespace.
Arguments#
Q1ASM instructions use the following types of arguments:
Type |
Acronym |
Format |
Description |
|---|---|---|---|
Immediate |
|
# |
32-bit decimal or hexadecimal value (e.g. |
Register |
|
R# |
Register address in range 0 to 63 (e.g. |
Labels#
Labels are used to mark addresses for program flow control (e.g., for jumps and loops).
A label is defined by placing an identifier followed by a colon :. e.g. mylabel:
Any instruction can be preceded by a label.
Labels can be placed on a separate line (See the Q1 core section for an example).
Label references#
A label is referenced by placing an at-symbol @ followed by the label’s name.
e.g. mylabel: is referred as @mylabel.
A label reference has to be an immediate argument.
Forward references are allowed, meaning you can refer to a label before it is defined.
Alias references#
An alias is referenced by placing a dollar sign $ followed by the alias’s name.
Tip
Example
.DEF SQG_TIME 100 # Time in ns for single qubit gate
wait $SQG_TIME
An alias reference can be immediate or register argument.
Forward references are not allowed; the
.DEFmust appear before the alias is used.
Instructions#
A sequencer consists of the Q1 core and the real-time (RT) core. The Q1 core pushes instructions to a queue, which are then executed by the RT core. See Q1 instructions and RT instructions for more specific instructions.
The total duration of an experiment, or its wall-time, is determined only by the duration argument of RT instructions.
The Q1 core’s processing time is only relevant if it cannot prepare instructions fast enough to keep the RT core busy.
If the RT queue runs empty, the sequencer will halt and raise an error.
In the tables below, the arguments of an instruction are specified as arg0_name: type.
An instruction may have multiple allowed combinations of arguments, which are specified on separate lines.
Q1 Instructions#
Core Instructions#
Instruction |
Execution time (ns) |
Description of instruction |
|---|---|---|
illegal |
4 |
An invalid instruction. If executed, the sequencer halts with an error. |
stop |
4 |
Stops the sequencer. |
nop |
4 |
No operation. Does nothing for one Q1 clock cycle. |
Jump Instructions#
For jump instructions, the immediate is generally a label, representing the instruction address of the following instruction. The functionality of jumping to addresses stored in registers can be used for creating subroutines, to add offsets to labels, writing case tables, and so on.
Instruction |
Signature |
Execution time (ns) |
Description of instruction |
|---|---|---|---|
jmp |
|
16 |
Jumps to the instruction at |
jge |
|
24 on jump, 12 on continue |
If a \(\ge\) b, jumps to |
jlt |
|
24 on jump, 12 on continue |
If a \(\le\) b, jumps to |
loop |
|
24 on jump, 12 on continue |
Decrements a by one. If the result is not zero, jumps to |
Note
For jump instructions, register values are treated as an unsigned 32-bit integers.
Arithmetic Instructions#
Instruction |
Signature |
Execution time (ns) |
Description |
|---|---|---|---|
move |
|
4 |
Move/copy source to destination. |
not |
|
12 |
Bitwise invert source and move the result to destination. |
add |
|
12 |
Add b to a and move the result to destination. |
sub |
|
12 |
Subtract b from a and move the result to destination. |
and |
|
12 |
Bitwise AND a and b and move the result to destination. |
or |
|
12 |
Bitwise OR a and b and move the result to destination. |
xor |
|
12 |
Bitwise XOR a and b and move the result to destination. |
asl |
|
12 |
Bitwise left-shift a by b bits and move the result to destination. |
asr |
|
12 |
Bitwise right-shift a by b bits and move the result to destination. |
Note
For arithmetic instructions, the register value is treated as an unsigned 32-bit integer.
Immediates must be in the range [0, 4294967295].
To use a negative number, move 0 to a register and then subtract the desired positive value from it. Alternatively, directly use the 2’s complement form of the number.
Latched Instructions#
Some instructions like set_awg_offs and set_freq change special latched registers in the FPGA.
The new values are “latched” (held) until a subsequent RT instruction (like upd_param or play) applies them to a sequencer.
More information can be found here.
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
set_cond |
|
4 |
Configures the condition for following RT instructions. If the condition is true, the RT instruction is executed. Else, the RT core waits for |
All parameters below are latched and only updated when a real-time instruction (like upd_param or play) is executed.
The wait real-time instruction does not update latched parameters.
To understand the functionalities of the instructions that follow, let us model the total phase of the NCO as defined in the control sequencer page.
\(\phi_\text{acc}(t) = 2\pi f t' + \Phi + \phi\)
Hereon, by accumulated phase we mean \(\phi_\text{acc}\), by phase we mean \(\phi_0\), and by phase kick we refer to \(\delta\phi\).
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
set_mrk |
|
4 |
Set marker output channels to |
set_freq |
|
4 |
Sets the NCO frequency (f) to |
reset_ph |
— |
4 |
Resets the NCO’s accumulated phase to zero. by setting \(t' \rightarrow 0\), \(\Phi \rightarrow 0\) and \(\Phi \rightarrow 0\). |
set_ph |
|
4 |
Sets the NCO phase offset \(\phi\) to |
set_ph_delta |
|
4 |
Adds an instantaneous phase kick (\(\Delta\phi\)) to the NCO’s total phase (\(t'\rightarrow t' + \delta\phi/(2\pi f)\)). This is useful for applying dynamic phase shifts during a sequence. |
set_awg_gain |
|
4 |
Sets the signal gain for the two AWG paths. Values are integers from –32,768 to 32,767. |
set_awg_offs |
|
4 |
Sets the signal offset for the two AWG paths. Values are integers from –32,768 to 32,767. |
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
set_digital |
|
4 |
Set the output of sequencer/channel to high or low using |
set_time_ref |
— |
4 |
Configure the reference timestamp to the current sequencer time. This timestamp may be used by the |
set_scope_en |
|
4 |
Set |
Note
Adjustment range of fine_delay is [0, 2047] where each number is a multiple of 1/ 128 ns. This fine resolution is limited by hardware resolution of 39 ps (5 steps). Mask should always be set to 1.
Real-time Instructions#
These instructions are executed by the real-time (RT) core and define the experiment’s timing (wall-time).
The duration argument dictates how long the RT core spends on that step, with a resolution of 1ns and minimum of 4 ns. See link.
The duration is counted from the beginning of an instruction.
This is what enables, for example, parallel playback and acquisition.
Once started, the RT timeline is uninterruptible to ensure deterministic timing. In case of a conflict to the Q1 core, the sequencer will halt and raise an error flag.
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
set_latch_en |
|
4 |
Enables or disables all trigger network address counters. Once enabled, the counters will count all triggers on the trigger network. When disabled, the counters hold their last values. |
latch_rst |
|
4 |
Resets all trigger network address counters to 0. |
wait |
|
4 |
Waits for the specified |
wait_trigger |
|
4 |
Waits for a hardware trigger signal. The |
wait_sync |
|
4 |
Wait for SYNQ to complete all previous tasks of all the sequencers. |
The execution of any of these instructions will cause the latched parameters to be updated.
Please note that the duration argument for all these instructions has been explained at the start of this section!
Also note that for all real-time instructions, duration \(\in\) [4, 65535].
For longer wall times, extra waits must be added after the instructions.
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
upd_param |
|
4 |
Update the latched parameters, and then wait for |
play |
|
4 |
Update the latched parameters, interrupt currently playing waves, and start playing AWG waveforms stored at indexes |
The execution of any of these instructions will cause the latched parameters to be updated.
Please note that the duration argument for all these instructions has been explained at the start of this section!
Also note that for all real-time instructions, duration \(\in\) [4, 65535].
For longer wall times, extra waits must be added after the instructions.
Instruction |
Signature |
Q1 Execution Time (ns) |
Description |
|---|---|---|---|
upd_param |
|
4 |
Update the latched parameters, and then wait for |
play |
|
4 |
Update the latched parameters, interrupt currently playing waves, and start playing AWG waveforms stored at indexes |
acquire |
|
4 |
Update the latched parameters, interrupt currently active acquisitions, and start the acquisition referred to using index |
acquire_weighed |
|
4 |
Update the latched parameters, interrupt currently active acquisitions, and start the acquisition referred to using index |
acquire_ttl |
|
4 |
Update the latched parameters, start the TTL trigger acquisition referred to using index |
The time tag sequencers have their own set of unique real-time instructions, detailed below.
As with the other modules, executing any of these instructions will update the latched parameters.
Instruction |
Signature |
Execution Time (ns) |
Description |
|---|---|---|---|
acquire_timetags |
|
8 |
Opens or closes (depending on |
acquire_digital |
|
8 |
Updates latched parameters, samples and records the inputs mapped to the sequencer. Depending on the sampled input level, a trigger may be sent to the trigger network for feedback. |
upd_thres |
|
8 |
Updates latched parameters and sets the event count threshold at the given |
Note
Adjustment range of fine_delay is [0, 2047] where each number is a multiple of 1/ 128 ns. This fine resolution is limited by hardware resolution of 39 ps (5 steps). Mask should always be set to 1.
Note
When using the same bin in acquire_ttl across multiple acquisition runs, the TTL event counts within that bin are accumulated. In contrast, acquire_timetags averages the timestamps of the TTL events acquired within the corresponding window.