-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support for casting of OpenQASM 3.0 types #32
Labels
enhancement
New feature or request
Milestone
Comments
burgholzer
pushed a commit
that referenced
this issue
Jun 2, 2023
burgholzer
pushed a commit
that referenced
this issue
Jun 2, 2023
Merged
burgholzer
added a commit
that referenced
this issue
Dec 13, 2023
This PR replaces the existing OpenQASM 2.0 parser with a new OpenQASM 3.0 parser. The new parser now builds a syntax tree, where type checking, constant evaluation, and translation to the Quantum circuit. The parser can handle the following new features: ### New Syntax New syntax for declaring bits, qubit, measure operations. The old syntax (`creg`, `qreg`) is still supported. ```qasm qubit[8] q; bit[8] c; c[0] = measure q[0]; measure q[1] -> c[1]; if (c[0] == 1) { x q[0]; } ``` ### Gate modifiers Gate modifiers (`inv`, `ctrl`, and `negctrl`) are now supported. This replaces the `c` prefix. See the OpenQASM 3.0 specification for more information: https://openqasm.com/language/gates.html#quantum-gate-modifiers ```qasm ctrl @ x q[0], q[1]; // Equivalent to cx q ctrl(2) @ x q[0], q[1], q[2]; // Equivalent to ccx q; ``` ### Classical constant values The parser now supports classical computation with constant values. This can be used to e.g. define the number of quantum registers. ```qasm const uint N = 4; qubit[N * 2]; x qubit[N * 2 - 1]; ``` Additionally, all features of the previous parser are still supported. The big features from OpenQASM 3.0 still missing are: - classical computational features such as loops, functions, etc. (see #33) - types such as bools, floats, angles, complex types, etc. (see #30, #32) - `pow` modifier (#27) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lukas Burgholzer <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The new OpenQASM standard introduces many additional datatypes besides quantum and classical registers. This allows to describe classical components of quantum algorithms in a very intuitive way. As a first step, support for all kinds of new types should be added to the QFR library and, correspondingly, to the QuantumComputation class. For details on all the new typed provided by the standard, see https://qiskit.github.io/openqasm/language/classical.html.
The standard provides the means for converting between the available types. For details, see https://qiskit.github.io/openqasm/language/types.html#casting-specifics.
This depends on #30 for the availability of all the types.
The text was updated successfully, but these errors were encountered: