A comprehensive collection of Verilog projects for the iCESugar Nano FPGA board demonstrating LED control, PWM effects, UART communication, and microcontroller implementations.
constraints/- Pin Constraint File (.pcf) for iCESugar Nanosrc/PE-Library/- Verilog library templatessrc/projects/- Example projects organized by complexity
git clone https://github.com/abhinav937/icesugar_nano_examples.git
cd icesugar_nano_examples
cd src/projects/blinky| Project | Description | Pin Mapping |
|---|---|---|
blinky |
Simple LED blink at 1 Hz | LED → B6 |
pwm_led |
PWM-based LED breathing effect | LED → B6 |
train_leds |
Pulsating effect across PMOD3 pins | B4, B3, B2, B1, A4, A3, A2, A1 |
fpga_done_led |
Turn off B4 LED when FPGA is programmed | LED → B4 |
| Project | Description | Pin Mapping |
|---|---|---|
uart_pwm_led |
UART-controlled LED brightness | LED → B6, UART → B7, B8 |
multi_led_uart |
Multi-LED UART control with brightness setting | PMOD3 pins, UART → B7, B8 |
lowpass_pwm_uart |
Low-pass filtered PWM demo with bar graph | B6 (filtered PWM), PMOD1-8 (bar graph) |
| Project | Description | Pin Mapping |
|---|---|---|
pwm_microcontroller |
8-bit microcontroller with dual PWM channels | PWM0 → B4, PWM1 → C6, UART → A3, B3 |
closed_loop_control |
Closed-loop control system with UART feedback | PWM → B6, UART → A3, B3 |
blinky - Simple LED toggle at 1 Hz frequency, perfect for first-time FPGA users.
pwm_led - Demonstrates PWM (Pulse Width Modulation) to create a smooth breathing effect on an LED.
train_leds - Creates a moving light pattern across 8 LEDs on PMOD3, simulating a train of lights.
fpga_done_led - Shows how to control an LED based on the FPGA's programming state.
uart_pwm_led - Controls LED brightness via UART commands, demonstrating serial communication.
multi_led_uart - Advanced UART control for multiple LEDs with individual brightness control.
lowpass_pwm_uart - Combines PWM with low-pass filtering and includes a visual bar graph display.
pwm_microcontroller - Implements a simple 8-bit microcontroller with:
- Dual PWM channels (1kHz frequency)
- UART RX/TX communication
- Command protocol for PWM control
- Acknowledgment system
closed_loop_control - Demonstrates closed-loop control with:
- UART voltage input (0-255 representing 0.0V-25.5V)
- Proportional control law: d[n] = 0.4167 + Kp*(5 - Vout[n])
- 10kHz PWM output
- Real-time duty cycle feedback via UART
- Baud rate: 115200
- Data format: 8N1 (8 data bits, no parity, 1 stop bit)
- Compatible with: iCELink USB CDC interface
This repository uses a custom workflow with the Lattice_NanoIce flash tool and ssh-push for FPGA programming.
-
Install Lattice_NanoIce Flash Tool:
bash <(curl -s https://raw.githubusercontent.com/abhinav937/Lattice_NanoIce/main/install.sh) -
Install ssh-push (if not already installed):
# Clone and install ssh-push git clone https://github.com/abhinav937/ssh-push.git cd ssh-push ./install.sh
# Navigate to any project directory
cd src/projects/[project_name]
# Build and program using the flash tool
flash [module_name].v [module_name].pcf
# Example for blinky project:
cd src/projects/blinky
flash blinky.v blinky.pcf
# Example for pwm_microcontroller:
cd src/projects/pwm_microcontroller
flash pwm_microcontroller.v pwm_microcontroller.pcf# Verbose output for debugging
flash [module_name].v [module_name].pcf --verbose
# Build only (skip programming)
flash [module_name].v [module_name].pcf --build-only
# Set clock frequency (1=8MHz, 2=12MHz, 3=36MHz, 4=72MHz)
flash [module_name].v [module_name].pcf -c 2
# Force drag-and-drop programming
flash [module_name].v [module_name].pcf --force-dragdropFor remote development or automated builds:
# Navigate to project directory
cd src/projects/[project_name]
# Push and program via SSH (uses .ssh_push_config.json for connection details)
ssh-push [module_name].v [module_name].pcf
# Example for blinky project:
cd src/projects/blinky
ssh-push blinky.v blinky.pcf
# Example for pwm_microcontroller:
cd src/projects/pwm_microcontroller
ssh-push pwm_microcontroller.v pwm_microcontroller.pcfEach project directory contains a .ssh_push_config.json file that specifies the SSH connection details (hostname, remote directory, authentication method, etc.).
Most projects include Python test scripts for UART communication:
uart_pwm_led/set_brightness.pymulti_led_uart/set_led_brightness.pymulti_led_uart/test_multi_led.pypwm_microcontroller/program.py
- LED not responding: Check pin mapping in
.pcffile - UART issues: Verify baud rate is 115200 and port settings
- Build errors: Ensure correct constraint file is used
- Programming issues: Check USB connection and driver installation
- Flash tool issues: Run
flash --helpfor available options - Device not detected: Check USB connection and run
flash -c 2to test device status
- iCESugar Nano FPGA board
- USB cable for programming and UART communication
- Optional: External LEDs or PMOD modules for expanded functionality
Feel free to submit issues, feature requests, or pull requests to improve these examples.
See the LICENSE file for details.