Skip to content

✨ Full Support of Classically-Controlled Operations is Missing #168

@DRovara

Description

@DRovara

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Anything related to C++ codeenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions