Documentation of my process:
- Started by reading up about qubits and their represenation in a matricular form
- Went to IBM's website to read up about qiskit
- Found a lesson on the basics of quantum computing and basic gates with circuits
- Read up the blogs on each and decided to try making a sample circuit
- Opened up the circuit lab and played around with the interface finding new gates to read up about
- Tried making a smaller (half adder) using the CNOT gates
- Scaled up to the full adder with the CNOT and toffoli gates
FORMULA FOR THE CIRCUIT:
- SUM = X (xor) Y (xor) Z
- CARRY = XY (xor) YZ (xor) XZ
LOGIC:
- We encode each of the inputted values into a 3 digit binary number
- We use controlled-NOT gates to implement the binary addition logic. The target qubit is the qubit where the result will be stored (qubit 3 in our case), and the control qubits are the qubits representing the bits of the numbers to be added.
- we apply the same logic but with toffoli gates to take account the carry of the circuit
- we measure the output to take the value of the SUM and CARRY of the two inputs
Circuit diagram:
Logic table of the circuit:
x | y | z | Carry | Sum |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 1 |
0 | 1 | 0 | 0 | 1 |
0 | 1 | 1 | 1 | 0 |
1 | 0 | 0 | 0 | 1 |
1 | 0 | 1 | 1 | 0 |
1 | 1 | 0 | 1 | 0 |
1 | 1 | 1 | 1 | 1 |
OUTPUT: ( Test Case )
sources: