Bit (register) declaration
A bit or bit register must be declared before they can be used. The general form is given as follows:
bit[
size]
identifier
Grammar for bit (register) declaration
bit-declaration:
bit
array-size-declarationopt identifier
array-size-declaration:
[
integer-literal]
Its form is similar to the declaration of an arbitrary variable,
whereby the type of the variable is specified first, i.e.
bit
denotes that the declared variable is of type Bit.
and bit[
size]
denotes that the declared variable is of type BitArray.
The size of a bit register is declared by an integer value between square brackets [
size]
.
The name of the bit (register) is defined through an identifier.
The declaration of a bit (register) is optional, Nevertheless, since measurement outcomes are stored as bits, measure instructions require a previously declared bit (register).
Find below examples, respectively, of a single bit declaration and bit register declaration.
Example
The individual bits of a bit register can be referred to by their register index,
e.g. in the example of the Bit register declaration,
the statement b[0] = measure q[0]
indicates that the measurement outcome is stored at the bit
located at index 0
of the bit register b
.
Note that in the case of a single bit, the bit is referred to through its identifier,
not through a register index.