QuantumBFS / YaoQASM.jl

Bidirectional transformation between Yao IR and QASM.
Apache License 2.0
11 stars 4 forks source link

fix qasm to yao translation #5

Closed GiggleLiu closed 4 years ago

GiggleLiu commented 4 years ago

Changes

Notes

GiggleLiu commented 4 years ago

Now the following example works perfectly, isn't this amazing @Roger-luo @wangleiphy

julia> src1 = """
       OPENQASM 2.0;

       gate cu1(theta) a,b
       {
           U(0,0,theta/2) a;
           CX a,b;
           U(0,0,-theta/2) b;
       }

       qreg q[3];
       qreg a[2];
       creg c[3];
       creg syn[2];
       cu1(pi/2) q[0],q[1];
       """
"OPENQASM 2.0;\n\ngate cu1(theta) a,b\n{\n    U(0,0,theta/2) a;\n    CX a,b;\n    U(0,0,-theta/2) b;\n}\n\nqreg q[3];\nqreg a[2];\ncreg c[3];\ncreg syn[2];\ncu1(pi/2) q[0],q[1];\n"

julia> circ = @eval $(trans(parse_qasm(lex(src1))))
nqubits: 5
chain
├─ put on (1)
│  └─ chain
│     ├─ rot(Z gate, 0.7853981633974483)
│     ├─ rot(Y gate, 0)
│     └─ rot(Z gate, 0)
├─ control(1)
│  └─ (2,) X gate
└─ put on (2)
   └─ chain
      ├─ rot(Z gate, -0.7853981633974483)
      ├─ rot(Y gate, 0)
      └─ rot(Z gate, 0)
Roger-luo commented 4 years ago

can you fix the CI? @GiggleLiu the PR looks good in general. I'd like to merge it and register the package first.