From 63d06a4d523a577bc0047805d7d39f5dbb555595 Mon Sep 17 00:00:00 2001 From: Sho Uemura Date: Tue, 17 Sep 2024 21:21:33 -0500 Subject: [PATCH] some convenience tweaks --- qick_lib/qick/asm_v2.py | 2 ++ qick_lib/qick/qick_asm.py | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/qick_lib/qick/asm_v2.py b/qick_lib/qick/asm_v2.py index 8544d00f..b2f790b3 100644 --- a/qick_lib/qick/asm_v2.py +++ b/qick_lib/qick/asm_v2.py @@ -911,6 +911,8 @@ def preprocess(self, prog): for ro in self.ros: rocfg = prog.soccfg['readouts'][ro] + if ro not in prog.ro_chs: + raise RuntimeError("RO channel %d is triggered but never declared"%(ro)) if rocfg['trigger_type'] == 'dport': self.outdict[rocfg['trigger_port']] |= (1 << rocfg['trigger_bit']) else: diff --git a/qick_lib/qick/qick_asm.py b/qick_lib/qick/qick_asm.py index 992b0b66..a6031405 100644 --- a/qick_lib/qick/qick_asm.py +++ b/qick_lib/qick/qick_asm.py @@ -844,6 +844,25 @@ def check_pfb_collisions(self, rocfg, cfg1, cfgs): if np.abs(cfg1['f_folded'] - cfg2['pfb_center']) < rocfg['f_dds']/2: logger.warning("The readout at %.3f MHz may see some crosstalk from the tone at %.3f MHz." % (cfg2['f_rounded'], cfg1['f_rounded'])) + def get_maxv(self, gen_ch): + """Convenience method for looking up a generator's maximum allowed envelope value. + The absolute value of the idata/qdata should not exceed this. + Typically you will want to normalize your envelope's maximum range to this value. + + Parameters + ---------- + gen_ch : int + generator channel (index in 'gens' list) + + Returns + ------- + int + max allowed value + """ + gencfg = self['gens'][gen_ch] + return int(np.floor(gencfg['maxv']*gencfg['maxv_scale'])) + + class DummyIp: """Stores the configuration constants for a firmware IP block. """ @@ -1306,7 +1325,7 @@ def add_cosine(self, ch, name, length, maxv=None, even_length=False): This is useful for flat_top pulses, where the envelope gets split into two halves. """ gencfg = self.soccfg['gens'][ch] - if maxv is None: maxv = gencfg['maxv']*gencfg['maxv_scale'] + if maxv is None: maxv = self.soccfg.get_maxv(ch) samps_per_clk = gencfg['samps_per_clk'] # convert to integer number of fabric clocks @@ -1344,7 +1363,7 @@ def add_gauss(self, ch, name, sigma, length, maxv=None, even_length=False): This is useful for flat_top pulses, where the envelope gets split into two halves. """ gencfg = self.soccfg['gens'][ch] - if maxv is None: maxv = gencfg['maxv']*gencfg['maxv_scale'] + if maxv is None: maxv = self.soccfg.get_maxv(ch) samps_per_clk = gencfg['samps_per_clk'] if self.GAUSS_BUG: @@ -1392,7 +1411,7 @@ def add_DRAG(self, ch, name, sigma, length, delta, alpha=0.5, maxv=None, even_le This is useful for flat_top pulses, where the envelope gets split into two halves. """ gencfg = self.soccfg['gens'][ch] - if maxv is None: maxv = gencfg['maxv']*gencfg['maxv_scale'] + if maxv is None: maxv = self.soccfg.get_maxv(ch) samps_per_clk = gencfg['samps_per_clk'] f_fabric = gencfg['f_fabric'] @@ -1440,7 +1459,7 @@ def add_triangle(self, ch, name, length, maxv=None, even_length=False): This is useful for flat_top pulses, where the envelope gets split into two halves. """ gencfg = self.soccfg['gens'][ch] - if maxv is None: maxv = gencfg['maxv']*gencfg['maxv_scale'] + if maxv is None: maxv = self.soccfg.get_maxv(ch) samps_per_clk = gencfg['samps_per_clk'] # convert to integer number of fabric clocks