Loading mlir/parsers/qasm3/examples/adder.qasm +15 −11 Original line number Diff line number Diff line Loading @@ -2,6 +2,10 @@ * quantum ripple-carry adder * Cuccaro et al, quant-ph/0410184 */ // Summit compile: // Using DM-Sim: // qcor -linker g++ -qrt nisq adder.qasm -shots 1024 -qpu dm-sim[gpus:4] OPENQASM 3; gate ccx a,b,c Loading @@ -28,17 +32,17 @@ gate unmaj a, b, c { } qubit cin; qubit a[4]; qubit b[4]; qubit a[8]; qubit b[8]; qubit cout; bit ans[5]; bit ans[9]; // FIXME: left shift casting to handle different type: // e.g. i4 vs. i64 (shift value) // e.g. i8 vs. i64 (shift value) uint[64] a_in = 1; uint[64] b_in = 14; uint[64] b_in = 15; for i in [0:4] { for i in [0:8] { // FIXME: not able to do this inline.... bool b1 = bool(a_in[i]); bool b2 = bool(b_in[i]); Loading @@ -52,16 +56,16 @@ for i in [0:4] { // add a to b, storing result in b majority cin, b[0], a[0]; for i in [0: 3] { for i in [0: 7] { majority a[i], b[i + 1], a[i + 1]; } cx a[3], cout; cx a[7], cout; for i in [2: -1: -1] { for i in [6: -1: -1] { unmaj a[i], b[i+1], a[i+1]; } unmaj cin, b[0], a[0]; measure b[0:3] -> ans[0:3]; measure cout[0] -> ans[4]; No newline at end of file measure b[0:7] -> ans[0:7]; measure cout[0] -> ans[8]; No newline at end of file Loading
mlir/parsers/qasm3/examples/adder.qasm +15 −11 Original line number Diff line number Diff line Loading @@ -2,6 +2,10 @@ * quantum ripple-carry adder * Cuccaro et al, quant-ph/0410184 */ // Summit compile: // Using DM-Sim: // qcor -linker g++ -qrt nisq adder.qasm -shots 1024 -qpu dm-sim[gpus:4] OPENQASM 3; gate ccx a,b,c Loading @@ -28,17 +32,17 @@ gate unmaj a, b, c { } qubit cin; qubit a[4]; qubit b[4]; qubit a[8]; qubit b[8]; qubit cout; bit ans[5]; bit ans[9]; // FIXME: left shift casting to handle different type: // e.g. i4 vs. i64 (shift value) // e.g. i8 vs. i64 (shift value) uint[64] a_in = 1; uint[64] b_in = 14; uint[64] b_in = 15; for i in [0:4] { for i in [0:8] { // FIXME: not able to do this inline.... bool b1 = bool(a_in[i]); bool b2 = bool(b_in[i]); Loading @@ -52,16 +56,16 @@ for i in [0:4] { // add a to b, storing result in b majority cin, b[0], a[0]; for i in [0: 3] { for i in [0: 7] { majority a[i], b[i + 1], a[i + 1]; } cx a[3], cout; cx a[7], cout; for i in [2: -1: -1] { for i in [6: -1: -1] { unmaj a[i], b[i+1], a[i+1]; } unmaj cin, b[0], a[0]; measure b[0:3] -> ans[0:3]; measure cout[0] -> ans[4]; No newline at end of file measure b[0:7] -> ans[0:7]; measure cout[0] -> ans[8]; No newline at end of file