Skip to content

Commit

Permalink
Merge pull request #221 from BBN-Q/feature/tdm-chan
Browse files Browse the repository at this point in the history
TDM input channels
  • Loading branch information
Diego Ristè committed Sep 10, 2019
2 parents 2e9ff3e + 18dc28f commit 4967e72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 21 additions & 2 deletions QGL/ChannelLibraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ def new_APS(self, label, address, **kwargs):

@check_for_duplicates
def new_TDM(self, label, address, **kwargs):
return Channels.Processor(label=label, model="TDM", address=address, trigger_interval=250e-6)
chans = []
for k in range(7): # TDM has 7 digital inputs
chans.append(Channels.DigitalInput(label=f"DigitalInput-{label}-{k}", channel=k, channel_db=self.channelDatabase))
tdm = Channels.Processor(label=label, model="TDM", address=address, trigger_interval=250e-6, channels=chans, channel_db=self.channelDatabase)
self.add_and_update_dict(tdm)
return tdm

@check_for_duplicates
def new_spectrum_analzyer(self, label, address, source, **kwargs):
Expand Down Expand Up @@ -555,7 +560,7 @@ def set_qubit_connectivity(self, graph):
self.add_and_update_dict(new_edges)
return new_edges

def set_measure(self, qubit, transmitter, receivers, generator=None, trig_channel=None, gate=False, gate_channel=None, trigger_length=1e-7):
def set_measure(self, qubit, transmitter, receivers, generator=None, trig_channel=None, gate=False, gate_channel=None, trigger_length=1e-7, tdm_chan=None):

if isinstance(transmitter, Channels.Transmitter):
quads = [c for c in transmitter.channels if isinstance(c, Channels.PhysicalQuadratureChannel)]
Expand Down Expand Up @@ -614,6 +619,20 @@ def set_measure(self, qubit, transmitter, receivers, generator=None, trig_channe
meas.gate_chan = gate_chan
self.add_and_update_dict([gate_chan])

if tdm_chan:
if isinstance(tdm_chan, Channels.DigitalInput):
phys_tdm_channel = tdm_chan
else:
if not hasattr(self.channelDatabase, 'processors') or not self.channelDatabase.processors:
raise ValueError(f"No processor is defined")
elif len(self.channelDatabase.processors) > 1:
raise ValueError(f"Multiple processors are defined. Please specify digital input channel.")
else:
tdm = self.channelDatabase.processors[0]
phys_tdm_channel = tdm.get_chan(tdm_chan)
meas.processor_chan = phys_tdm_channel
self.add_and_update_dict([meas, phys_tdm_channel])

def set_master(self, master_instrument, trig_channel=None, pulse_length=1e-7):

if isinstance(master_instrument, Channels.Processor):
Expand Down
8 changes: 6 additions & 2 deletions QGL/drivers/APS2Pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,9 @@ def tdm_instructions(seqs):

elif isinstance(s, PulseSequencer.Pulse):
if s.label == 'MEAS' and s.maddr != (-1, 0):
instructions.append(CrossBar(2**s.maddr[1], 0x1, label=label))
# tdm_chan specifies the input channel to the TDM carrying the qubit state. Defaults to 1
tdm_chan = m.channel.processor_chan.channel if getattr(m.channel, 'processor_chan') else 1
instructions.append(CrossBar(2**m.maddr[1], 2**(tdm_chan-1)), label=label)
instructions.append(LoadCmp(label=label))
instructions.append(StoreMeas(s.maddr[0], 1 << 16, label=label))

Expand All @@ -1404,7 +1406,9 @@ def tdm_instructions(seqs):
if len(set(maddr))>1:
raise Exception('Storing simultaneous measurements on different addresses not supported.')
for n,m in enumerate(sim_meas):
instructions.append(CrossBar(2**m.maddr[1], 2**n))
# each tdm_chan specifies the input channel to the TDM carrying the corresponding qubit state. Default values are the first n channels
tdm_chan = m.channel.processor_chan.channel if getattr(m.channel, 'processor_chan') else n+1
instructions.append(CrossBar(2**m.maddr[1], 2**(tdm_chan-1)))
instructions.append(LoadCmp(label=label))
instructions.append(StoreMeas(maddr[0], 1 << 16))

Expand Down

0 comments on commit 4967e72

Please sign in to comment.