@@ -46,20 +46,19 @@ def dropnil(lst):
46
46
47
47
class QASMParser (parsimonious .NodeVisitor ):
48
48
49
- def __init__ (self , dt = (20 , 40 ), t1 = 30000 , t2 = 30000 ):
49
+ def __init__ (self , qubit_parameters , dt = (20 , 40 )):
50
+
50
51
self .grammar = qasm_grammar
51
52
self .lines = []
52
53
self .qubit_names = []
53
54
54
- self .t1 , self .t2 = t1 , t2
55
-
56
55
self .timestep = 0
57
-
58
56
self .circuits = []
59
57
self .gates = []
58
+ self .qubit_parameters = qubit_parameters
60
59
self .timestep_increment_sgl = dt [0 ]
61
60
self .timestep_increment_dbl = dt [1 ]
62
- self .timestep_increment = min (dt [ 0 ], dt [ 1 ] )
61
+ self .timestep_increment = min (self . timestep_increment_dbl , self . timestep_increment_sgl )
63
62
64
63
def visit_qubit_spec (self , node , children ):
65
64
self .qubit_names .append (children [1 ])
@@ -68,7 +67,9 @@ def visit_initall(self, node, children):
68
67
self .timestep = 0
69
68
self .current_circuit = ct .Circuit ("Circuit # " + str (len (self .circuits )))
70
69
for qb in self .qubit_names :
71
- self .current_circuit .add_qubit (qb , t1 = self .t1 , t2 = self .t2 )
70
+ t1 = self .qubit_parameters [qb ]['T1' ]
71
+ t2 = self .qubit_parameters [qb ]['T2' ]
72
+ self .current_circuit .add_qubit (qb , t1 = t1 , t2 = t2 )
72
73
73
74
def visit_gatelist (self , node , children ):
74
75
self .timestep += self .timestep_increment
@@ -104,11 +105,16 @@ def visit_id(self, node, children):
104
105
return node .text
105
106
106
107
def visit_meas (self , node , children ):
107
- self .current_circuit .add_waiting_gates (tmin = 0 , tmax = self .timestep + self .timestep_increment_sgl )
108
+ for b in self .qubit_names :
109
+ p_exc = self .qubit_parameters [b ]['frac1_0' ]
110
+ p_dec = 1 - self .qubit_parameters [b ]['frac1_1' ]
111
+ ro_gate = ct .ButterflyGate (b , p_exc = p_exc , p_dec = p_dec ,
112
+ time = self .timestep )
113
+ self .current_circuit .add_gate (ro_gate )
114
+ self .current_circuit .add_waiting_gates (tmin = 0 , tmax = self .timestep )
108
115
self .current_circuit .order ()
109
116
110
117
self .circuits .append (self .current_circuit )
111
118
112
119
def generic_visit (self , node , children ):
113
120
pass
114
-
0 commit comments