circuits / toffoli-gate

Toffoli Gate (CCNOT)

FEATURED

The Toffoli gate (CCNOT) flips the target qubit only when both control qubits are |1⟩. Fundamental for reversible computing.

quantumcomputer.dev
openqasm3q3 gatesdepth220 views0 saves0 forks0 downloads
1OPENQASM 2.0;
2include "qelib1.inc";
3qreg q[3];
4creg c[3];
5// Set controls to |1>
6x q[0]; x q[1];
7// Toffoli
8ccx q[0],q[1],q[2];
9measure q -> c;

Cite this circuit

MIT
quantumcomputer.dev. "Toffoli Gate (CCNOT)". quantumcomputer.dev/circuits/toffoli-gate. 2026.