Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
qcor
Commits
3b215c7d
Commit
3b215c7d
authored
Sep 21, 2021
by
Nguyen, Thien Minh
Browse files
Make it an 8-qubit adder to make it more difficult
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
4992e38a
Changes
1
Hide whitespace changes
Inline
Side-by-side
mlir/parsers/qasm3/examples/adder.qasm
View file @
3b215c7d
...
...
@@ -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. i
4
vs. i64 (shift value)
// e.g. i
8
vs. i64 (shift value)
uint[64] a_in = 1;
uint[64] b_in = 1
4
;
uint[64] b_in = 1
5
;
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment