OpenQASM


Open Quantum Assembly Language is an intermediate representation for quantum instructions. The language was first described in a paper published in July 2017, and source code was released as part of IBM's Quantum Information Software Kit for use with their IBM Q Experience cloud quantum computing platform. The language has similar qualities to traditional hardware description languages such as Verilog.

Examples

The following is an example of OpenQASM source code from the official library. The program adds two four-bit numbers.

// quantum ripple-carry adder from Cuccaro et al, quant-ph/0410184
OPENQASM 2.0;
include "qelib1.inc";
gate majority a,b,c
gate unmaj a,b,c
qreg cin;
qreg a;
qreg b;
qreg cout;
creg ans;
// set input states
x a; // a = 0001
x b; // b = 1111
// add a to b, storing result in b
majority cin,b,a;
majority a,b,a;
majority a,b,a;
majority a,b,a;
cx a,cout;
unmaj a,b,a;
unmaj a,b,a;
unmaj a,b,a;
unmaj cin,b,a;
measure b -> ans;
measure b -> ans;
measure b -> ans;
measure b -> ans;
measure cout -> ans;