Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #3 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cat_staten04.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4 4
0 H 1 0 0
1 CNOT 2 1 0 1 0
2 CNOT 2 2 1 1 1
3 CNOT 2 3 2 1 2
16 changes: 16 additions & 0 deletions cat_staten04.qasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OPENQASM 2.0;
include "qelib1.inc";
qreg q[16];
creg c[16];
u2(0,3.14159265358979) q[10];
cx q[11],q[10];
cx q[6],q[11];
u2(0,3.14159265358979) q[6];
u2(0,3.14159265358979) q[7];
cx q[6],q[7];
u2(0,3.14159265358979) q[6];
u2(0,3.14159265358979) q[7];
measure q[10] -> c[0];
measure q[6] -> c[2];
measure q[11] -> c[1];
measure q[7] -> c[3];
21 changes: 21 additions & 0 deletions cat_staten04.scaffold
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

scaff_module catN ( qbit *bit, const int n ) {
H( bit[0] );
for ( int i=1; i < n; i++ ) {
CNOT( bit[i], bit[i-1] );
}
}

scaff_module unCatN ( qbit *bit, const int n ) {
for ( int i=n-1; i > 0; i-- ) {
CNOT( bit[i], bit[i-1] );
}
H( bit[0] );
}

int main () {
qbit bits[4];
catN( bits, 4 );
return 0;
}

21 changes: 21 additions & 0 deletions compile.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cat_staten04.scaffold
file: cat_staten04
[Scaffold.makefile] Inserting reverse function signatures
python ../ScaffCC/scaffold/insert_reverse.py cat_staten04_merged.scaffold
[Scaffold.makefile] Compiling cat_staten04_merged_reverse_insert.scaffold ...
[Scaffold.makefile] Transforming cbits ...
[Scaffold.makefile] Unrolling Loops (1) ...
[Scaffold.makefile] Cloning Functions (1) ...
[Scaffold.makefile] Dead Argument Elimination (1) ...
[Scaffold.makefile] Unrolling Loops (2) ...
[Scaffold.makefile] Cloning Functions (2) ...
[Scaffold.makefile] Dead Argument Elimination (2) ...
[Scaffold.makefile] Unrolling Loops (3) ...
[Scaffold.makefile] Cloning Functions (3) ...
[Scaffold.makefile] Dead Argument Elimination (3) ...
[Scaffold.makefile] Rotation tool not built, skipping rotation decomposition ...
[Scaffold.makefile] Internalizing and Removing Unused Functions ...
[Scaffold.makefile] Inserting Reverse Functions...
[Scaffold.makefile] Flattening modules ...
[Scaffold.makefile] Generating OpenQASM ...
[Scaffold.makefile] OpenQASM written to cat_staten04.qasm ...
9 changes: 6 additions & 3 deletions compile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import subprocess as sp
import sys
import os
scaffcc_path=""
scaffcc_path="../ScaffCC/"
triq_path=""
out_path=""

out_file=open("compile.log",'w')
sp.call([os.path.join(scaffcc_path, "scaffold.sh"), "-b", sys.argv[1]], stdout=out_file)

base_name = ''.join(sys.argv[1].split('.')[:-1])
ir_name = base_name + ".qasm"
dag_name = base_name + ".in"
out_name = base_name + ".qasm"
sp.call(["python3.6", "./ir2dag.py", ir_name, dag_name])

sp.call([os.path.join(triq_path, "triq"), os.path.join(triq_path, dag_name), os.path.join(triq_path, out_name), sys.argv[2], " 0 "])
sp.call(["python", "./ir2dag.py", ir_name, dag_name])

print(os.path.join(triq_path, "triq"), os.path.join(triq_path, dag_name), os.path.join(triq_path, out_name), sys.argv[2], " 0 ")
sp.call(["./"+os.path.join(triq_path, "triq"), os.path.join(triq_path, dag_name), os.path.join(triq_path, out_name), sys.argv[2], " 0 "])

9 changes: 7 additions & 2 deletions ir2dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ def process_gate(line, f_out):
break
for g in gset2:
if line.startswith(g):
qbit = line.split()[1].split('[')[1].split(']')[0]
angle = line.split()[0].split('(')[1].split(')')[0]
#manually fix spacing issue
line = line.replace("[", "[ ")
line = line.replace("]", " ]")
qbit = line.split()[4]
angle = line.split()[1]
# qbit = line.split()[1].split('[')[1].split(']')[0]
# angle = line.split()[0].split('(')[1].split(')')[0]

print(global_gate_id, g, qbit, angle)
f_out.write(str(global_gate_id) + ' ' + gate_names[g] + ' 1 ' + qbit)
Expand Down
Empty file.
Binary file added src/backtrack.o
Binary file not shown.
Binary file added src/circuit.o
Binary file not shown.
Binary file added src/expt.o
Binary file not shown.
Binary file added src/gate.o
Binary file not shown.
Binary file added src/machine.o
Binary file not shown.
Binary file added src/mapper.o
Binary file not shown.
Binary file added src/optimize_1q.o
Binary file not shown.
Binary file added src/pattern.o
Binary file not shown.
Binary file added src/quaternion.o
Binary file not shown.
Binary file added src/targetter.o
Binary file not shown.
Binary file added triq
Binary file not shown.