uniqc.circuit_builder.qram module¶
Quantum RAM (QRAM) data structure.
Provides a simple binary-addressed classical memory used by quantum circuits. A QRAM is declared with an address size and data size; at runtime it stores integers (0 <= value < 2^data_size) indexed by addresses (0 <= addr < 2^addr_size).
Example usage in OriginIR-ext:
QRAMDECL my_ram 3,6
QINIT 9
CREG 0
my_ram q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7],q[8]
The above declares my_ram as a QRAM with 3-bit address and 6-bit data
(9 qubits total). Callers index it as
my_ram q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7],q[8] where q[0..2] are
the address bits (q[0] = LSB) and q[3..8] are the data bits (q[3] = LSB).
- class uniqc.circuit_builder.qram.QRAM(name, addr_size, data_size)[source]¶
Bases:
objectA simple binary-addressed quantum RAM.
- Parameters:
name – Identifier for this QRAM instance.
addr_size – Number of address qubits (determines number of entries).
data_size – Number of data qubits (determines max storable value).
- property max_value¶
2^data_size - 1.
- Type:
Maximum storable value
- property num_entries¶
2^addr_size.
- Type:
Number of addressable entries
- read(addr)[source]¶
Read the value stored at addr.
- Parameters:
addr – Address index (0 <= addr < 2^addr_size).
- Returns:
The stored integer.
- Raises:
IndexError – If addr is out of range.
- reset(value=0)[source]¶
Reset all entries to value (default 0).
- Parameters:
value – Value to fill every address with.
- Raises:
ValueError – If value exceeds the data capacity.
- property total_qubits¶
address + data.
- Type:
Total number of qubits required