Advertisement
Advanced Time: 6–8 weeks Electronics Engineering

FPGA Digital Design and Implementation

Implement a complete SoC on FPGA including CPU (RISC-V core), UART, SPI, VGA controller, and custom digital signal processing accelerators.

FPGAVerilogVHDLXilinxVivadoDigital Logic
DifficultyAdvanced
Duration6–8 weeks
Components10 items
Steps4 steps

Introduction

Implement a complete SoC on FPGA including CPU (RISC-V core), UART, SPI, VGA controller, and custom digital signal processing accelerators. This comprehensive guide covers everything from design through implementation, testing, and deployment.

Theory & Background

FPGA (Field-Programmable Gate Array): array of configurable logic blocks (CLBs) interconnected by programmable routing. Each CLB contains: LUTs (Look-Up Tables, implement any Boolean function), flip-flops (sequential storage), and multiplexers. DSP blocks: dedicated hardware multipliers (fast, efficient). BRAM: on-chip block RAM (18Kb or 36Kb blocks). I/O blocks: configurable voltage standards, differential I/O, SERDES. Configuration: SRAM-based (Xilinx/Altera) — contents loaded from flash on power-up. Anti-fuse (Microsemi) — one-time programmable (radiation-hard for space). FPGAs implement any digital circuit up to their resource limits.

Advertisement

Components & Requirements

10 components required for this project.

#ComponentPurposeQty
1Digilent Basys 3 (Artix-7 FPGA) or Nexys A7FPGA development boardx1
2Xilinx Vivado Design Suite (free WebPack)Synthesis, implementation, bitstream generationx1
3VGA monitorFPGA VGA output displayx1
4Logic analyzer (Saleae or FPGA integrated)Digital signal debuggingx1
5Pmod accessories (UART, SPI, I2C modules)Peripheral testingx1
6PicoRV32 RISC-V soft coreOpen-source CPU implementationx1
7ModelSim / Vivado SimulatorRTL simulation before synthesisx1
8Constraint file (.xdc) for Basys 3Pin assignments and timing constraintsx1
9Oscilloscope (for timing verification)Signal timing measurementx1
10Git version controlHDL source code managementx1

Step-by-Step Implementation

Follow these 4 steps carefully.

1
FPGA Architecture and Reconfigurability

FPGA (Field-Programmable Gate Array): array of configurable logic blocks (CLBs) interconnected by programmable routing. Each CLB contains: LUTs (Look-Up Tables, implement any Boolean function), flip-flops (sequential storage), and multiplexers. DSP blocks: dedicated hardware multipliers (fast, efficient). BRAM: on-chip block RAM (18Kb or 36Kb blocks). I/O blocks: configurable voltage standards, differential I/O, SERDES. Configuration: SRAM-based (Xilinx/Altera) — contents loaded from flash on power-up. Anti-fuse (Microsemi) — one-time programmable (radiation-hard for space). FPGAs implement any digital circuit up to their resource limits.

2
VGA Controller Implementation

VGA timing: horizontal sync (hsync), vertical sync (vsync), and RGB pixel data. 640×480@60Hz standard: 25.175 MHz pixel clock. Horizontal: 640 visible + 16 front porch + 96 sync + 48 back porch = 800 total pixels/line. Vertical: 480 visible + 10 front + 2 sync + 33 back = 525 total lines. Verilog implementation: two counters (h_count and v_count) driven by 25 MHz clock. Sync signals asserted during sync periods. Pixel data: ROM containing image data, addressed by (v_count × 640 + h_count). Output: 4-bit R, G, B DAC resistor ladder (4 resistors: 2kΩ, 1kΩ, 500Ω, 250Ω) converts digital to analog for VGA connector.

3
RISC-V Soft Core CPU

PicoRV32: compact RISC-V implementation in 750 lines of Verilog. Implements RV32IMC (integer, multiply, compressed). Interfaces: AXI4 or simple memory bus. Integrate into FPGA design: connect to BRAM (program memory + data memory), UART peripheral, GPIO. Compile C programs: RISC-V GCC toolchain (riscv32-unknown-elf-gcc -march=rv32imc). Convert ELF to memory init file. Load into FPGA BRAM. Execute: PicoRV32 fetches instructions from BRAM, executes, accesses peripherals through memory-mapped I/O. Benchmark: ~0.8 DMIPS/MHz. At 50MHz on Artix-7: 40 DMIPS — adequate for embedded control.

4
Timing Analysis and Constraints

FPGA timing: paths between flip-flops must meet setup and hold time requirements. Vivado timing analysis: run 'report_timing_summary' after implementation. Critical path: the longest combinational path (determines maximum clock frequency). If timing fails: Vivado reports offending paths. Fix: pipeline (add registers to break long path), reduce logic complexity, use DSP blocks for arithmetic. Write timing constraints (.xdc): create_clock -period 10.000 [get_ports clk] (100 MHz). False paths: between clock domains, async reset recovery. Correctly constrained design is essential for reliable FPGA operation.

Code & Implementation

Core code for vga_controller.v:

vga_controller.v Verilog
// VGA 640x480 @ 60Hz controller // Pixel clock: 25.175 MHz (use 25 MHz PLL output)  module vga_controller (     input  wire        clk_25MHz,     input  wire        rst,     output reg         hsync,     output reg         vsync,     output wire        display_on,     output wire [9:0]  pixel_x,    // 0-639     output wire [9:0]  pixel_y     // 0-479 );      // VGA 640x480 timing parameters     localparam H_DISPLAY = 640, H_FRONT = 16, H_SYNC = 96, H_BACK = 48;     localparam V_DISPLAY = 480, V_FRONT = 10, V_SYNC = 2,  V_BACK = 33;     localparam H_TOTAL = H_DISPLAY + H_FRONT + H_SYNC + H_BACK; // 800     localparam V_TOTAL = V_DISPLAY + V_FRONT + V_SYNC + V_BACK;  // 525      reg [9:0] h_count = 0, v_count = 0;      // Horizontal counter     always @(posedge clk_25MHz or posedge rst) begin         if (rst) h_count <= 0;         else if (h_count == H_TOTAL - 1) h_count <= 0;         else h_count <= h_count + 1;     end      // Vertical counter     always @(posedge clk_25MHz or posedge rst) begin         if (rst) v_count <= 0;         else if (h_count == H_TOTAL - 1) begin             if (v_count == V_TOTAL - 1) v_count <= 0;             else v_count <= v_count + 1;         end     end      // Sync signals (active low for standard VGA)     always @(posedge clk_25MHz) begin         hsync <= ~(h_count >= H_DISPLAY + H_FRONT && h_count < H_DISPLAY + H_FRONT + H_SYNC);         vsync <= ~(v_count >= V_DISPLAY + V_FRONT && v_count < V_DISPLAY + V_FRONT + V_SYNC);     end      // Pixel coordinates and display enable     assign pixel_x    = (h_count < H_DISPLAY) ? h_count : 0;     assign pixel_y    = (v_count < V_DISPLAY) ? v_count : 0;     assign display_on = (h_count < H_DISPLAY) && (v_count < V_DISPLAY);  endmodule

Testing & Troubleshooting

Test FPGA Digital Design and Implementation by verifying each subsystem individually before full integration.

!
Troubleshooting Tips

Verify power voltages, check ground connections, use serial monitor for debug.

Real-World Applications

*Real-time digital signal processing
*High-speed data acquisition system
*Custom digital communication protocol
*Image processing accelerator
*Neural network inference accelerator
*Software-defined radio baseband processing
*High-frequency trading latency reduction
*Motor control with sub-microsecond loop time

Extensions & Next Steps

  • Implement a complete RISC-V SoC with OS running on FPGA
  • Build a hardware AES encryption accelerator
  • Design an FFT processor using systolic array
  • Implement a MIPI CSI-2 camera interface
  • Build a PCIe endpoint for high-speed PC data acquisition

Interactive Playground

Coming Soon

An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.

Frequently Asked Questions

When should I use an FPGA instead of a microcontroller?
Use FPGA when: (1) True parallelism needed — multiple tasks simultaneously (MCU does one thing at a time). (2) Deterministic ultra-low latency — FPGA logic executes in single clock cycles (5–10ns), MCU interrupt latency ~200ns minimum. (3) High-speed I/O — SERDES enables multi-Gbps serial links impossible with MCU GPIO. (4) Custom digital hardware — implement protocols not available as MCU peripherals. (5) DSP acceleration — dozens of parallel DSP blocks for signal processing. Use MCU when: running software algorithms, requiring easy programming (C/Python vs Verilog), interfacing standard peripherals (UART, I2C, USB), lower power and cost requirements.
Advertisement