qick.qick_asm
The higher-level driver for the QICK library. Contains an tProc assembly language wrapper class and auxiliary functions.
Functions
|
Takes a frequency and casts it to an (even) valid ADC DDS frequency. |
|
Converts tProc clock cycles to microseconds. |
|
Converts degrees into phase register values; numbers greater than 360 will effectively be wrapped. |
|
Converts frequency in MHz to tProc DAC register value. |
|
Converts frequency in MHz to tProc ADC register value. |
|
Converts phase register values into degrees. |
|
Converts frequency from format readable by tProc DAC to MHz. |
|
Converts frequency from format readable by tProc ADC to MHz. |
|
Converts microseconds to integer number of tProc clock cycles. |
Classes
|
QickProgram is a Python representation of the QickSoc processor assembly program. |
- qick.qick_asm.adcfreq(f)[source]
Takes a frequency and casts it to an (even) valid ADC DDS frequency.
- qick.qick_asm.deg2reg(deg)[source]
Converts degrees into phase register values; numbers greater than 360 will effectively be wrapped.
- class qick.qick_asm.QickProgram(cfg=None)[source]
Bases:
object
QickProgram 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.
- add_pulse(ch, name, style, idata=None, qdata=None, length=None)[source]
Adds a pulse to the pulse library within the program.
- load_pulses(soc)[source]
Loads pulses that were added using add_pulse into the SoC’s signal generator memories.
- Parameters
soc (Qick object) – Qick object
- sreg(ch, name)[source]
Gets tProc special register number associated with a channel and register name.
- set_pulse_registers(ch, freq=None, phase=None, addr=None, gain=None, phrst=None, stdysel=None, mode=None, outsel=None, length=None, t=None)[source]
A macro to set (optionally) the pulse parameters including frequency, phase, address of pulse, gain, stdysel, mode register (compiled from length and other flags), outsel, length, and schedule time.
- Parameters
ch (int) – DAC channel
freq (float) – Frequency (MHz)
phase (float) – Phase (degrees)
addr (int) – Address
gain (float) – Gain (DAC units)
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
t (int) – The number of clock ticks at which point the pulse starts
- Returns
- const_pulse(ch, name=None, freq=None, phase=None, gain=None, phrst=None, stdysel=None, mode=None, outsel=None, length=None, t='auto', play=True)[source]
Schedule and (optionally) play a constant pulse, can autoschedule this based on previous pulses.
- Parameters
ch (int) – DAC channel
name (str) – Pulse name
freq (float) – Frequency (MHz)
phase (float) – Phase (degrees)
gain (float) – Gain (DAC units)
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
t (int) – The number of clock ticks at which point the pulse starts
- arb_pulse(ch, name=None, freq=None, phase=None, gain=None, phrst=None, stdysel=None, mode=None, outsel=None, length=None, t='auto', play=True)[source]
Schedule and (optionally) play an arbitrary pulse, can autoschedule this based on previous pulses.
- Parameters
ch (int) – DAC channel
name (str) – Pulse name
freq (float) – Frequency (MHz)
phase (float) – Phase (degrees)
gain (float) – Gain (DAC units)
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
t (int) – The number of clock ticks at which point the pulse starts
- flat_top_pulse(ch, name=None, freq=None, phase=None, gain=None, phrst=None, stdysel=None, mode=None, outsel=None, length=None, t='auto', play=True)[source]
Schedule and (optionally) play an a flattop pulse with arbitrary ramps, can autoschedule based on previous pulses To use these pulses one should use add_pulse 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.
- Parameters
ch (int) – DAC channel
name (str) – Pulse name
freq (float) – Frequency (MHz)
phase (float) – Phase (degrees)
gain (float) – Gain (DAC units)
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
t (int) – The number of clock ticks at which point the pulse starts
- pulse(ch, name=None, freq=None, phase=None, gain=None, phrst=None, stdysel=None, mode=None, outsel=None, length=None, t='auto', play=True)[source]
Overall pulse class which will select the correct function to call based on the ‘style’ parameter of the named pulse.
- Parameters
ch (int) – DAC channel
name (str) – Pulse name
freq (float) – Frequency (MHz)
phase (float) – Phase (degrees)
gain (float) – Gain (DAC units)
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
t (int) – The number of clock ticks at which point the pulse starts
- Returns
Dict of pulse styles
- Return type
- align(chs)[source]
Sets all of the last times for each channel included in chs to the latest time in any of the channels.
- 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)[source]
Aligns and syncs all channels with additional time t.
- Parameters
t (int) – The time offset in clock ticks
- marker(t, t1=0, t2=0, t3=0, t4=0, adc1=0, adc2=0, rp=0, r_out=31, short=True)[source]
Sets the value of the marker bits at time t. This triggers the ADC(s) at a specified time t and also sends trigger values to 4 PMOD pins for syncing a scope trigger. Channel 0 of the tProc is connected to triggers/PMODs. E.g. if t3=1 PMOD0_2 goes high.
- Parameters
t (int) – The number of clock ticks at which point the pulse starts
t1 (int) – t1 - value of an external pin connected to the PMOD (PMOD0_0)
t2 (int) – t2 - value of an external pin connected to the PMOD (PMOD0_1)
t3 (int) – t3 - value of an external pin connected to the PMOD (PMOD0_2)
t4 (int) – t4 - value of an external pin connected to the PMOD (PMOD0_3)
adc1 (bool) – 1 if ADC channel 0 is triggered; 0 otherwise.
adc2 (bool) – 1 if ADC channel 1 is triggered; 0 otherwise.
rp (int) – Register page
r_out (int) – Register number
short (bool) – If 1, plays a short marker pulse that is 5 clock ticks long
- trigger_adc(adc1=0, adc2=0, adc_trig_offset=270, t=0)[source]
Triggers the ADC(s) at a specified time t+adc_trig_offset.
- 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, debug=False)[source]
Converts an assembly instruction into a machine bytecode.
- get_mode_code(phrst, stdysel, mode, outsel, length)[source]
Creates mode code for the mode register in the set command, by setting flags and adding the pulse length.
- Parameters
phrst (bool) – If 1, it resets the phase coherent accumulator
stdysel (bool) – Selects what value is output continuously by the signal generator after the generation of a pulse. If 0, it is the last calculated sample of the pulse. If 1, it is a zero value.
mode (bool) – Selects whether the output is periodic or one-shot. If 0, it is one-shot. If 1, it is periodic.
outsel (int) – Selects the output source. The output is complex. Tables define envelopes for I and Q. If 0, the output is the product of table and DDS. If 1, the output is the DDS only. If 2, the output is from the table for the real part, and zeros for the imaginary part. If 3, the output is always zero.
length (int) – The number of samples in the pulse
- Returns
Compiled mode code in binary
- Return type
- append_instruction(name, *args)[source]
Append instruction to the program list
- Parameters
name (str) – Instruction name
*args –
Instruction arguments
- 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) – Instruction 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