QRAM 指针式读写

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)[源代码]

基类: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)[源代码]

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

参数:

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.

返回:

quantum memory pointer to the shifted base address.

返回类型:

QPtr

抛出:

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)[源代码]

基类:object

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

load(data)[源代码]

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

参数:

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

store(data)[源代码]

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

参数:

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