← Back to Projects

FPGA Neural Network Robot

Autonomous obstacle-avoidance robot powered by a neural network deployed entirely in FPGA hardware on the Altera DE1-SoC (Cyclone V). Achieves ~1 microsecond inference latency, zero collisions during live demonstration, and fully untethered battery-powered operation.

Verilog HDL FPGA DE1-SoC Cyclone V Arduino PyTorch Q6.10 Fixed-Point

// Performance

~1 µs Inference Latency
0 Collisions in Demo
59 NN Parameters
222 ALMs Used (<1%)
100 ms Control Loop
50 MHz Clock Speed

// Demo

// System Architecture

The system operates in a continuous 100ms control loop. Three ultrasonic sensors feed distance readings through an Arduino Uno, which serializes the data over UART to the DE1-SoC FPGA. The neural network runs entirely in hardware (no CPU, no software), classifies the sensor input into one of three actions, and sends the decision back to the Arduino for motor execution.

01

Sense

3 ultrasonic sensors (HC-SR04) read distances at 45-degree left, center, and 45-degree right

02

Transmit

Arduino maps distances to bytes and sends 3 bytes to FPGA via UART at 9600 baud

03

Decide

FPGA scales inputs to Q6.10 fixed-point, runs NN forward pass in ~50 clock cycles

04

Act

Arduino receives class (Forward / Stop / Turn) and drives the 4 motors accordingly

// Neural Network

A compact 2-layer fully-connected network designed to fit within FPGA constraints. All arithmetic uses signed 16-bit Q6.10 fixed-point. A single hardware multiplier is time-shared across all neurons to minimize DSP block usage.

Architecture

Input Layer3 neurons
Hidden Layer8 neurons (ReLU)
Output Layer3 neurons (Argmax)
Total Parameters59

Training

FrameworkPyTorch
Raw Samples1,698
Clean Samples670
QuantizationQ6.10 (16-bit signed)

Classification

ClassActionCondition
0ForwardAll directions clear (center ≥ 40 cm, sides ≥ 25 cm)
1StopCornered on all sides (< 15 cm each)
2TurnObstacle detected on any side

// Board Controls

SW[0] Master enable — UP activates inference, DOWN silences output
KEY[0] Reset — resets all internal state (active-low)
KEY[1] Emergency kill switch — forces STOP immediately
HEX0 7-segment display showing current class: F (Forward), S (Stop), t (Turn)
LEDR[1:0] Binary class indicator: 00 = Forward, 01 = Stop, 10 = Turn
LEDR[3] Kill switch indicator — ON when KEY[1] is pressed

// Hardware

ComponentQtyRole
DE1-SoC Board (Cyclone V 5CSEMA5F31C6)1NN inference engine
Arduino Uno R31Sensor/motor interface
HC-SR04 Ultrasonic Sensor3Obstacle detection (left, center, right)
L298N Motor Driver2Dual H-bridge for 4 DC motors
4-Wheel Robot Chassis1Mobility platform
Bi-directional Level Converter13.3V (FPGA) to 5V (Arduino)
7.4V 2S LiPo Battery2Motors/Arduino + FPGA (via boost converter)
DC Boost Converter1Steps up to 12V for DE1-SoC

// FPGA Resource Usage

ResourceUsedAvailableUtilization
ALMs (Adaptive Logic Modules)22232,070< 1%
DSP Blocks2872.3%
GPIO Pins2 (UART)365.6%
7-Segment Displays1616.7%
LEDs41040%

// Source Code

fpga/
  robot_neural.v -- Top-level module
  neural_net.v -- NN engine + hardcoded weights
  uart_rx.v -- UART receiver (9600 baud)
  uart_tx.v -- UART transmitter
  pin_assignments.tcl -- FPGA pin mappings

arduino/
  de1soc_phase5_3sensor.ino -- Main robot control
  de1soc_data_collect_v2.ino -- Data collection

training/
  fpga_nn_v5.ipynb -- Full training pipeline
View on GitHub