Skip to content

OpenQASM support #40

@anpaz

Description

@anpaz

Is your feature request related to a problem? Please describe.
It would be great if we could visualize an OpenQASM circuit using q-viz.

Describe the solution you'd like
Ideally this would all work using just javascript. We would have a javascript method that takes OpenQASM as a string, and parse it into a Sqore that can then be visualized. For example:

const teleport = `
    // quantum teleportation example
    OPENQASM 2.0;
    include "qelib1.inc";
    qreg q[3];
    creg c0[1];
    creg c1[1];
    creg c2[1];
    // optional post-rotation for state tomography
    gate post q { }
    u3(0.3,0.2,0.1) q[0];
    h q[1];
    cx q[1],q[2];
    barrier q;
    cx q[0],q[1];
    h q[0];
    measure q[0] -> c0[0];
    measure q[1] -> c1[0];
    if(c0==1) z q[2];
    if(c1==1) x q[2];
    post q[2];
    measure q[2] -> c2[0];
`;
const circuit = parse(teleport);
qviz.draw(circuit, sampleDiv, qviz.STYLES['Default']);

For OpenQASM 3.0, we might need to do something similar to what we do with Q#, i.e. run a trace of the program and generate the json from the corresponding gates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestGood for Hacktoberfest participantsenhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions