Skip to content

Reversible 1-bit quantum ALU implemented in Qiskit with opcode-controlled arithmetic and logic operations, validated on simulators and IBM Quantum hardware.

License

Notifications You must be signed in to change notification settings

mr-mohitrawat/quantum-reversible-alu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reversible Quantum ALU (1-bit)

This repository implements a 1-bit reversible Quantum Arithmetic Logic Unit (ALU) using Qiskit, designed with modular quantum circuits and executed on simulators and real IBM Quantum hardware.

The project demonstrates how classical ALU functionality can be mapped to unitary, reversible quantum logic, respecting quantum constraints such as no-cloning and reversibility.


✨ Features

  • Supports OR, AND, XOR, and ADD operations

  • Opcode-controlled operation selection

  • Custom reversible 4×1 quantum multiplexer

  • Explicit ancilla management and uncomputation

  • Fully unitary ALU core

  • Verified using a complete truth table

  • Executed on:

    • Qiskit Aer simulator
    • IBM Fake backend
    • Real IBM Quantum hardware

🧠 ALU Architecture

Inputs

  • a, b – data inputs
  • cin – carry-in (used only for ADD)
  • op[1:0] – opcode bits

Outputs

  • out – ALU result
  • carry – carry-out (meaningful only for ADD)

Opcode Mapping

op[1] op[0] Operation
0 0 OR
0 1 AND
1 0 XOR
1 1 ADD

The carry output is generated by the full adder and is only meaningful for the ADD operation. For logical operations, it is intentionally ignored.


✅ Truth Table Verification

All operations were validated against their classical truth tables. For non-ADD operations, cin is ignored and carry = 0.

ADD (Full Adder)

a b cin out carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1

All simulation and hardware results match the expected outputs.


📂 Project Structure

quantum-reversible-alu/
├── gates/
│   ├── and_gate.py
│   ├── or_gate.py
│   ├── xor_gate.py
│   ├── full_adder.py
│   └── mux_4_x_1.py
├── alu.py            # ALU construction (pure quantum logic)
├── run_circuit.py    # Backend execution helpers
├── alu.ipynb         # Entry-point demonstration notebook
├── requirements.txt
└── README.md

▶️ How to Run

1. Install dependencies

pip install -r requirements.txt

2. Run the demo

Open and run:

alu.ipynb

The notebook demonstrates:

  • Input initialization
  • Opcode selection
  • Measurement of out and carry
  • Execution on simulators and IBM Quantum backends

🧪 Measurement Strategy

Measurements are applied only at the top level to read the ALU result and carry-out. Intermediate qubits and ancilla are not measured to preserve reversibility and modularity.


🎯 Motivation

This project illustrates how a classical ALU can be redesigned using reversible quantum logic, highlighting key architectural differences between classical and quantum computation. The design emphasizes modularity, correctness, and hardware-awareness over circuit depth optimization.


🚀 Status

✔ Design complete ✔ Fully validated ✔ Executed on real quantum hardware

This implementation represents a finished and verified reference design.


📜 License

MIT License

About

Reversible 1-bit quantum ALU implemented in Qiskit with opcode-controlled arithmetic and logic operations, validated on simulators and IBM Quantum hardware.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors