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
dbaff28f
Commit
dbaff28f
authored
Sep 21, 2021
by
Nguyen, Thien Minh
Browse files
added a unit test case for the adder circuit compilation
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
0a931164
Changes
1
Hide whitespace changes
Inline
Side-by-side
mlir/parsers/qasm3/tests/test_subroutine.cpp
View file @
dbaff28f
...
...
@@ -84,6 +84,70 @@ print("Avg <X0X1> = ", exp_val);
EXPECT_FALSE
(
qcor
::
execute
(
sub1
,
"check_deuteron"
));
}
TEST
(
qasm3VisitorTester
,
checkSubroutineAdder
)
{
const
std
::
string
sub1
=
R"#(OPENQASM 3;
gate ccx a,b,c
{
h c;
cx b,c; tdg c;
cx a,c; t c;
cx b,c; tdg c;
cx a,c; t b; t c; h c;
cx a,b; t a; tdg b;
cx a,b;
}
gate majority a, b, c {
cx c, b;
cx c, a;
ccx a, b, c;
}
gate unmaj a, b, c {
ccx a, b, c;
cx c, a;
cx a, b;
}
qubit cin;
qubit a[8];
qubit b[8];
qubit cout;
bit ans[9];
// Input values:
uint[8] a_in = 5;
uint[8] b_in = 4;
for i in [0:8] {
if (bool(a_in[i])) {
x a[i];
}
if (bool(b_in[i])) {
x b[i];
}
}
// add a to b, storing result in b
majority cin, b[0], a[0];
for i in [0: 7] {
majority a[i], b[i + 1], a[i + 1];
}
cx a[7], cout;
for i in [6: -1: -1] {
unmaj a[i], b[i+1], a[i+1];
}
unmaj cin, b[0], a[0];
measure b[0:7] -> ans[0:7];
measure cout[0] -> ans[8];)#"
;
auto
llvm_ir
=
qcor
::
mlir_compile
(
sub1
,
"check_deuteron"
,
qcor
::
OutputType
::
LLVMIR
,
false
);
std
::
cout
<<
llvm_ir
<<
"
\n
"
;
}
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
auto
ret
=
RUN_ALL_TESTS
();
...
...
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