diff --git a/.gitignore b/.gitignore index d7ba40b..d005a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /.vscode # Build -sim_qasm test_wgt_storage /build *.so diff --git a/README.md b/README.md index 2ae80c5..dcc9c6c 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ x q[0]; measure q[0]->c[0]; measure q[1]->c[1]; ``` -This code can be found in [`qasm/circuits/bell_state.qasm`](qasm/circuits/bell_state.qasm) and can be run with `./build/qasm/sim_qasm qasm/circuits/bell_state.qasm`. All gates specified in [qelib1.inc](https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/qasm/libs/qelib1.inc) are supported, as well as measurements. Custom definitions of gates and classical conditioning are currently not supported. +This code can be found in [`qasm/circuits/bell_state.qasm`](qasm/circuits/bell_state.qasm) and can be run with `./build/qasm/run_qasm_on_qmdd qasm/circuits/bell_state.qasm`. All gates specified in [qelib1.inc](https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/qasm/libs/qelib1.inc) are supported, as well as measurements. Custom definitions of gates and classical conditioning are currently not supported. ## Documentation diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 17080f5..1ac660a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -35,4 +35,4 @@ add_example(test_algs test_algs.c) target_sources(test_algs PRIVATE ${ALGORITHM_EXAMPLES}) add_executable(circuit_equivalence circuit_equivalence.c) -target_link_libraries(circuit_equivalence qsylvan qsylvan_qasm_parser_qmdd) +target_link_libraries(circuit_equivalence qsylvan qsylvan_qasm_parser) diff --git a/examples/circuit_equivalence.c b/examples/circuit_equivalence.c index ca22084..7030d22 100644 --- a/examples/circuit_equivalence.c +++ b/examples/circuit_equivalence.c @@ -5,7 +5,7 @@ #include #include #include -#include "../qasm/simple_parser.h" +#include "../qasm/qsylvan_qasm_parser.h" #define max(a,b) ((a > b) ? a : b) diff --git a/qasm/CMakeLists.txt b/qasm/CMakeLists.txt index 07ec4bf..cb340b4 100644 --- a/qasm/CMakeLists.txt +++ b/qasm/CMakeLists.txt @@ -1,50 +1,18 @@ -#set(SOURCES -# QASM_to_circuit.c -# circuit.c -#) -#add_executable(test_circuit test_circuit.c ${SOURCES}) -#target_link_libraries(test_circuit qsylvan) -#add_executable(qsylvan_qasm qsylvan_qasm.c ${SOURCES}) -#target_link_libraries(qsylvan_qasm qsylvan popt) - -# allow the parser to be included in other places as a library -# (without compiling eval_expr.cpp again) - -#add_library(qsylvan_qasm_parser) -#target_sources(qsylvan_qasm_parser -# PRIVATE -# simple_parser.cpp -# parse_math/eval_expr.cpp -# PUBLIC -# simple_parser.h) -# -#add_executable(sim_qasm sim_qasm.c) -#target_link_libraries(sim_qasm qsylvan qsylvan_qasm_parser) - - -# QASM simulator with qmddd - -add_library(qsylvan_qasm_parser_qmdd) -target_sources(qsylvan_qasm_parser_qmdd +# 1. Compile qasm parser as separate library +# (to allow the parser to be included in other places as a library, without +# compiling eval_expr.cpp again) +add_library(qsylvan_qasm_parser) +target_sources(qsylvan_qasm_parser PRIVATE - simple_parser.cpp + qsylvan_qasm_parser.cpp parse_math/eval_expr.cpp PUBLIC - simple_parser.h) + qsylvan_qasm_parser.h) +# 2. QMDD QASM simulator add_executable(run_qasm_on_qmdd run_qasm_on_qmdd.c) -target_link_libraries(run_qasm_on_qmdd qsylvan qsylvan_qasm_parser_qmdd) - - -# QASM simulator with mtbdd - -add_library(qsylvan_qasm_parser_mtbdd) -target_sources(qsylvan_qasm_parser_mtbdd - PRIVATE - simple_parser.cpp - parse_math/eval_expr.cpp - PUBLIC - simple_parser.h) +target_link_libraries(run_qasm_on_qmdd qsylvan qsylvan_qasm_parser) +# 3. MTBDD QASM simulator add_executable(run_qasm_on_mtbdd run_qasm_on_mtbdd.c) -target_link_libraries(run_qasm_on_mtbdd qsylvan qsylvan_qasm_parser_mtbdd) +target_link_libraries(run_qasm_on_mtbdd qsylvan qsylvan_qasm_parser) diff --git a/qasm/simple_parser.cpp b/qasm/qsylvan_qasm_parser.cpp similarity index 99% rename from qasm/simple_parser.cpp rename to qasm/qsylvan_qasm_parser.cpp index b8af1e3..3bf5cc9 100644 --- a/qasm/simple_parser.cpp +++ b/qasm/qsylvan_qasm_parser.cpp @@ -23,7 +23,7 @@ #include #include -#include "simple_parser.h" +#include "qsylvan_qasm_parser.h" #include "parse_math/eval_expr.hpp" /** diff --git a/qasm/simple_parser.h b/qasm/qsylvan_qasm_parser.h similarity index 100% rename from qasm/simple_parser.h rename to qasm/qsylvan_qasm_parser.h diff --git a/qasm/run_qasm_on_mtbdd.c b/qasm/run_qasm_on_mtbdd.c index 4fdce2f..ebc1f14 100644 --- a/qasm/run_qasm_on_mtbdd.c +++ b/qasm/run_qasm_on_mtbdd.c @@ -24,7 +24,7 @@ #include #include -#include "simple_parser.h" // TODO: rename in qsylvan_qasm_parser.h +#include "qsylvan_qasm_parser.h" /** * diff --git a/qasm/run_qasm_on_qmdd.c b/qasm/run_qasm_on_qmdd.c index a925504..7d6b315 100644 --- a/qasm/run_qasm_on_qmdd.c +++ b/qasm/run_qasm_on_qmdd.c @@ -20,7 +20,7 @@ #include #include "qsylvan.h" -#include "simple_parser.h" +#include "qsylvan_qasm_parser.h" /*********************************************/ diff --git a/qasm/test/test_sim_qasm.py b/qasm/test/test_sim_qasm.py index 1802aec..90f3b5e 100644 --- a/qasm/test/test_sim_qasm.py +++ b/qasm/test/test_sim_qasm.py @@ -1,5 +1,5 @@ """ -Testing running sim_qasm from command line. +Testing running qmdd qasm simulator from command line. """ import os import subprocess @@ -39,7 +39,7 @@ def get_vector(qasm_file : str, args : list): ['--reorder'], ['--reorder-swap']]) class TestCircuits: """ - Test sim_qasm on all given circuits, with CL arguments given above. + Test on all given circuits, with CL arguments given above. """ def test_adder_n4(self, cl_args : str):