OpenQASM
Jump to navigation
Jump to search
This article relies too much on references to primary sources. (September 2018) (Learn how and when to remove this template message) |
Open Quantum Assembly Language (OpenQASM; pronounced open kazm[1]) is an intermediate representation for quantum instructions. The language was first described in a paper published in July 2017,[1] and source code was released as part of IBM's Quantum Information Software Kit (QISKit) for use with their IBM Q Experience cloud quantum computing platform.[2] The language has similar qualities to traditional hardware description languages such as Verilog.
Examples[edit]
The following is an example of OpenQASM source code from the official library. The program adds two four-bit numbers.[3]
// quantum ripple-carry adder from Cuccaro et al, quant-ph/0410184
OPENQASM 2.0;
include "qelib1.inc";
gate majority a,b,c
{
cx c,b;
cx c,a;
ccx a,b,c;
}
gate unmaj a,b,c
{
ccx a,b,c;
cx c,a;
cx a,b;
}
qreg cin[1];
qreg a[4];
qreg b[4];
qreg cout[1];
creg ans[5];
// set input states
x a[0]; // a = 0001
x b; // b = 1111
// add a to b, storing result in b
majority cin[0],b[0],a[0];
majority a[0],b[1],a[1];
majority a[1],b[2],a[2];
majority a[2],b[3],a[3];
cx a[3],cout[0];
unmaj a[2],b[3],a[3];
unmaj a[1],b[2],a[2];
unmaj a[0],b[1],a[1];
unmaj cin[0],b[0],a[0];
measure b[0] -> ans[0];
measure b[1] -> ans[1];
measure b[2] -> ans[2];
measure b[3] -> ans[3];
measure cout[0] -> ans[4];
References[edit]
- ^ a b Cross, Andrew W.; Bishop, Lev S.; Smolin, John A.; Gambetta, Jay M. "Open Quantum Assembly Language". arXiv:1707.03429.
- ^ qiskit-openqasm: OpenQASM specification, International Business Machines, 2017-07-04, retrieved 2017-07-06
- ^ "openqasm/adder.qasm at master · QISKit/openqasm · GitHub".
External links[edit]
- OpenQASM on GitHub