Skip to content

Commit

Permalink
Fix majoritymask
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Ristè committed Sep 12, 2018
1 parent 43fc30e commit 4e24b86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions QGL/BasicSequences/Feedback.py
Expand Up @@ -124,8 +124,8 @@ def BitFlip3(data_qs, ancilla_qs, theta=None, phi=None, nrounds=1, meas_delay=1e
raise Exception("Wrong number of qubits")
seqs = [
DecodeSetRounds(1,0,nrounds),
Invalidate(addr=10, mask=2*nrounds),
Invalidate(addr=11, mask=0x1)]
Invalidate(10, 2*nrounds),
Invalidate(11, 1)]

# encode single-qubit state into 3 qubits
if theta and phi:
Expand Down Expand Up @@ -153,7 +153,7 @@ def BitFlip3(data_qs, ancilla_qs, theta=None, phi=None, nrounds=1, meas_delay=1e
if docals:
seqs += create_cal_seqs(qubits,
calRepeats)
metafile = compile_to_hardware(seqs, 'BitFlip/BitFlip')
metafile = compile_to_hardware(seqs, 'BitFlip/BitFlip', tdm_seq = True)
return metafile

def MajorityVoteN(qubits, nrounds, prep=[], meas_delay=1e-6, docals=False, calRepeats=2):
Expand All @@ -173,8 +173,8 @@ def MajorityVoteN(qubits, nrounds, prep=[], meas_delay=1e-6, docals=False, calRe
"""
nqubits = len(qubits)
seqs = [MajorityMask(nrounds*nqubits),
Invalidate(addr=10, mask=nrounds*nqubits),
Invalidate(addr=11, mask=1)]
Invalidate(10, nrounds*nqubits),
Invalidate(11, 1)]
if prep:
seqs += [reduce(operator.mul, [X(q) for n,q in enumerate(qubits) if prep[n]])]
for n in range(nrounds):
Expand All @@ -187,5 +187,5 @@ def MajorityVoteN(qubits, nrounds, prep=[], meas_delay=1e-6, docals=False, calRe
if docals:
seqs += create_cal_seqs(qubits,
calRepeats)
metafile = compile_to_hardware(seqs, 'MajorityVote/MajorityVote')
metafile = compile_to_hardware(seqs, 'MajorityVote/MajorityVote', tdm_seq = True)
return metafile
4 changes: 2 additions & 2 deletions QGL/TdmInstructions.py
Expand Up @@ -40,8 +40,8 @@ def __ne__(self, other):
def MajorityVote(in_addr, out_addr, nmeas): # alternatively, append the loadcmpvram instruction when compiling (see STOREMEAS)
return [LoadCmpVramInstruction('LOADCMPVRAM', 1, in_addr, 2**nmeas-1, True), CustomInstruction('MAJORITY', in_addr, out_addr)]

def MajorityMask(in_addr, out_addr, value):
return [WriteAddrInstruction('INVALIDATE', None, 1, in_addr, 0x0, True), WriteAddrInstruction('WRITEADDR', None, 0, in_addr, value, True), LoadCmpVramInstruction('LOADCMPVRAM', 1, in_addr, 0xffff, True), CustomInstruction('MAJORITYMASK', in_addr, out_addr)]
def MajorityMask(value):
return [WriteAddrInstruction('INVALIDATE', None, 1, 0, 0x0, True), WriteAddrInstruction('WRITEADDR', None, 0, 0, value, True), LoadCmpVramInstruction('LOADCMPVRAM', 1, 0, 0xffff, True), CustomInstruction('MAJORITYMASK', 0, 1)]

def Decode(in_addr, out_addr, nmeas):
return [LoadCmpVramInstruction('LOADCMPVRAM', 1, in_addr, 2**nmeas-1, True), CustomInstruction('TSM', in_addr, out_addr)]
Expand Down

0 comments on commit 4e24b86

Please sign in to comment.