Skip to content

Commit aeb4e3a

Browse files
add additional tests
these tests specifically target gates that are handled differently for OpenQASM generation
1 parent 02236d8 commit aeb4e3a

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
OPENQASM 2.0;
2+
include "qelib1.inc";
3+
qreg qb[4];
4+
creg cb[2];
5+
reset qb[0];
6+
reset qb[1];
7+
x qb[1];
8+
reset qb[2];
9+
h qb[2];
10+
reset qb[3];
11+
x qb[3];
12+
h qb[3];
13+
cx qb[1], qb[2];
14+
ccx qb[0], qb[1], qb[2];
15+
cx qb[1], qb[2];
16+
h qb[2];
17+
measure qb[2] -> cb[0];
18+
measure qb[3] -> cb[1];
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
qubit qb0
2+
qubit qb1
3+
qubit qb2
4+
qubit qb3
5+
cbit cb0
6+
cbit cb1
7+
PrepZ qb0
8+
PrepZ qb1
9+
X qb1
10+
PrepX qb2
11+
PrepX qb3
12+
X qb3
13+
Fredkin qb0,qb1,qb2
14+
MeasX qb2
15+
MeasZ qb3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-------QASM Generation Pass:
2+
3+
module main ( ) {
4+
qbit qb[4];
5+
cbit cb[2];
6+
PrepZ ( qb[0] , 0 );
7+
PrepZ ( qb[1] , 1 );
8+
PrepX ( qb[2] , 0 );
9+
PrepX ( qb[3] , 1 );
10+
Fredkin ( qb[0] , qb[1] , qb[2] );
11+
cb[0] = MeasX ( qb[2] );
12+
cb[1] = MeasZ ( qb[3] );
13+
}
14+
15+
--------End of QASM generation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This file is targetted to test gates that have are handled in special ways
2+
// for OpenQASM generation
3+
int main () {
4+
qbit qb[4];
5+
cbit cb[2];
6+
7+
PrepZ( qb[0], 0 );
8+
PrepZ( qb[1], 1 );
9+
PrepX( qb[2], 0 );
10+
PrepX( qb[3], 1 );
11+
12+
Fredkin( qb[0], qb[1], qb[2] );
13+
14+
cb[0] = MeasX( qb[2] );
15+
cb[1] = MeasZ( qb[3] );
16+
17+
return 0;
18+
}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
total_gates = 3
2+

0 commit comments

Comments
 (0)