- Clone the repository
- Install the dependencies
- run the following command in the terminal
mkdir build
cd build
cmake ..
make
./QRAM_simulator
- run
pip install ./
- you can find the example usage in example.py
We have wrapped QRAM into a class, you can use it by including the header file and create an instance of the class. The following is an example of how to use it.
// we have two class: QRAM_base and QRAM_binary (QRAM_binary is the accelerated version)
// here is an example of how to use QRAM_base
QRAM_base qram_base(n, k, memory, address);
// first we need to create the circuit, call create_acc_matrix()
qram_base.create_acc_matrix();
// if we want to simulate noise, we need to call add_error()
qram_base.add_error(noise_list);
// then we can run the circuit, call run_baseline()
qram_base.run_baseline();
// if you want to print the result, call print_result()
qram_base.print_result(true);
// for QRAM_binary, the usage is the same, but we need to call run() instead of run_baseline()
QRAM_binary qram(n, k, memory, address);
qram.create_acc_matrix();
qram.add_error(noise_list);
qram.run();
qram.print_result(true);n is the layer number, k is the data length.
memory is the classical memory(for QRAM to read).
address is the address of the data we want to read (you can see it as a superposition state)
noise_list is needed if you want to test noise on QRAM.
The definition is as follows:
Each noise is defined by a NoiseInfo struct.
NoiseInfo has 5 fields:
- process: the process that the noise is added to, we have 4 processes: ADDRESS_INPUT, DATA_INPUT, DATA_OUTPUT, ADDRESS_OUTPUT
- bit: it's defined by the process, for ADDRESS_INPUT and ADDRESS_OUTPUT, it's the address bit for DATA_INPUT and DATA_OUTPUT, it's the data bit (you can see in the figure as A1 or D1)
- operation: the operation that the noise is added to, we have 5 operations: ADDRESS_BUS, DATA_BUS_INPUT, DATA_BUS_OUTPUT, ROUTING_START, ROUTING_END, INTERNAL_SWAP, DATA_COPY
- layer: defined the layer of the operation. all the fields above are used to locate when will the noise happen (it will happen before the operation)
- bit_pos: defined the position of the noise in the circuit it has 3 fields: layer, shift, data_qubit layer: the layer of the qubit shift: the shift of the qubit in the layer (start from 0) data_qubit: 0 for address qubit, 1 for data qubit
- error_rate: define the probability of X, Y, Z error
