Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
FPGA USB Device Design in VHDL - From First Principles
Rating: 4.4 out of 5(8 ratings)
46 students

FPGA USB Device Design in VHDL - From First Principles

Building a FIFO-Based FPGA USB CDC Interface in VHDL Without Vendor IP Cores
Created byL Athukorala
Last updated 6/2026
English
English [Auto],

What you'll learn

  • Understand the USB architecture from a hardware and protocol perspective
  • Implement a USB CDC (Communications Device Class) interface entirely in VHDL
  • Create and manage USB descriptors, including device, configuration, interface, and endpoint descriptors
  • Design control transfer handling for USB enumeration
  • Implement bulk IN and OUT endpoints for data communication
  • Build FIFO-based data paths between USB endpoints and internal FPGA logic
  • Design robust finite state machines for USB packet handling and flow control
  • Handle USB data buffering, handshaking, and error conditions
  • Debug USB communication using simulation and real hardware testing using Signal Tap Logic Analyser
  • Structure a medium-sized VHDL project for clarity, reuse, and maintainability

Course content

1 section93 lectures28h 8m total length
  • Introduction8:56

    Learn to design a USB CDC interface in VHDL from first principles, building a complete USB device from the ground up with a FIFO-based data path and hands-on hardware practice.

  • Where to Get the FPGA Explorer Development Board0:05
  • Course Roadmap5:26

    Outline the course roadmap by breaking the USB CDC design into transmitter, receiver, ROM, FIFOs, and a central state machine.

  • Transmitter Intro29:47
  • Transmitter Block Diagram6:14
  • Transmitter Signalling9:03
  • CRC 16 Circuit26:06

    Develop a 16-bit CRC generator using a linear feedback shift register based on the USB16 polynomial, append the CRC to the message, and verify at the receiver.

  • CRC 16 VHDL32:12
  • Shift Register VHDL36:45

    Learn to implement a shift register in VHDL for an FPGA USB device from first principles.

  • Transmitter Top Level Timing Diagram26:18

    Examine the USB transmitter top-level design, coordinating shift registers, a CRC generator, and glue logic with a state machine to drive the USB data lines.

  • Transmitter VHDL 110:51

    Design a VHDL USB transmitter from a timing diagram, with a generic TX message bytes (default 16), CRC options, and an in-out USB DP/DM interface.

  • Transmitter VHDL 215:47

    Implement a USB transmitter in VHDL by using a four-stage ring counter to generate TP1–TP4 timing pulses, with a PKG_USB package of constants and a USB sync field.

  • Transmitter VHDL 313:22

    Explain a vhdl usb transmitter that drives data plus and data minus lines using five-state usb bit type (tri-state, se0, idle, 1, 0) gated by tp4 with resettable drive process.

  • Transmitter VHDL 46:22

    Generate stuff bits after six consecutive 1s by monitoring the new bit, count 1s with a three-bit counter, reset on 0, and assert the stuff bit required flag on six.

  • Transmitter VHDL 517:33

    Instantiates the data shift register in the USB transmitter VHDL, rotates right with peak index 16 and prepends an 8-bit sync field to the message.

  • Transmitter VHDL 69:30

    Instantiate a 16-bit crc shift register in vhdl, rotate left so msb is transmitted first, and connect it via a port map with reset, clock, and crc result ready signals.

  • Transmitter VHDL 79:02

    Instantiate usb crc16 generator in the transmit path, initialize lfsr on tx message ready, and feed bits from index 16 onward (excluding pid and sync) before loading crc.

  • Transmitter VHDL 818:02
  • Transmitter VHDL 933:54

    Explore transmitter design in VHDL for FPGA USB devices. Build foundational skills from first principles to implement reliable transmitters.

  • Transmitter Test Bench 119:03
  • Transmitter Test Bench 224:48

    Explore building and simulating a VHDL transmitter test bench in ModelSim, using 2008 syntax, and analyze waveform signals, CRC generation, and USB data flow.

  • Receiver Overview13:31

    Explore the USB receiver architecture, including a two-stage synchronizer, diff state and single-ended zero decoding, a reset detector, a bit sampler, and RX complete signaling for framing USB data.

  • Sync Module Design6:19
  • Rx Sampler 122:31

    Describe the rx bit sampler that extracts usb data bits from the diff stream using a timing diagram, delayed dif signals, and a two-bit counter to sample mid-bit.

  • Rx Sampler 225:38

    Create a vhdl usb rx bit sampler with usb diff inputs, two delayed diff signals, an idle and receiving state machine, and bit extraction via previous state xor and invert.

  • Rx Sampler 319:35

    Learn to generate the internal sampling clock in VHDL and reliably capture USB data bits, including SE0 end-of-reception handling with two-stage delays and stuff-bit discard.

  • Rx Sampler 415:20
  • Receiver Design 127:14
  • Receiver Design 231:57
  • Receiver Test Bench15:33
  • Types Of USB Transfers12:46

    Explore the four USB transfer types—control, interrupt, bulk (in and out), and isochronous—covering bidirectional enumeration, host polling, data throughput limits, and the no-retry behavior of isochronous transfers.

  • USB Transfer Flow11:56
  • USB Packets12:51
  • USB Transfer Examples12:11

    Study how USB transfers assemble from setup packets and data nodes for control transfers. Review bulk in and bulk out flows, data one and data zero toggling, and zero-length packets.

  • Configurations, Interfaces and Endpoints16:50

    Explain how configurations, interfaces, and endpoints define a usb device's capabilities, including endpoint 0 enumeration, one active configuration at a time, and separate in and out endpoints for data.

  • Descriptor ROM VHDL7:00
  • Device Descriptor17:22

    Populate the VHDL ROM with the 18-byte device descriptor, detailing bLength, bDescriptorType, usb 2.0 bcd, bMaxPacketSize0, cdc class, vid/pid, iManufacturer, iProduct, iSerialNumber, and bNumConfigurations.

  • Configuration Descriptor21:08

    Describe the usb configuration descriptor, including its nine-byte length and total length 0x43. Define two interfaces, configuration value 1, i configuration 0, bm attributes 0x80, and max power 0x32.

  • Interface Descriptor 022:35
  • Interface Descriptor 125:43
  • String Descriptors9:47

    Define and populate a string descriptor ROM in VHDL, detailing string indices, product name, and serial number with ASCII encoding, offsets, and zeros for unused locations.

  • PIDs and bRequests24:09

    Explains usb pids and brequests, showing how four-bit pids become eight-bit codes and outlining common usb tokens and standard device requests for full-speed usb devices.

  • Class Specific bRequests9:28
  • A simple FIFO36:16

    Design a simple FIFO in VHDL to support FPGA USB device design, guided by first principles and practical buffering concepts.

  • Transmit FIFO Design 120:19
  • Transmit FIFO Design 239:31

    Design a transmit FIFO for a USB device on an FPGA using VHDL, guided by first principles. Implement reliable data transmission through a concise, practical FIFO architecture.

  • Receive FIFO Design 14:59
  • Receive FIFO Design 25:42

    Analyze how the 64-bit shift register acts as an 8-byte buffer to split incoming data, rotate by 8 bits, and write bytes into the simple FIFO via the DIN port.

  • Receive FIFO Design 319:44
  • USB Top Level Block Diagram4:45

    Design the top level USB module that instantiates transmitter, receiver, FIFOs, descriptor ROM, and a reset generator that supports a state machine coordinating requests on the d+ and d- lines.

  • Top Level Ports9:09

    Define usb top-level ports, including data plus/minus and tx/rx fifo interfaces, to enable a usb cdc device with uart configuration (baud rate, data bits, stop bits, parity) and status signals.

  • Top Level VHDL 111:12

    Stage the VHDL top-level module for a USB device by declaring usb-top-level, generating a 48 mhz clock from 25 mhz via PLL, and defining tx/rx interfaces and dp/dm lines.

  • Top Level VHDL 215:03
  • Top Level VHDL 314:21

    Instantiate the USB transmitter and descriptor ROM in a top-level VHDL file, map clocks, reset, and USB data lines, and size tx/rx buffers based on the endpoint size.

  • Top Level VHDL 427:31
  • Central State Machine Flow Chart23:35
  • Central State Machine - Setting up the Framework32:20

    Explore how to build a central state machine and set up the framework for a USB device design in VHDL, guiding the FPGA implementation from first principles.

  • Central State Machine - Control Transfers 121:09

    Learn how the central state machine handles control output transfers, decoding B requests and executing set address and set configuration, with CDC line coding and control line state considerations.

  • Central State Machine - Control Transfers 219:20

    Explain the central state machine for usb control transfers, handling set control line state and set line coding via setup requests, out/in tokens, and direction-aware waits for control data.

  • Central State Machine - Control Transfers 319:54

    Terminate a control transfer through the end control transfer state, detailing termination sequences for control input and control output transfers.

  • Central State Machine - Data PID Toggle Process17:56

    Design per-endpoint data PID toggling for endpoints 0, 1, and 2, tracking separate states and toggling on each host acknowledge. Reset endpoint 0 to data 1 at new control transaction.

  • Central State Machine - Decode INOUT Requests11:50

    Implement a VHDL state machine to handle USB control transfers, decoding host requests like get descriptor and get line coding, and coordinating acknowledge and error handling.

  • Central State Machine - Get Line Coding23:18

    Formulates the get line coding response for a USB control transfer. Sends UART settings (baud rate, stop bits, parity, data bits) and a 16-bit CRC within a VHDL state machine.

  • Central State Machine - Simple Get Requests5:51

    Implement get requests in the USB CDC state machine for configuration, interface, and status, passing the b configuration value to the transmitter as 16 bits and returning a 16-bit status.

  • Central State Machine - Get Descriptor Request 119:07

    Explain how the getDescriptor request reads USB descriptors from the FPGA, using setup data to identify descriptor type and streaming descriptors from ROM in eight-byte packets during enumeration.

  • Central State Machine - Get Descriptor Request 220:43

    Explain how the VHDL central state machine handles get descriptor requests by decoding setup data, selecting device, configuration, or string descriptors from ROM, and computing addresses and sizes.

  • Central State Machine - Get Descriptor Request 332:46

    Design and analyze the central state machine that handles get descriptor requests for a USB device implemented in VHDL on an FPGA.

  • Central State Machine - Set Line Coding10:01

    Describe how the central state machine handles the usb set line coding request, configuring uart baud rate, data bits, stop bits, and parity.

  • Central State Machine - Decode PID12:34

    Decode usb pid tokens and route data for endpoint 1 bulk data and endpoint 2 notification within a central state machine for a usb cdc interface, including uart data handling.

  • FIFO Instantiation15:14

    Instantiate and wire the transmit and receive FIFOs for endpoint 1 in the FPGA, enabling USB data transfers between the PC and downstream interfaces by replacing UART with FIFOs.

  • Central State Machine - Bulk Data Handling25:51

    Design and implement the central state machine to transmit data from endpoint 1 via the transmit FIFO to the host PC, handle acks, zero-length packets, CRC, endpoint 2 status.

  • Central State Machine - Consolidation16:58

    Consolidate and debug a usb vhdl state machine by tidying case statements, fixing syntax errors, renaming constants, and implementing a negative acknowledge path for unsupported requests.

  • Completing USB Top Level Module21:19

    Declare the usb top-level vhdl with state machine types and signals, including 28 states, descriptor ROM, setup request data, token/data PIDs, and fifo control, for fpga embedding.

  • Making Final Tweaks34:07
  • Adding Some Useful Comments26:39
  • Top Level Test Bench - The Approach12:24

    Learn the top-level test bench approach for a USB VHDL device, with DUT and test bench driver to simulate a host PC and verify USB transactions, then deploy on hardware.

  • Top Level Test Bench 118:47
  • Top Level Test Bench 214:23
  • Top Level Test Bench 318:38

    Develop a USB test bench in VHDL by implementing token, setup data, data out, and acknowledge packet procedures; cover PID, bmRequest, bRequest, wValue, wIndex, wLength, and unconstrained data lengths.

  • Top Level Test Bench 418:17
  • Top Level Test Bench 59:05
  • Top Level Test Bench 612:34

    Build a top-level USB VHDL test bench that instantiates the device under test with a test bench driver, drives reset and a 50 MHz clock for simulating USB with ModelSim.

  • Test Case 1 - Set Address27:51
  • Test Case 2 - Get Descriptor33:17
  • Test Case 3 - Host Writes Data14:36
  • Test Case 4 - Host Reads Data13:34
  • Hardware Test Model7:25

    Test hardware with VHDL hardware test fixture that loops RX FIFO to TX FIFO, validates USB interface via enumeration, and uses a PLL to derive 48 MHz from 25 MHz.

  • Hardware Test Fixture31:55
  • The Quartus Project26:45
  • Pin Assignments and Binary Files20:02
  • Hardware Functional Testing15:00

    Test and verify our USB CDC FPGA design on real hardware, using Docklight for loopback and RTS/DTR control, programming with ByteBlaster, and validating enumeration.

  • Debugging With Signal Tap32:25

    Master debugging of an FPGA USB device design in VHDL using signal tap to monitor internal signals and identify timing and logic issues.

  • Conclusion1:49

    Build a working USB CDC device in VHDL, understand the protocol, state machines, and data paths, and connect enumeration, descriptors, and control transfers to FPGA logic.

Requirements

  • Must have a basic understanding of the VHDL language
  • Understanding clocks, resets, and synchronous logic
  • Able to design simple finite state machines
  • If you have completed an introductory VHDL course, you are well prepared for this material.

Description

Add USB connectivity to your FPGA project

USB is everywhere — from keyboards to mice to embedded devices and development tools to production hardware. Yet in many FPGA projects, USB is treated as a black box, hidden behind prebuilt IP cores or software libraries.

In this course, you’ll do something different: you’ll build a working USB CDC (virtual COM port) interface entirely in VHDL, gaining a deep, practical understanding of how USB works at the hardware level — not just how to use it.


Who This Course Is For

This course is designed for engineers, students, and hobbyists who already have a basic understanding of VHDL and want to move beyond simple demonstration projects.

It’s ideal if you:

  • Understand basic VHDL concepts such as signals, processes, and state machines

  • Want to learn how real communication interfaces are implemented in hardware

  • Are curious about how USB works beyond libraries and vendor IP cores

  • Want to design FPGA systems that interact directly with a PC

  • Are comfortable working at the register, protocol, and timing level

This course focuses on understanding and building a USB CDC interface from first principles, not on using prebuilt blocks or high-level abstractions.

Not for you if:

  • You are completely new to VHDL or digital design

  • You are looking for a plug-and-play USB solution

  • You only want to use vendor-provided USB IP cores

  • You expect minimal HDL code or a purely software-driven approach

What You Will Learn

By the end of this course, you will be able to:

  • Understand USB architecture at the hardware and protocol level

  • Implement a USB CDC interface entirely in VHDL

  • Create and manage USB descriptors and handle enumeration

  • Design bulk IN and OUT endpoints for data transfer

  • Build FIFO-based data paths between USB endpoints and FPGA logic

  • Debug USB communication using simulation and real hardware

Why This Course Is Different

Many USB tutorials rely on vendor IP cores or software stacks — this course does not.

Instead, you’ll:

  • Build everything in VHDL from the ground up

  • Understand what each block does and why it exists

  • Learn to debug protocol-level issues

  • Take away knowledge you can reuse on other projects or platforms

The goal isn’t just to make something work — it’s to understand why it works.


Practical Outcomes

You won’t just learn theory. You will:

  • Build a working USB CDC device in VHDL that appears as a virtual COM port on a PC

  • Exchange data between a PC and FPGA using TX and RX FIFOs

  • Develop a solid understanding of USB device architecture

  • Gain a reusable USB foundation adaptable to other device classes or custom protocols

  • Prepare for more advanced FPGA and embedded projects

Skills You’ll Take Away

After completing this course, you’ll have:

  • A deep understanding of USB devices at the protocol level

  • Practical experience designing medium-sized VHDL systems

  • A solid foundation for advanced topics such as Ethernet, ADC/DAC interfacing, and system-level FPGA design

Recommended Background

Before starting this course, you should be comfortable with:

  • Writing and simulating simple VHDL modules

  • Designing simple finite state machines

  • Understanding clocks, resets, and synchronous logic

  • Using an FPGA toolchain to build and program a design

If you’ve completed an introductory VHDL course, you are well prepared for this material.


Hardware Platform (FPGA Explorer Board)

This course uses a modern FPGA development platform based on a Cyclone 10 LP device, featuring USB, SDRAM, user I/O, and other peripherals suitable for real-world projects.

All lessons, examples, and exercises have been tested on this platform, letting you follow along step by step without needing additional hardware. Focus stays on learning VHDL and system design, not on hardware workarounds.

This same platform will be used in future courses covering:

  • Ethernet communication

  • ADC and DAC interfacing

  • Advanced FPGA system design

Search eBay for "FPGA Explorer Board". See "FPGA_Explorer_Board.pdf" for more details.

Search eBay for "Byte Blaster Programmer". - You will need this to program the FPGA.


Ready to move beyond basic VHDL and start building real interfaces?

Join the course and take the next step in your FPGA journey.

Who this course is for:

  • Students with basic VHDL knowledge looking to move beyond simple demos
  • Hobbyists and makers interested in USB-enabled FPGA projects
  • Engineers or embedded developers who want hands-on FPGA experience
  • Anyone curious about USB device protocols and low-level FPGA design
  • Learners who want to build reusable skills for advanced FPGA projects