A comprehensive FPGA (Field-Programmable Gate Array) simulator featuring GPU acceleration, quantum computing integration, machine learning optimization, and realistic hardware modeling with power noise simulation.
- Configurable Logic Blocks (CLBs) with GPU-accelerated Look-Up Tables
- Block RAM (BRAM) with Error Correcting Code (ECC) support
- DSP Blocks for high-speed signal processing (MAC, FFT, FIR)
- Quantum Processing Unit (QPU) for quantum algorithm acceleration
- HDL Compilation from Verilog to bitstream
- Place & Route algorithms with ML optimization
- 🎮 GPU Acceleration using CuPy for massive parallelism (10-100x speedup)
- 🔬 Quantum Computing with Grover's search, QFT, and VQE algorithms
- 🧠 Machine Learning for routing optimization and prediction
- ⚡ Power Noise Modeling with thermal, supply, and crosstalk simulation
- 🛡️ Fault Tolerance with SEU injection and ECC recovery
- 🌐 Web Interface for real-time monitoring and control
# Clone the repository
git clone https://github.com/yourusername/fpga-simulator.git
cd fpga-simulator
# Install basic dependencies
pip install -r requirements.txt
# Or use make
make install# Install with all optional features
make install-all
# Or manually install components:
pip install numpy matplotlib flask # Basic
pip install cupy-cuda11x # GPU support (requires CUDA)
pip install qiskit qiskit-aer # Quantum computing
pip install scikit-learn scipy # Machine learning# Install development dependencies
make install-dev
# Or manually:
pip install -e ".[dev]"from fpga_simulator import AdvancedFPGAFabric
# Create an FPGA
fpga = AdvancedFPGAFabric(rows=8, cols=8, num_brams=4, num_dsps=2)
# Configure a CLB as an AND gate
clb = fpga.clbs[0][0]
clb.configure({'lut': [0]*15 + [1]}) # AND truth table
# Evaluate
result = clb.evaluate(np.array([1, 1, 0, 0]))
print(f"Output: {result.value}")# Start the web interface
python app_simple.py
# Or with make
make run-webOpen http://localhost:5000 in your browser for interactive visualization.
# Run interactive examples menu
python examples/basic_example.py
# Or specific examples:
python examples/neural_network.py # Neural network acceleration
python examples/quantum_search.py # Quantum algorithmsInteractive tutorial covering:
- CLB configuration and evaluation
- BRAM usage with ECC
- DSP operations (multiplication, MAC, filtering)
- Parallel processing
- HDL compilation
- Power and noise simulation
- Fault tolerance demonstration
- FPGA-accelerated neural network inference
- Quantized weights stored in BRAM
- DSP blocks for matrix multiplication
- CLB-based activation functions
- Performance benchmarking vs CPU
# Example: XOR learning on FPGA
fpga = AdvancedFPGAFabric(rows=8, cols=8, num_brams=2, num_dsps=4)
nn = FPGANeuralNetwork(fpga, input_size=2, hidden_size=4, output_size=1)- Grover's search algorithm
- Quantum Fourier Transform (QFT)
- Variational Quantum Eigensolver (VQE)
- Quantum phase estimation
- Quantum machine learning kernels
# Example: Quantum search for prime numbers
result = fpga.run_quantum_accelerated_search(32, is_prime)Sample Verilog code for compilation:
module full_adder(sum, cout, a, b, cin);
output sum, cout;
input a, b, cin;
// Implementation...
endmodulefpga-simulator/
├── fpga_simulator.py # Core simulator implementation
├── fpga_advanced_demo.py # Advanced feature demonstrations
├── fpga_web_interface.html # Interactive web visualization
├── app.py # Full Flask server
├── app_simple.py # Minimal Flask server
├── requirements.txt # Python dependencies
├── setup.py # Package installation
├── Makefile # Build automation
├── LICENSE # MIT License
├── README.md # This file
├── CONTRIBUTING.md # Contribution guidelines
├── examples/ # Example code
│ ├── basic_example.py # Interactive tutorial
│ ├── neural_network.py # NN accelerator demo
│ ├── quantum_search.py # Quantum algorithms
│ └── adder.v # Verilog examples
└── tests/ # Unit tests
└── test_basic.py # Basic component tests
AdvancedFPGAFabric
├── ConfigurableLogicBlock (CLB)
│ ├── GPUAcceleratedLUT
│ └── QuantumLogicBlock
├── BlockRAM (BRAM)
│ └── ECC Support
├── DSPBlock
│ ├── Multiply-Accumulate
│ └── FFT/FIR Processing
├── QuantumProcessingUnit (QPU)
│ ├── Grover's Algorithm
│ ├── QFT
│ └── VQE
└── Infrastructure
├── PlaceAndRoute
├── HDLParser
├── BitstreamGenerator
└── MLOptimizedRouter
| Operation | CPU Only | GPU Accelerated | Quantum | Speedup |
|---|---|---|---|---|
| 64 CLB Evaluation | 12.3ms | 1.2ms | - | 10.3x |
| 1k-point FFT | 8.5ms | 0.9ms | - | 9.4x |
| 16-item Search | 16 steps | 16 steps | 4 steps | 4.0x |
| Neural Network (100 neurons) | 45ms | 4.8ms | - | 9.4x |
- CLBs: Up to 256 (16x16 grid)
- BRAMs: Configurable (typically 4-8)
- DSPs: Configurable (typically 2-4)
- QPU: 5-qubit quantum processor
# Run all tests
make test
# With coverage
make coverage
# Specific test file
pytest tests/test_basic.py -v- Basic components (CLB, BRAM, DSP)
- Signal processing and noise models
- Fault injection and recovery
- Parallel execution
- GPU acceleration (if available)
- Quantum algorithms (if available)
- ML optimization (if available)
make help # Show all available commands
make check-deps # Check installed dependencies
make lint # Run code linting
make format # Format code with black
make clean # Clean generated files
make benchmark # Run performance benchmarks# Check if everything works
make quick-test
# Run specific examples
make run-neural # Neural network example
make run-quantum # Quantum algorithms
# Development setup
make dev-setupThe simulator includes an interactive web interface with:
- Real-time CLB activity visualization
- Power grid heatmap
- Performance metrics dashboard
- Fault injection controls
- Quantum state visualization
- 🎨 Modern, responsive design
- 📊 Real-time performance graphs
- 🔧 Interactive controls
- 📈 Resource utilization monitoring
- ⚡ Power and noise visualization
We welcome contributions! Please see our Contributing Guidelines for details.
- Additional HDL support (VHDL, SystemVerilog)
- More quantum algorithms
- Advanced routing algorithms
- Power optimization
- 3D visualization
- Additional examples and tutorials
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CuPy team for GPU acceleration
- Qiskit community for quantum computing integration
- scikit-learn for machine learning capabilities
- Flask for web framework
- Inspired by Xilinx Vivado and Intel Quartus
- 📧 Email: jon@finstad.org
Made with ❤️ by the Jon. :D
⭐ Star us on GitHub!