QRAM pointer-style read/write

oracq.infrastructure.qmem

Pointer-style reads and writes of QRAM data structures: C-style base addresses, offsets, multidimensional views and random writes.

class oracq.infrastructure.qmem.QMem(builder, resource, *, shape=None, _base=None)[source]

Bases: object

Multidimensional array view of a QRAM resource: row-major flattening, with indices being integers or register views.

property strides

Row-major strides per dimension, i.e. the address increment of advancing one index along that dimension.

property address_width

Address width of the underlying QRAM resource.

property data_width

Data word width of the underlying QRAM resource.

ptr(base=None)[source]

Return a pointer; base is an integer offset or a register view holding an address, a quantum pointer.

Parameters:

base – integer offset, or a register view whose bit width does not exceed the address width; omitted keeps the base address of the current view.

Returns:

quantum memory pointer to the shifted base address.

Return type:

QPtr

Raises:

ValidationError – the base is neither an integer nor a register view, or its bit width exceeds the limit.

class oracq.infrastructure.qmem.QPtr(mem, addr)[source]

Bases: object

QRAM pointer: base address + offset, dereferenceable for reads (XOR-Load) or random writes (Store).

load(data)[source]

XOR-Load: data ^= M[addr]; address computation is automatically restored to zero, and superposed addresses are naturally supported.

Parameters:

data – view of the same width as the data word, into which the hit content is XORed.

store(data)[source]

Random write: M[addr] := d. At execution time the address and data must be in a definite basis state; no gate cost is counted.

Parameters:

data – view of the same width as the data word, providing the content to write.