A complete hardware implementation of a multilayer perceptron (MLP) neural network for MNIST handwritten digit recognition, built with Logisim Evolution.
This project demonstrates a fully digital circuit that classifies 16×16 binarized MNIST images (0–9) in real time. The network comprises:
- Input layer: 256 inputs (16×16 pixels)
- Hidden layer: 128 neurons with ReLU activation
- Output layer: 10 neurons for digit classes 0–9
- Total parameters: ~34,000 weights
All layers and activation functions are realized in Logisim Evolution, with trained weights stored in ROM modules.
Logisim_MLP/ ├── MLP_circuit.circ # Main Logisim circuit file ├── weights/ # Generated weight and bias files │ ├── layer1_weights.txt │ ├── layer1_bias.txt │ ├── layer2_weights.txt │ └── layer2_bias.txt ├── python/ # Python scripts for weight generation │ └── generate_weights.py └── README.md # This file
- Logisim Evolution ≥ 3.8.0
- Java ≥ 8 (for Logisim)
- Python ≥ 3.8 (for weight generation)
-
Install Python dependencies (if any): pip install numpy
-
Run the weight-generation script: cd python python generate_weights.py
-
Confirm the output files in
weights/:
layer1_weights.txtlayer1_bias.txtlayer2_weights.txtlayer2_bias.txt
- Open Logisim Evolution.
- Go to File → Open and select
MLP_circuit.circ. - Expand the HiddenLayer subcircuit, right-click the weight ROM, choose Load Image, and load:
weights/layer1_weights.txtweights/layer1_bias.txt
- Repeat for the OutputLayer:
weights/layer2_weights.txtweights/layer2_bias.txt
- In Logisim, enable ticks: Simulate → Ticks Enabled (Ctrl+K).
- Set clock frequency: Simulate → Tick Frequency → 1 kHz or higher.
- Start simulation (Ctrl+K).
- Use the on-screen joystick to draw a digit on the RGB video input.
- Set the start input to
1to trigger classification. - After ~30–40 s of simulated time, the predicted digit appears on the 7-segment display.
- Reduce frequency to 1 Hz for single-step inspection.
- Use the probe tool to monitor:
- InputLayer outputs (256 pixel values)
- HiddenLayer outputs (128 neuron activations)
- OutputLayer scores (10 class logits)
Lloyd Kwak
GitHub: lloydkwak
This project is released under the MIT License. Feel free to use and modify for educational purposes.