-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Problem Statement
IfElse Operations in OpenQASM can be based on more than just equality conditions.
The underlying MQT Core framework already supports all of the different types of IFElse Operations, such as different comparison conditions and checks that only use subsets of classical registers or single classical bits.
Furthermore, we currently only allow IfElse Operations that contain only a single instruction in the "then" block. This makes tracking the current operation easier, but obviously does not match the full OpenQASM standard. We should therefore implement support for multi-instruction bodies accordingly.
The following are some code examples that should work in standard OpenQASM but are not allowed/parsed correctly by the debugger:
qreg q[3];
creg c[3];
...
if (c == 0) {
x q[0];
}
This only works without the if body:
if (c == 0) x q[0];
qreg q[3];
creg c[3];
...
if (c == 0) {
x q[0];
}
This is not supported by the Debugger's parser at all.
if (c > 0) x q[0];
The debugger only supports equality conditions for if blocks, but the simulation backend supports other conditions, too, so this should be a straightforward enhancement.
Proposed Solution
In the DDSimDebug.cpp backend and the CodePreprocessor.cpp, support for the corresponding operation types should be added when stepping through the code.