From 1bbe3c0a7ea24e3e1d0bade9f7176c4f3469fbbd Mon Sep 17 00:00:00 2001 From: Brian Donovan Date: Wed, 28 Nov 2018 12:52:58 -0500 Subject: [PATCH 1/3] Merge conflict --- QGL/drivers/APS2Pattern.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/QGL/drivers/APS2Pattern.py b/QGL/drivers/APS2Pattern.py index 6d9da1ee..61c6e597 100644 --- a/QGL/drivers/APS2Pattern.py +++ b/QGL/drivers/APS2Pattern.py @@ -49,6 +49,7 @@ MAX_TRIGGER_COUNT = 2**32 - 1 MAX_VRAM_ADDRESS = 2**12-1 MODULATION_CLOCK = 300e6 +NUM_NCO = 4 # instruction encodings WFM = 0x0 @@ -581,13 +582,19 @@ def to_instruction(self, write_flag=True, label=None): MODULATOR_OP_OFFSET = 44 NCO_SELECT_OP_OFFSET = 40 + nco_select_bits = {1 : 0b0001, + 2 : 0b0010, + 3 : 0b0100, + 4 : 0b1000, + 15: 0b1111}[self.nco_select] + op_code_map = {"MODULATE": 0x0, "RESET_PHASE": 0x2, "SET_FREQ": 0x6, "SET_PHASE": 0xa, "UPDATE_FRAME": 0xe} payload = (op_code_map[self.instruction] << MODULATOR_OP_OFFSET) | ( - self.nco_select << NCO_SELECT_OP_OFFSET) + (nco_select_bits) << NCO_SELECT_OP_OFFSET) if self.instruction == "MODULATE": #zero-indexed quad count payload |= np.uint32(self.length / ADDRESS_UNIT - 1) @@ -615,9 +622,9 @@ def inject_modulation_cmds(seqs): for ct,seq in enumerate(seqs): #check whether we have modulation commands freqs = np.unique([entry.frequency for entry in filter(lambda s: isinstance(s,Compiler.Waveform), seq)]) - if len(freqs) > 2: - raise Exception("Max 2 frequencies on the same channel allowed.") - no_freq_cmds = np.all(np.less(np.abs(freqs), 1e-8)) + if len(freqs) > NUM_NCO: + raise Exception("Max {} frequencies on the same channel allowed.".format(NUM_NCO)) + no_freq_cmds = np.allclose(freqs, 0) phases = [entry.phase for entry in filter(lambda s: isinstance(s,Compiler.Waveform), seq)] no_phase_cmds = np.all(np.less(np.abs(phases), 1e-8)) frame_changes = [entry.frameChange for entry in filter(lambda s: isinstance(s,Compiler.Waveform), seq)] @@ -1135,12 +1142,13 @@ def start_new_seq(): instructions = np.frombuffer(FID.read(8*inst_len), dtype=np.uint64) wf_lib = {} - for i in range(num_chans): - wf_len = struct.unpack(' Date: Wed, 28 Nov 2018 13:05:55 -0500 Subject: [PATCH 2/3] Reset 4 NCOs --- QGL/drivers/APS2Pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QGL/drivers/APS2Pattern.py b/QGL/drivers/APS2Pattern.py index 61c6e597..23c41f97 100644 --- a/QGL/drivers/APS2Pattern.py +++ b/QGL/drivers/APS2Pattern.py @@ -648,7 +648,7 @@ def inject_modulation_cmds(seqs): #heuristic to insert phase reset before trigger if we have modulation commands if isinstance(entry, ControlFlow.Wait): if not ( no_modulation_cmds and (cur_freq == 0) and (cur_phase == 0)): - mod_seq.append(ModulationCommand("RESET_PHASE", 0x3)) + mod_seq.append(ModulationCommand("RESET_PHASE", 0xF)) for nco_ind, freq in enumerate(freqs): mod_seq.append( ModulationCommand("SET_FREQ", nco_ind + 1, frequency = -freq) ) elif isinstance(entry, ControlFlow.Return): From 6990088cbef5120d96952ad0d076922b624c856e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rist=C3=A8?= Date: Fri, 15 Nov 2019 13:16:51 -0500 Subject: [PATCH 3/3] Restore aps2 format --- QGL/drivers/APS2Pattern.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/QGL/drivers/APS2Pattern.py b/QGL/drivers/APS2Pattern.py index 23c41f97..39210163 100644 --- a/QGL/drivers/APS2Pattern.py +++ b/QGL/drivers/APS2Pattern.py @@ -1142,13 +1142,10 @@ def start_new_seq(): instructions = np.frombuffer(FID.read(8*inst_len), dtype=np.uint64) wf_lib = {} - wf_lib['ch1'] = ( - 1.0 / - MAX_WAVEFORM_VALUE) * FID['/chan_1/waveforms'].value.flatten() - wf_lib['ch2'] = ( - 1.0 / - MAX_WAVEFORM_VALUE) * FID['/chan_2/waveforms'].value.flatten() - instructions = FID['/chan_1/instructions'].value.flatten() + for i in range(num_chans): + wf_len = struct.unpack('