Commit 3b215c7d authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Make it an 8-qubit adder to make it more difficult


Signed-off-by: Nguyen, Thien Minh's avatarThien Nguyen <nguyentm@ornl.gov>
parent 4992e38a
......@@ -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
......@@ -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]);
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment