← Back to all projects

FPGA DESIGN VHDL MASTERY

While a CPU is a fixed-path machine that executes instructions one by one, an FPGA is a sea of gates that you rewire to become the algorithm itself. It is the bridge between software flexibility and ASIC (Application-Specific Integrated Circuit) performance.

Learn FPGA Design with VHDL: From Zero to Hardware Master

Goal: Deeply understand the architecture and logic of Field Programmable Gate Arrays (FPGAs) using VHDL. You will transition from thinking like a programmer (sequential) to thinking like a hardware engineer (concurrent), ultimately building complex, hardware-accelerated pipelines for cryptography and image processing that outperform traditional software.


Why FPGA Design Matters

While a CPU is a “fixed-path” machine that executes instructions one by one, an FPGA is a “sea of gates” that you rewire to become the algorithm itself. It is the bridge between software flexibility and ASIC (Application-Specific Integrated Circuit) performance.

  • Historical Context: FPGAs emerged in the 1980s (Xilinx) to provide a middle ground between cheap but slow microprocessors and fast but expensive custom chips.
  • Real-World Impact: FPGAs power 5G base stations, high-frequency trading (where nanoseconds matter), real-time video processing in cameras, and Mars Rover landing systems.
  • The Unlock: Mastering VHDL allows you to design custom hardware. You stop being a “user” of chips and start being the “creator” of chips.

Core Concept Analysis

1. The FPGA Architecture: The Sea of Gates

FPGAs don’t have “code” in the traditional sense. They have a bitstream that configures hardware blocks.

      FPGA INTERNALS (Simplified)
+------------------------------------------+
|  [IOB]      [IOB]      [IOB]      [IOB]  |  IOB: Input/Output Blocks
|    |          |          |          |    |
|  [CLB] <--> [CLB] <--> [CLB] <--> [CLB]  |  CLB: Configurable Logic Blocks
|    ^          ^          ^          ^    |       (LUTs + Flip-Flops)
|    |          |          |          |    |
|  [BRAM] <-> [BRAM] <-> [DSP] <--> [DSP]  |  BRAM: Block RAM
|    |          |          |          |    |  DSP: Math Slices
+------------------------------------------+
|         Interconnect Matrix              |
+------------------------------------------+

2. Thinking in Concurrency (The VHDL Mindset)

In C, a = b; c = d; happens one after the other. In VHDL, these two assignments can happen at the exact same picosecond.

  • Entity: The “black box” view (Inputs and Outputs).
  • Architecture: The “guts” (What’s inside).
  • Process: The bridge between sequential logic (for state machines) and hardware.
  • Signals vs. Variables: Signals represent wires; variables represent local storage within a process.

3. The Design Flow: From Text to Silicon

[ VHDL Code ] -> [ Simulation ] -> [ Synthesis ] -> [ Place & Route ] -> [ Bitstream ] -> [ FPGA ]
      |               |                 |                 |                  |           |
 "I want a     "Does it work   "Turn VHDL into   "Map gates to     "The binary     "Upload
  counter"      logically?"      logic gates"     actual CLBs"      file"           to chip"

The “Big Three” Building Blocks

A. The Look-Up Table (LUT)

FPGAs don’t have “AND” gates. They have small memory tables (LUTs) that simulate any logic function. Analogy: Instead of building a calculator, you build a table that pre-calculates every possible result.

B. The Flip-Flop (FF)

The memory of hardware. It holds a single bit (‘0’ or ‘1’) and changes only when the clock “ticks.” This is how we create synchronized systems.

C. The Finite State Machine (FSM)

Hardware’s way of making decisions.

  • Moore Machine: Output depends only on the state.
  • Mealy Machine: Output depends on state AND current inputs.

Concept Summary Table

Concept Cluster What You Need to Internalize
Structural vs Behavioral Structural is like LEGO (wiring blocks); Behavioral is describing the logic (if/then).
Clock Domains Everything in hardware happens on a heartbeat. Multiple hearts (clocks) cause “meta-stability” (chaos).
Combinational Logic Logic that reacts instantly (glitchy). No memory.
Sequential Logic Logic that updates on clock edges. Safe, predictable, has memory.
Pipelining Breaking a big task into small stages to increase throughput (like an assembly line).

Deep Dive Reading by Concept

1. Digital Logic Foundation

Concept Book & Chapter
Boolean Logic & Gates “Digital Design and Computer Architecture” by Harris & Harris — Ch. 1: “From Zero to One”
Combinational Logic “Digital Design and Computer Architecture” by Harris & Harris — Ch. 2
Sequential Logic (FFs) “Digital Design and Computer Architecture” by Harris & Harris — Ch. 3

2. VHDL Mastery

Concept Book & Chapter
VHDL Syntax & Entities “Getting Started with FPGAs” by Russell Merrick — Ch. 4: “VHDL Basics”
Processes & Sensitivity “FPGA Prototyping by VHDL Examples” by Pong P. Chu — Ch. 2
Synthesis vs Simulation “Designing Electronics That Work” by Hunter Scott — Ch. 6

Essential Reading Order

  1. The Fundamentals (Week 1):
    • Harris & Harris Ch. 1-3. You must understand how a D-Flip-Flop works before writing a single line of VHDL.
  2. The Language (Week 2):
    • Merrick Ch. 4-6. Learn the difference between std_logic and bit.
  3. The Architecture (Week 3):
    • Chu Ch. 3. Mastering Finite State Machines is 80% of FPGA design.

Project List

Projects are ordered from fundamental understanding to advanced implementations.


Project 1: The Pulse Width Modulation (PWM) Dimmer

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog, SystemVerilog
  • Coolness Level: Level 2: Practical but Forgettable
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 1: Beginner (The Tinkerer)
  • Knowledge Area: Digital Logic / Clock Dividers
  • Software or Tool: Vivado (Xilinx) or Quartus (Intel/Altera)
  • Main Book: “Digital Design and Computer Architecture” by Harris & Harris

What you’ll build: A hardware module that controls the brightness of an LED using PWM. You’ll implement a 10-bit counter and a comparator to create a variable duty cycle.

Why it teaches VHDL: This project introduces the most fundamental concept in hardware: The Clock. You will learn how to divide a 50MHz or 100MHz clock down to human-perceivable speeds and how “concurrency” works by running a counter and a comparator simultaneously.

Core challenges you’ll face:

  • Clock Dividing → Learning that hardware doesn’t have a sleep() function; you must count clock cycles.
  • Bit-Width Management → Understanding that std_logic_vector(7 downto 0) is a physical set of 8 wires.
  • Sensitivity Lists → Realizing why your logic only updates when the clock “ticks.”

Key Concepts

  • Counters: “Digital Design and Computer Architecture” Ch. 3.4 - Harris & Harris
  • PWM Theory: “Getting Started with FPGAs” Ch. 7 - Russell Merrick

Difficulty: Beginner Time estimate: Weekend Prerequisites: Basic understanding of logic gates (AND/OR).


Real World Outcome

You will see an LED on your development board slowly pulse (fade in and out) or stay at a specific brightness level. Unlike a CPU which “jiggles” the pin, your FPGA will produce a perfectly stable, nanosecond-precise square wave.

Example Output (Simulation Waveform):

Clock:   _|_|_|_|_|_|_|_|_|_|
Counter: 0 1 2 3 4 5 6 7 8 9
Target:  3 3 3 3 3 3 3 3 3 3
PWM_Out: H H H L L L L L L L 
         (Duty cycle = 30%)

The Core Question You’re Answering

“How do I create a stable physical signal when the only thing I have is a clock ticking millions of times per second?”

Before you write any code, sit with this question. In software, timing is often “close enough.” In hardware, timing is the law. If your clock is 100MHz, one cycle is exactly 10ns.


Concepts You Must Understand First

Stop and research these before coding:

  1. The D-Flip-Flop
    • What happens to the output (Q) when the clock rises?
    • What is the “Reset” signal for?
    • Book Reference: “Digital Design and Computer Architecture” Ch. 3.2
  2. Synchronous Logic
    • Why do we almost always use if rising_edge(clk)?
    • What happens if we don’t use a clock? (Glitch city!)
    • Book Reference: “Getting Started with FPGAs” Ch. 5

Questions to Guide Your Design

Before implementing, think through these:

  1. Resolution
    • If I use an 8-bit counter, how many levels of brightness do I have?
    • If I use a 16-bit counter, will the LED flicker to the human eye?
  2. Overflow
    • What happens when a counter reaches its maximum value (e.g., 255 for 8 bits)? Does it stop or wrap around?

Thinking Exercise

The Duty Cycle Trace

Trace the following logic in your head. Assume a 4-bit counter (0-15) and a DutyValue of 4.

if counter < DutyValue then
    pwm_out <= '1';
else
    pwm_out <= '0';
end if;

Questions while tracing:

  • How many cycles is the output ‘1’?
  • How many cycles is the output ‘0’?
  • What percentage of the total cycle (16) is the light “on”?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is the difference between a Signal and a Variable in VHDL?”
  2. “Why is a synchronous reset preferred over an asynchronous reset in modern FPGAs?”
  3. “How would you calculate the frequency of the PWM signal if the system clock is 100MHz and the counter is 8-bit?”
  4. “What is a ‘glitch’ in combinational logic?”
  5. “Explain the purpose of the sensitivity list in a process block.”

Hints in Layers

Hint 1: The Counter Start by making a simple process that increments an integer or unsigned value on every rising_edge(clk).

Hint 2: The Comparison Inside that same process (or a different one), compare your counter to a fixed value. If counter is less than value, output ‘1’.

Hint 3: Signal Types Use IEEE.NUMERIC_STD.ALL. Do not use std_logic_arith. Use the unsigned type for counters so you can use the + operator.

Hint 4: Verification Use a Testbench! Create a separate VHDL file that generates a clock and watches your pwm_out toggle in the simulator.


Books That Will Help

Topic Book Chapter
VHDL Syntax “Getting Started with FPGAs” by Russell Merrick Ch. 4
Sequential Logic “Digital Design and Computer Architecture” by Harris & Harris Ch. 3

Project 2: The Finite State Machine (FSM) Traffic Light

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog, SystemVerilog
  • Coolness Level: Level 2: Practical but Forgettable
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate (The Developer)
  • Knowledge Area: State Machines / Control Logic
  • Software or Tool: Vivado / Quartus / GHDL
  • Main Book: “FPGA Prototyping by VHDL Examples” by Pong P. Chu

What you’ll build: A controller for a 4-way intersection. It must handle transitions (Green -> Yellow -> Red) and detect a “pedestrian button” input to trigger a crosswalk phase.

Why it teaches VHDL: This is the “brain” of hardware. Most hardware modules are just data paths controlled by an FSM. You’ll learn the Two-Process Method: one process for state transitions (sequential) and one for output logic (combinational).

Core challenges you’ll face:

  • State Encoding → Understanding how IDLE, GREEN, YELLOW are represented as bits.
  • Timing Transitions → Integrating a counter to hold a state for exactly 5 seconds.
  • Input Debouncing → Learning that a physical button “bounces” (generates noise) and must be cleaned up in hardware.

Key Concepts

  • Finite State Machines: “Digital Design and Computer Architecture” Ch. 3.4 - Harris & Harris
  • Debouncing: “FPGA Prototyping by VHDL Examples” Ch. 4.4 - Pong P. Chu

Difficulty: Intermediate Time estimate: 1 week Prerequisites: Project 1 (Counters).


Real World Outcome

You’ll see three LEDs (Red, Yellow, Green) cycling through patterns. When you press a button, the system will acknowledge it and switch to the pedestrian state after the current green light expires.

Example Output (Console/Simulation Log):

T=0s: State = GREEN_NORTH,  Lights = G:N, R:S, R:E, R:W
T=10s: State = YELLOW_NORTH, Lights = Y:N, R:S, R:E, R:W
T=12s: State = RED_ALL,      Lights = R:N, R:S, R:E, R:W
T=13s: State = GREEN_SOUTH,  Lights = R:N, G:S, R:E, R:W
[Button Pressed!]
T=23s: State = PEDESTRIAN,   Lights = R:ALL, WALK:ON

The Core Question You’re Answering

“How does hardware make ‘decisions’ based on history and current inputs?”

Software uses if/else or switch statements that run in sequence. Hardware FSMs use a “State Register” that holds the current “memory” of where the system is.


Concepts You Must Understand First

Stop and research these before coding:

  1. Moore vs. Mealy Machines
    • Which one changes outputs immediately when an input changes?
    • Which one is “safer” for high-speed timing?
    • Book Reference: “Digital Design and Computer Architecture” Ch. 3.4.1
  2. Enumerated Types
    • How to define type state_type is (RED, YELLOW, GREEN);
    • Why is this better than using raw numbers?

Questions to Guide Your Design

Before implementing, think through these:

  1. The Fail-Safe
    • What happens if the FPGA starts up in an undefined state? (Hint: Always define a “Reset” state).
    • Can you ever have two Green lights at the same time? How do you prevent this in logic?
  2. The “Tick”
    • Your clock is 100MHz. If you transition every clock cycle, the lights will blink too fast to see. How do you slow it down? (Review Project 1’s counter).

Thinking Exercise

The State Transition Diagram

Draw a circle for each light state. Draw arrows between them.

  • Label the arrows with conditions (e.g., “Counter = MaxCount” or “Button = ‘1’”).
  • Which states can be reached from the “Emergency Reset” state?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is the ‘illegal state’ problem, and how do you handle it in VHDL?”
  2. “Why do we use a separate process for the state register and the combinational logic?”
  3. “Explain the difference between a synchronous and asynchronous state machine.”
  4. “How do you calculate the number of flip-flops required to store an FSM with 8 states?”
  5. “What is ‘binary encoding’ vs ‘one-hot encoding’ for states?”

Hints in Layers

Hint 1: The Type Define an architecture signal: type state_t is (S_RED, S_GREEN, S_YELLOW); signal current_state, next_state : state_t;

Hint 2: The Transition Process Write a process that only does one thing: if rising_edge(clk) then current_state <= next_state; end if;

Hint 3: The Logic Process Write a second process with current_state and inputs in the sensitivity list. Use a case current_state is statement to determine next_state.

Hint 4: The Timer Create a signal timer : unsigned(31 downto 0);. Increment it in the first process. Only change states when timer reaches a certain value.


Project 3: UART Serial Controller (Talk to your PC)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate (The Developer)
  • Knowledge Area: Communication Protocols / Timing
  • Software or Tool: PuTTY / TeraTerm / Screen
  • Main Book: “FPGA Prototyping by VHDL Examples” by Pong P. Chu

What you’ll build: A Universal Asynchronous Receiver/Transmitter. This allows your FPGA to send text to your computer’s terminal. You’ll implement the start bit, 8 data bits, and the stop bit.

Why it teaches VHDL: This is your first encounter with External Synchronization. You must sample a serial line at exactly the right time (the middle of the bit) without a shared clock. It teaches “Baud Rate Generation” and precise timing.

Core challenges you’ll face:

  • Baud Rate Generator → Creating a “pulse” every 1/9600th of a second.
  • Sampling Logic → Sampling the input 16 times faster than the baud rate to find the “center” of a bit.
  • Shift Registers → Moving data bit-by-bit into a parallel 8-bit signal.

Key Concepts

  • Baud Rate Generation: “Digital Design and Computer Architecture” Ch. 9.2 - Harris & Harris
  • Sampling and Synchronization: “FPGA Prototyping by VHDL Examples” Ch. 7 - Pong P. Chu

Difficulty: Intermediate Time estimate: 1-2 weeks Prerequisites: Project 1 (Counters) and Project 2 (FSMs).


Real World Outcome

You will type a character on your PC keyboard (via PuTTY), and the FPGA will receive it, increment it (e.g., ‘A’ becomes ‘B’), and send it back to your screen. You have successfully created a hardware bridge between two distinct systems.

Example Output (PC Terminal):

FPGA UART initialized at 9600 baud.
Type something: 
User types: hello
FPGA responds: ifmmp

The Core Question You’re Answering

“How do two devices talk to each other when they don’t share the same clock?”

This is the fundamental problem of all networking. Since the PC and FPGA have different “hearts,” you must find a way to agree on the speed (Baud) and find the start of the message.


Concepts You Must Understand First

Stop and research these before coding:

  1. UART Protocol Frame
    • What is the “Idle” state of the wire? (Hint: Logic 1).
    • What is the Start Bit? What is the Stop Bit?
    • Book Reference: “Getting Started with FPGAs” Ch. 8
  2. Oversampling
    • Why do we sample 16 times per bit instead of just once?
    • How does this help with noise?

Questions to Guide Your Design

Before implementing, think through these:

  1. The Clock Divider
    • If your clock is 100MHz and you want 9600 Baud, what number should your counter count to?
    • 100,000,000 / 9,600 = ?
  2. The Receiver FSM
    • How does the FSM know when a new byte is starting? (Detection of a 1-to-0 transition).

Thinking Exercise

The Serial Bit-Stream

Draw a timing diagram for the character ‘A’ (ASCII 0x41, Binary 01000001).

  • Draw the Start Bit (0).
  • Draw the 8 Data Bits (LSB first: 1, 0, 0, 0, 0, 0, 1, 0).
  • Draw the Stop Bit (1).

Questions while drawing:

  • If the FPGA clock is slightly faster than the PC clock, where does the error accumulate?
  • Why is it better to sample in the middle of the bit rather than at the edge?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “Why is UART called ‘Asynchronous’?”
  2. “How do you handle ‘Meta-stability’ when an external signal (RX) enters your clock domain?”
  3. “What happens if the Baud rate mismatch is greater than 5%?”
  4. “Describe the function of a FIFO in a UART system.”
  5. “What is a ‘Parity bit’ and how would you implement it in VHDL?”

Hints in Layers

Hint 1: The Tick Generator Don’t make a new clock. Make a “tick” signal that is ‘1’ for exactly one system clock cycle at the Baud rate.

Hint 2: The TX FSM States: IDLE, START_BIT, DATA_BITS, STOP_BIT. Use a bit-counter (0 to 7) to stay in the DATA_BITS state.

Hint 3: The RX Synchronization Pass the incoming RX signal through two flip-flops (sync_reg_1, sync_reg_2) before using it in your FSM. This prevents meta-stability.

Hint 4: Mid-point Sampling In the RX FSM, wait for the start bit (0), then wait for 1.5 bit-periods. This puts you exactly in the center of Data Bit 0. Then wait exactly 1 bit-period for each subsequent bit.


Books That Will Help

Topic Book Chapter
Serial Protocols “Digital Design and Computer Architecture” by Harris & Harris Ch. 9
UART Implementation “FPGA Prototyping by VHDL Examples” by Pong P. Chu Ch. 7

Project 4: Fixed-Point CORDIC Square Rooter

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: C (for Golden Model), Verilog
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 3: Advanced (The Engineer)
  • Knowledge Area: Computer Arithmetic / DSP
  • Software or Tool: MATLAB or Python (for verification)
  • Main Book: “Digital Signal Processing with Field Programmable Gate Arrays” by Uwe Meyer-Baese

What you’ll build: A hardware module that calculates the square root of a 16-bit number using the CORDIC (Coordinate Rotation Digital Computer) algorithm. You will use only shifts and additions—no multipliers or dividers!

Why it teaches VHDL: This project introduces Fixed-Point Arithmetic and Hardware Optimization. You’ll learn how to represent fractions in binary and how to implement a complex mathematical function without the expensive hardware “math” blocks (DSPs).

Core challenges you’ll face:

  • Fixed-Point Representation → Understanding that “10.5” is represented as an integer with a virtual dot.
  • Iterative Logic → Designing a state machine that runs a specific number of cycles to reach convergence.
  • Rounding and Precision → Handling the bits lost during shifts.

Key Concepts

  • Fixed-Point Numbers: “Digital Design and Computer Architecture” Ch. 5.3.3 - Harris & Harris
  • CORDIC Algorithm: “Hacker’s Delight” Ch. 11 - Henry S. Warren, Jr.

Difficulty: Advanced Time estimate: 2 weeks Prerequisites: Project 1 (Counters) and Project 2 (FSMs).


Real World Outcome

You’ll input a number (e.g., 255) via your UART (from Project 3), and the FPGA will return the square root (15.96) in less than 20 clock cycles. This module can then be reused in radar systems, robotics, or 3D graphics.

Example Output (Testbench):

Input: 0x0100 (256) -> Output: 0x0010 (16.00)
Input: 0x0002 (2.00)  -> Output: 0x0001.6A (1.414)
Cycles to complete: 16
Clock Frequency: 250 MHz

The Core Question You’re Answering

“How do I do ‘heavy’ math when I only have simple logic gates (and no math processor)?”

Most CPUs have a dedicated unit for division and square roots. In an FPGA, you have to build that unit. CORDIC is the elegant way to do trigonometry and roots using only the most basic operations.


Concepts You Must Understand First

Stop and research these before coding:

  1. Q-Notation (Fixed Point)
    • What is Q8.8 format? (8 bits for integer, 8 bits for fraction).
    • How do you add two Q8.8 numbers? How do you multiply them?
    • Book Reference: “Digital Signal Processing with FPGAs” Ch. 3
  2. The CORDIC “Shift-and-Add” Logic
    • How can you approximate a root by iterating through binary search steps?

Questions to Guide Your Design

Before implementing, think through these:

  1. Parallel vs. Serial
    • Should you build 16 stages of logic that work at once (high speed, high area)?
    • Or one stage that you reuse 16 times (low speed, low area)?
  2. Input Scaling
    • CORDIC often requires inputs to be within a specific range (like 0 to 2). How will you scale your 16-bit input?

Thinking Exercise

Manual CORDIC Trace

Try to find the square root of 2 using a 4-bit fraction.

  1. Start with an estimate.
  2. If estimate^2 > 2, subtract a small value.
  3. If estimate^2 < 2, add a small value.

Questions while tracing:

  • How many steps did it take to get close to 1.41?
  • What happens if your “small value” is too large? (Overshoot).

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “Why is floating-point math rare in FPGAs?”
  2. “Explain the trade-off between a pipelined CORDIC and an iterative CORDIC.”
  3. “How many bits of precision do you lose in a 16-iteration CORDIC?”
  4. “What is a ‘DSP Slice’ and when should you use it instead of logic gates?”
  5. “How do you handle overflow in fixed-point addition?”

Hints in Layers

Hint 1: The Representation Use std_logic_vector(15 downto 0) but treat it as unsigned(15 downto 0). Decide that the lower 8 bits are the fraction.

Hint 2: The Iteration Use a counter from 0 to 15. In each state, perform: x <= x + (y srl i); where srl is the shift-right-logical operator.

Hint 3: Pre-computing Constants The CORDIC algorithm uses a table of “Atan” or “Magic constant” values. Since these are constants, store them in a constant array in your VHDL.

Hint 4: Pipelining If you want it to be fast, put flip-flops between every iteration. Now you can calculate a new square root every clock cycle!


Books That Will Help

Topic Book Chapter
Hardware Arithmetic “Digital Design and Computer Architecture” by Harris & Harris Ch. 5
CORDIC Algorithms “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese Ch. 4

Project 5: LFSR-based Stream Cipher (Crypto Core)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: C (for testing), Verilog
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate (The Developer)
  • Knowledge Area: Cryptography / Bit Manipulation
  • Software or Tool: Vivado / Quartus
  • Main Book: “The Art of Computer Programming, Volume 4, Fascicle 1” by Donald E. Knuth

What you’ll build: A Linear Feedback Shift Register (LFSR) that generates a pseudo-random bitstream. You’ll then use this bitstream to XOR with incoming data (from your UART) to create a simple but fast hardware encryptor.

Why it teaches VHDL: This project teaches you about Bitwise Logic and Feedback Loops. You’ll understand how simple XOR gates and shift registers can create complex, repeating patterns. It also introduces the concept of “Hardware Security” by obfuscating data at the wire level.

Core challenges you’ll face:

  • Tap Selection → Choosing the right bits to XOR together so the register doesn’t get stuck in a “Zero” state.
  • Synchronization → Ensuring the sender and receiver LFSRs start with the same “Seed” at the exact same time.
  • Throughput → Matching the LFSR speed to the data source.

Key Concepts

  • LFSR Theory: “The Art of Computer Programming, Vol 4, Fascicle 1” - Knuth
  • Stream Ciphers: “Serious Cryptography” Ch. 4 - Jean-Philippe Aumasson

Difficulty: Intermediate Time estimate: 1 week Prerequisites: Project 3 (UART).


Real World Outcome

You’ll send “SECRET” from your PC. The FPGA will encrypt it and you’ll see gibberish like *&^%$#. Then, you’ll flip a switch to “Decrypt” mode, and the gibberish will turn back into “SECRET”. You’ve built a hardware privacy engine.

Example Output (Hardware Logic Analyzer):

Data_In:  S (01010011)
LFSR_Key: K (10110101)
XOR_Out:  (11100110) -> Sent over wire

The Core Question You’re Answering

“How do I generate ‘randomness’ using perfectly deterministic logic gates?”

Hardware is usually predictable. LFSRs use mathematical “primitive polynomials” to create the longest possible sequence of bits before repeating, simulating randomness.


Concepts You Must Understand First

Stop and research these before coding:

  1. Primitive Polynomials
    • What is a “tap”?
    • Why do certain taps produce longer sequences than others?
  2. XOR Properties
    • Why does (A XOR B) XOR B = A? (The basis of symmetric encryption).

Questions to Guide Your Design

Before implementing, think through these:

  1. The Seed
    • What happens if the seed is all zeros? (Hint: The LFSR will never change).
    • How do you securely load a 32-bit seed into the FPGA?
  2. Parallelism
    • Can you generate 8 random bits in a single clock cycle to encrypt a whole byte?

Thinking Exercise

The 4-bit LFSR Trace

Start with seed 1000. Use taps at bits 4 and 3 (XOR them to find the new bit 1).

  1. 1000 -> bit 1 becomes (1 XOR 0) = 1. New state: 1100.
  2. 1100 -> bit 1 becomes (1 XOR 1) = 0. New state: 0110. Trace this until you get back to 1000.

Questions while tracing:

  • How many steps did it take?
  • If you used 32 bits, how many billions of steps would it take?

The Interview Questions They’ll Ask

  1. “What is the maximum period of an N-bit LFSR?”
  2. “Why is an LFSR not considered cryptographically secure by itself?”
  3. “How do you avoid the ‘all-zero’ state in hardware?”
  4. “What is a ‘Galois LFSR’ vs a ‘Fibonacci LFSR’?”
  5. “How would you use an LFSR for CRC (Cyclic Redundancy Check) calculation?”

Hints in Layers

Hint 1: The Register Use a signal reg : std_logic_vector(31 downto 0);.

Hint 2: The Logic On every clock: reg <= (reg(31) xor reg(21) xor reg(1) xor reg(0)) & reg(31 downto 1); (Example taps for a 32-bit LFSR).

Hint 3: The XOR encrypted_byte <= input_byte xor reg(7 downto 0);

Hint 4: Testbench Check if the sequence repeats. If it repeats too soon, your taps are wrong!


Project 6: VGA Pattern Generator (The Video Clock)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 3: Advanced (The Engineer)
  • Knowledge Area: Video Protocols / High-Speed Timing
  • Software or Tool: Oscilloscope (optional), Monitor with VGA/HDMI
  • Main Book: “Digital Design and Computer Architecture” by Harris & Harris

What you’ll build: A hardware module that generates VGA sync signals (HSYNC, VSYNC) and RGB color data. You’ll display a test pattern (like color bars or a checkerboard) on a real monitor.

Why it teaches VHDL: This is the master class in Timing Constraints. You must match the pixel clock exactly (e.g., 25.175 MHz for 640x480). You’ll learn about “Front Porch,” “Back Porch,” and “Active Video” regions.

Core challenges you’ll face:

  • Pixel Clock Generation → Using a PLL (Phase Locked Loop) or DCM to create a specific frequency from your system clock.
  • Nested Counters → One counter for the horizontal line (pixels) and one for the vertical line (lines).
  • Synchronous Output → Ensuring the RGB data changes exactly when the HSYNC pulse ends.

Key Concepts

  • VGA Timing Standard: “Digital Design and Computer Architecture” Ch. 9.4.1 - Harris & Harris
  • PLLs and Clocking: Official FPGA Vendor Documentation (Xilinx UG472 or Intel Clocking Guide).

Difficulty: Advanced Time estimate: 1-2 weeks Prerequisites: Project 1 (Counters).


Real World Outcome

A monitor connected to your FPGA board will spring to life, displaying a rock-solid image. No software is running. No OS is drawing pixels. Your logic is physically driving the electron beam (or LCD pixels) of the monitor.

Example Output (Timing Diagram):

HSYNC:  ____|~~~~|____ (640 active, 16 front, 96 sync, 48 back)
VSYNC:  ____|~~~~|____ (480 active, 10 front, 2 sync, 33 back)
Total H-Pixels: 800
Total V-Lines: 525

The Core Question You’re Answering

“How do I synchronize hardware with a high-speed physical display?”

A monitor is a “dumb” device. It just follows pulses. If your pulse is 1 microsecond late, the whole screen will flicker or tear. This project forces you to respect the nanosecond.


Concepts You Must Understand First

Stop and research these before coding:

  1. VGA Standard (640x480 @ 60Hz)
    • What is the frequency of the Pixel Clock?
    • What happens during the “Blanking” interval?
  2. PLL (Phase Locked Loop)
    • Why can’t we just use a counter to divide a clock for video? (Hint: Jitter).

Questions to Guide Your Design

Before implementing, think through these:

  1. The Coordinate System
    • How do you map a counter value (0-799) to an X-coordinate (0-639)?
    • What do you output when the counter is in the “Porch” region? (Hint: Always Black).
  2. Color Depth
    • If you have 4 bits per color (R,G,B), how many total colors can you display?

Thinking Exercise

The Scanning Beam

Imagine a beam of light moving across a screen from top-left to bottom-right.

  1. It moves right for 640 pixels.
  2. It “jumps” back to the left (Horizontal Sync).
  3. It repeats this 480 times.
  4. It “jumps” back to the top (Vertical Sync).

Questions while tracing:

  • At what exact pixel count (H) and line count (V) is the pixel at the dead center of the screen?
  • How much “dead time” (non-visible pixels) is there in one full frame?

The Interview Questions They’ll Ask

  1. “What is the difference between a pixel clock and a system clock?”
  2. “How do you handle ‘Clock Domain Crossing’ between your CPU and your Video controller?”
  3. “Explain the purpose of the ‘Blanking’ signal.”
  4. “Why do we use an FPGA instead of a CPU for high-resolution video generation?”
  5. “What is the maximum resolution you could drive with a 100MHz pixel clock?”

Hints in Layers

Hint 1: The PLL Use the “Clocking Wizard” (Vivado) or “IP Catalog” (Quartus) to generate a 25.175 MHz clock. Don’t try to write this in VHDL.

Hint 2: The Counters H_count goes 0 to 799. V_count increments only when H_count wraps around.

Hint 3: The Sync Pulses HSYNC <= '0' when (H_count >= 656 and H_count < 752) else '1'; (Negative sync).

Hint 4: The RGB Output Red <= "1111" when (H_count < 640 and V_count < 480) else "0000"; (Fill screen with Red).


Project 7: Grayscale Image Processor (BRAM Mastery)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Python (to convert image to .coe/.mif file)
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 3: Advanced (The Engineer)
  • Knowledge Area: Memory Interfacing / Image Processing
  • Software or Tool: Python (Pillow library)
  • Main Book: “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese

What you’ll build: A system that stores a small image (e.g., 128x128) in the FPGA’s internal Block RAM (BRAM). You’ll implement hardware logic to read the RGB pixels, calculate the luminance (Grayscale), and output the result to your VGA module.

Why it teaches VHDL: This project introduces Internal Memory. FPGAs have dedicated memory blocks (BRAM) that are much faster than external RAM. You’ll learn about Memory Latency: why the data you ask for doesn’t appear until the next clock cycle.

Core challenges you’ll face:

  • Memory Initialization → Converting a JPEG into a format the FPGA can load (COE/MIF files).
  • Dual-Port RAM → Reading and writing to memory simultaneously.
  • Latency Alignment → Ensuring your RGB math stays synchronized with the VGA sync signals (which have no latency).

Key Concepts

  • Block RAM: FPGA Vendor User Guide (e.g., Xilinx 7-Series Memory Resources).
  • Luminance Formula: Y = 0.299R + 0.587G + 0.114B.

Difficulty: Advanced Time estimate: 2 weeks Prerequisites: Project 6 (VGA).


Real World Outcome

Your VGA monitor will show a static photograph. By flipping a switch, the color photo will instantly turn grayscale. You are witnessing hardware-speed image processing.

Example Output (Calculation Trace):

Input: R=200, G=100, B=50 (Orange)
Calculation: (200*0.3) + (100*0.6) + (50*0.1) = 60 + 60 + 5 = 125
Output: Gray=125
Latency: 2 clock cycles from RAM read to Output

The Core Question You’re Answering

“How do I handle the ‘wait time’ between asking for data and receiving it?”

In software, you just wait. In hardware, the clock keeps ticking. If you ask for a pixel at T=1, it arrives at T=2. Your VGA controller needs to know that!


Concepts You Must Understand First

Stop and research these before coding:

  1. Memory Read Latency
    • If I put the address on the bus at cycle 10, when does the data appear?
  2. Integer Arithmetic for Fractions
    • How do you multiply by 0.299 without a floating-point unit? (Hint: Multiply by 306 and shift right by 10).

Questions to Guide Your Design

Before implementing, think through these:

  1. Storage
    • A 128x128 image with 12-bit color takes 196,608 bits. Does your FPGA have enough BRAM for this?
  2. Addressing
    • How do you convert an (X, Y) coordinate into a single linear memory address? Addr = (Y * Width) + X.

Thinking Exercise

The Pipeline Stall

Imagine a pipe with 3 segments:

  1. Fetch Address
  2. Read RAM
  3. Calculate Gray At T=1, you fetch pixel (0,0). At T=2, pixel (0,0) is in the RAM read stage, you fetch pixel (0,1). At T=3, pixel (0,0) is being converted to Gray, (0,1) is in RAM read, you fetch (0,2).

Questions:

  • At what time is the FIRST grayscale pixel ready?
  • How many pixels are “in flight” at once?

The Interview Questions They’ll Ask

  1. “What is a Dual-Port RAM and why is it useful for video?”
  2. “Explain the difference between Distributed RAM and Block RAM.”
  3. “How do you handle memory initialization in VHDL?”
  4. “What is ‘Pipeland Balancing’ and why is it needed here?”
  5. “If your BRAM is too small, how would you interface with an external DDR3 chip?”

Hints in Layers

Hint 1: The Image Format Use Python to generate a .coe file (for Xilinx) or .mif (for Intel). It’s just a text file of hex values.

Hint 2: The Memory Generator Use the “IP Catalog” to create a Single-Port ROM. Tell it to use your COE file as the initial content.

Hint 3: The Math To approximate 0.299R + 0.587G + 0.114B, use: (R*4 + G*10 + B*2) / 16. Since 16 is a power of 2, the division is just a shift srl 4.

Hint 4: Synchronization Since the RAM and Math add 2 cycles of delay, you must delay your HSYNC and VSYNC signals by exactly 2 clock cycles using a shift register (delay line).


Project 8: Sobel Edge Detection (The Pipeline)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 5. The “Industry Disruptor”
  • Difficulty: Level 4: Expert (The Systems Architect)
  • Knowledge Area: Pipelining / Convolution / Vision
  • Software or Tool: MATLAB/Python for golden model
  • Main Book: “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese

What you’ll build: A hardware convolution engine that performs Sobel Edge Detection in real-time. It will take the grayscale image from Project 7 and find all the edges (vertical and horizontal).

Why it teaches VHDL: This is the pinnacle of Pipelined Architectures. To calculate an edge, you need a 3x3 window of pixels. This means you need Line Buffers to store the previous two lines of video while you process the third.

Core challenges you’ll face:

  • Line Buffers → Using BRAM as a FIFO to hold a full line of image data.
  • 3x3 Sliding Window → Managing 9 pixels at once.
  • Pipelined Math → Performing 6 additions and 4 shifts in a single clock cycle (or spreading it across stages).

Key Concepts

  • Sobel Operator: Two 3x3 kernels (Gx and Gy).
  • Convolution in Hardware: “Digital Signal Processing with FPGAs” Ch. 8.

Difficulty: Expert Time estimate: 3-4 weeks Prerequisites: Project 7 (BRAM).


Real World Outcome

You’ll see your image on the monitor transformed. The colors disappear, replaced by bright white lines on a black background, highlighting every edge in the photo. It looks exactly like the “Edge” filter in Photoshop, but it’s happening in raw silicon.

Example Output (Sobel Kernel):

Gx Kernel:     Gy Kernel:
[-1 0 +1]      [+1 +2 +1]
[-2 0 +2]      [ 0  0  0]
[-1 0 +1]      [-1 -2 -1]

Result = sqrt(Gx^2 + Gy^2) (Approx: |Gx| + |Gy|)

The Core Question You’re Answering

“How do I process data that hasn’t arrived yet?”

To process a pixel at (X, Y), you need pixels from (X-1, Y-1) and (X+1, Y+1). This forces you to think about Data Locality and how to buffer enough data to “look back” in time.


Concepts You Must Understand First

Stop and research these before coding:

  1. Sliding Window Buffer
    • How do you use two FIFOs to turn a stream of pixels into a 3x3 grid?
  2. Resource Constraints
    • How many multipliers does your Sobel engine need? (Hint: If you’re smart, zero—it’s all powers of 2).

Questions to Guide Your Design

Before implementing, think through these:

  1. Boundary Conditions
    • What do you do at the very edge of the image (X=0 or Y=0)? (Hint: Zero padding).
  2. Bit Growth
    • If you add nine 8-bit numbers, how many bits do you need for the result? (Don’t let your math overflow!).

Thinking Exercise

The Line Buffer Trace

Imagine you have a 4x4 image. You want to see the 3x3 window centered at (1,1).

  1. Line Buffer 1 holds Line 0.
  2. Line Buffer 2 holds Line 1.
  3. You are currently receiving Line 2.

Questions:

  • Which pixels from Line 0 and Line 1 do you need right now?
  • How many BRAMs do you need to implement this for a 1080p stream?

The Interview Questions They’ll Ask

  1. “What is a ‘Line Buffer’ and why is it essential for image processing?”
  2. “Explain the trade-off between throughput and latency in a Sobel pipeline.”
  3. “How would you handle a 5x5 or 7x7 kernel?”
  4. “What is ‘Tiling’ in the context of FPGA memory?”
  5. “If you were limited by power, how would you optimize this design?”

Hints in Layers

Hint 1: The Buffer Use the FPGA vendor’s “FIFO Generator” to create two FIFOs, each exactly the width of your image (e.g., 128 deep).

Hint 2: The Window Create 9 signals: p11, p12, p13, p21, p22, p23, p31, p32, p33. Update them every clock cycle like a shift register.

Hint 3: The Kernel Math Gx <= (p13 + 2*p23 + p33) - (p11 + 2*p21 + p31); Gy <= (p11 + 2*p12 + p13) - (p31 + 2*p32 + p33);

Hint 4: Absolute Value The final edge value is abs(Gx) + abs(Gy). Make sure to clamp the result to 255 so it doesn’t wrap around to 0!


Books That Will Help

Topic Book Chapter
Image Processing Theory “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese Ch. 8
VHDL Pipelines “FPGA Prototyping by VHDL Examples” by Pong P. Chu Ch. 11

Project 9: Tiny Encryption Algorithm (TEA)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: C (for verification)
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 3: Advanced (The Engineer)
  • Knowledge Area: Cryptography / Datapath Design
  • Software or Tool: Vivado / Quartus / GHDL
  • Main Book: “Serious Cryptography” by Jean-Philippe Aumasson

What you’ll build: A hardware implementation of the Tiny Encryption Algorithm (TEA). It uses 32 rounds of additions, shifts, and XORs to encrypt a 64-bit block of data with a 128-bit key.

Why it teaches VHDL: This project teaches you how to implement a Complex Iterative Datapath. Unlike the LFSR, TEA requires multiple operations per round and a specific “Delta” constant. You’ll learn how to reuse a single set of hardware to perform multiple rounds (Resource Sharing).

Core challenges you’ll face:

  • State Control → Managing the 32 iterations and signaling when the data is ready.
  • Fixed-Step Constants → Implementing the “Golden Ratio” constant (0x9E3779B9) accumulation.
  • Bitwise Shifting → Ensuring the shifts and XORs perfectly match the C implementation.

Key Concepts

  • Feistel Ciphers: “Serious Cryptography” Ch. 4 - Aumasson
  • Resource Sharing: “FPGA Prototyping by VHDL Examples” Ch. 5.2 - Pong P. Chu

Difficulty: Advanced Time estimate: 1-2 weeks Prerequisites: Project 3 (UART).


Real World Outcome

You will feed 64 bits of data into the FPGA via UART. The FPGA will crunch the numbers for 32 clock cycles and return the ciphertext. This is the first step toward building a “Hardware Security Module” (HSM).

Example Output (Console):

Plaintext:  0x0123456789ABCDEF
Key:        0x00112233445566778899AABBCCDDEEFF
Ciphertext: 0x4B3D... (Encrypted in 32 cycles)

The Core Question You’re Answering

“How do I balance ‘Speed’ vs. ‘Chip Area’ in a cryptographic core?”

You could build 32 copies of the TEA round (high speed, huge area) or one copy that runs 32 times (slow speed, tiny area). This project forces you to make that architectural choice.


Concepts You Must Understand First

Stop and research these before coding:

  1. The Feistel Network
    • How does TEA split the 64-bit block into two 32-bit halves?
    • How does it swap them in each round?
  2. Unsigned vs. Signed
    • Why do we use unsigned for crypto math? (Hint: No sign bit worries).

Questions to Guide Your Design

Before implementing, think through these:

  1. The Loop
    • How do you design an FSM that stays in the ENCRYPT state for exactly 32 clock cycles?
  2. The Key Schedule
    • TEA uses 4 sub-keys. How do you rotate through them each round?

Thinking Exercise

The TEA Round Trace

Do one round of TEA by hand for L=0, R=0 with Key[0]=0x12345678. Formula: sum += delta; L += ((R << 4) + k[0]) ^ (R + sum) ^ ((R >> 5) + k[1]);

Questions:

  • How many different XOR operations are in one round?
  • Can these be done in parallel or must they be sequential?

The Interview Questions They’ll Ask

  1. “Explain the difference between an ‘Iterative’ and a ‘Fully Unrolled’ hardware cipher.”
  2. “How many clock cycles does your TEA core take per 64-bit block?”
  3. “What is the maximum frequency (Fmax) of your design?”
  4. “How do you handle the ‘sum’ constant accumulation in hardware?”
  5. “If you needed to encrypt 10Gbps of data, how would you modify this design?”

Hints in Layers

Hint 1: The Registers Create L_reg, R_reg, and sum_reg. Update them only when the FSM is in the WORK state.

Hint 2: The Shift-Add-XOR temp_L <= ((R_reg sll 4) + k0) xor (R_reg + sum_reg) xor ((R_reg srl 5) + k1);

Hint 3: The State Machine States: IDLE (wait for start bit), CALC (loop 32 times), DONE (set ready signal).

Hint 4: Verification Use a C program to generate the “Golden Vectors” (the expected answers) and check them against your VHDL simulation.


Project 10: AES-128 Encryption Core (The Industry Standard)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 5: Master (The First-Principles Wizard)
  • Knowledge Area: Cryptography / High-Performance Design
  • Software or Tool: OpenSSL (for verification)
  • Main Book: “The Design of Rijndael” by Joan Daemen and Vincent Rijmen

What you’ll build: A full implementation of the Advanced Encryption Standard (AES) with a 128-bit key. You’ll implement SubBytes (using BRAM as S-Boxes), ShiftRows, MixColumns, and the Key Expansion.

Why it teaches VHDL: This is the “boss fight” of hardware design. You’ll learn how to handle Wide Datapaths (128 bits), Parallel S-Box Lookups, and Galois Field Arithmetic (the math behind MixColumns).

Core challenges you’ll face:

  • S-Box Implementation → Efficiently placing the 256-byte lookup table in BRAM or Logic.
  • MixColumns → Implementing the GF(2^8) multiplication (multiplying by 2 and 3 in hardware).
  • Key Expansion → Generating the 10 round keys on-the-fly or pre-calculating them.

Key Concepts

  • Substitution-Permutation Networks: “Serious Cryptography” Ch. 4 - Aumasson
  • AES Specification: FIPS 197 (The official NIST document).

Difficulty: Master Time estimate: 1 month Prerequisites: Project 9 (TEA).


Real World Outcome

You’ll have a core that can encrypt data at the full speed of your clock (e.g., 100 million blocks per second if fully pipelined). This is faster than almost any software implementation. You can now build a hardware-encrypted USB drive or a VPN accelerator.

Example Output (Testbench):

State: 00112233445566778899AABBCCDDEEFF
Key:   000102030405060708090A0B0C0D0E0F
Round 1 Result: ...
Final Ciphertext: 69C4E0D86A7B0430D8CDB78070B4C55A

The Core Question You’re Answering

“How do I implement highly complex, non-linear math efficiently in silicon?”

AES is designed to be hard for CPUs but easy for hardware. By implementing SubBytes and MixColumns, you’ll see how hardware can do 16 lookups and a matrix multiplication in a single heartbeat.


Concepts You Must Understand First

Stop and research these before coding:

  1. The 4 Steps of AES
    • What does ShiftRows do to the 4x4 state matrix?
    • How does AddRoundKey work? (Hint: It’s just XOR).
  2. Key Expansion
    • How does one 128-bit key become eleven 128-bit keys?

Questions to Guide Your Design

Before implementing, think through these:

  1. Logic vs. Memory
    • Should you use BRAM for the S-Box (saves logic, adds 1 cycle latency) or Logic Gates (saves latency, uses more area)?
  2. MixColumns Optimization
    • Multiplication by 2 in Galois Field is just a left shift and an optional XOR with 0x1B. Can you implement this without a multiplier?

Thinking Exercise

The AES State Matrix

Draw a 4x4 grid. Fill it with the numbers 0-15.

  1. Perform ShiftRows: Row 0 (no shift), Row 1 (shift left 1), Row 2 (shift left 2), Row 3 (shift left 3).
  2. Where did the number 13 end up?

Questions:

  • Why does this “mixing” make the cipher harder to break?
  • How many wires are needed to move this whole matrix at once? (4x4x8 = 128 bits).

The Interview Questions They’ll Ask

  1. “What is the difference between AES-ECB and AES-CBC modes in hardware?”
  2. “How do you protect your AES core against ‘Side-Channel Power Analysis’?”
  3. “Compare the performance of your AES core to a modern Intel CPU with AES-NI instructions.”
  4. “Why is MixColumns the most expensive part of the hardware implementation?”
  5. “Explain how you would implement the AES Decryption path (InvMixColumns).”

Hints in Layers

Hint 1: The State Matrix Use an array of std_logic_vector(7 downto 0): type state_t is array(0 to 3, 0 to 3) of std_logic_vector(7 downto 0);.

Hint 2: SubBytes Create a 256-entry constant array for the S-Box. Wrap it in a function so you can call SubBytes(byte_in).

Hint 3: ShiftRows This is zero cost! You just wire the outputs of the previous stage to different inputs of the next stage.

Hint 4: MixColumns Implement a helper function gmul2(byte) that does: if byte(7)='1' then return (byte sll 1) xor x"1b"; else return (byte sll 1); end if;.


Project 11: Median Filter for Video (Noise Reduction)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 4: Expert (The Systems Architect)
  • Knowledge Area: Sorting Networks / Video Processing
  • Software or Tool: Vivado / Quartus
  • Main Book: “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese

What you’ll build: A hardware filter that removes “Salt and Pepper” noise from a video stream. It takes a 3x3 window of pixels (like Project 8) but instead of math, it performs a Hardware Sort and picks the middle (median) value.

Why it teaches VHDL: This project teaches you about Sorting Networks (like the Batcher Odd-Even Mergesort). You’ll learn how to build a hardware “Compare-and-Swap” unit and how to pipeline a sorting algorithm to handle millions of pixels per second.

Core challenges you’ll face:

  • Compare-and-Swap (CAS) → The basic building block of hardware sorting.
  • Pipelined Sorting → Sorting 9 numbers in exactly 5 or 9 clock cycles.
  • Resource Management → Balancing the number of CAS units vs. the speed of the filter.

Key Concepts

  • Median Filtering: “Digital Signal Processing with FPGAs” Ch. 8.4.
  • Sorting Networks: “The Art of Computer Programming, Vol 3: Sorting and Searching” - Knuth.

Difficulty: Expert Time estimate: 2 weeks Prerequisites: Project 8 (Sobel).


Real World Outcome

You’ll feed a noisy image into the FPGA. The “Salt” (white dots) and “Pepper” (black dots) will vanish, leaving a clean, slightly blurred image. This is a critical component for pre-processing in medical imaging or machine vision.

Example Output (Simulation):

Window: [10, 255, 12, 11, 0, 15, 12, 14, 13] (Contains noise: 0 and 255)
Sorted: [0, 10, 11, 12, 12, 13, 14, 15, 255]
Median: 12 (Noise is gone!)

The Core Question You’re Answering

“How do I sort data when I don’t have a CPU and ‘quick-sort’ is impossible?”

Software sorting relies on comparisons and jumps. In hardware, you don’t “jump.” You build a physical network of comparators that the data flows through, emerging sorted at the other end.


Concepts You Must Understand First

Stop and research these before coding:

  1. Sorting Networks (Batcher)
    • What is a Compare-and-Swap unit?
    • How many stages are needed to sort 9 values?
  2. Data Throughput
    • Can your sorter handle a new set of 9 pixels every clock cycle?

Questions to Guide Your Design

Before implementing, think through these:

  1. Area vs. Speed
    • Should you use a 9-stage pipeline (one CAS per stage) or 25 CAS units in one stage (risks timing failure)?
  2. Line Buffers
    • Re-use your line buffer logic from Project 8. Is it fast enough to feed the sorter?

Thinking Exercise

The Hardware Swapper

Logic: if A > B then High=A, Low=B; else High=B, Low=A; end if; Draw 4 lines (A, B, C, D).

  1. Swap (A,B) and (C,D).
  2. Swap (A,C) and (B,D).
  3. Swap (B,C). Are the lines now in order?

Questions:

  • How many comparisons are needed for 4 items?
  • How many for 9?

The Interview Questions They’ll Ask

  1. “Why is a Compare-and-Swap network better than a Bubble Sort for FPGAs?”
  2. “Explain the ‘latency’ of your sorting network.”
  3. “What happens to the timing (Fmax) as the sorting network gets larger?”
  4. “How would you implement a ‘Moving Average’ filter vs a ‘Median’ filter?”
  5. “Can you sort 16-bit values with the same network you used for 8-bit?”

Hints in Layers

Hint 1: The CAS Unit Create a component CAS with two inputs and two outputs. It sorts the two inputs.

Hint 2: The Network Connect the CAS units in a “Sorting Network” pattern. For 9 items, use a known optimal network (like the Bose-Nelson or Hibbard network).

Hint 3: Pipelining Put a register (process with rising_edge(clk)) between every layer of CAS units.

Hint 4: Synchronization Just like the Sobel project, make sure to delay your video sync signals (HSYNC, VSYNC) to match the latency of the sorter.


Project 12: SHA-256 Hash Engine (Bitcoin’s Heart)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Verilog
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 5. The “Industry Disruptor”
  • Difficulty: Level 5: Master (The First-Principles Wizard)
  • Knowledge Area: Cryptography / Pipelining
  • Software or Tool: SHA-256 online calculator
  • Main Book: “Serious Cryptography” by Jean-Philippe Aumasson

What you’ll build: A hardware module that calculates a SHA-256 hash. You’ll implement the 64 rounds of message scheduling, the logical functions (Ch, Maj, Σ), and the constant addition.

Why it teaches VHDL: This project teaches you Massive Parallelism and Loop Unrolling. You’ll understand why Bitcoin miners use FPGAs/ASICs: because hardware can do the 64 rounds of SHA-256 much faster and more efficiently than a general-purpose CPU.

Core challenges you’ll face:

  • Message Scheduling → Expanding a 512-bit block into 64 sub-blocks of 32 bits.
  • Resource Bottlenecks → SHA-256 requires many additions. You’ll need to optimize the “Carry Chain” logic in your FPGA.
  • High-Speed Clocking → Pushing the design to run at 200+ MHz.

Key Concepts

  • Cryptographic Hashing: “Serious Cryptography” Ch. 6 - Aumasson.
  • SHA-256 Specification: FIPS 180-4.

Difficulty: Master Time estimate: 3-4 weeks Prerequisites: Project 10 (AES).


Real World Outcome

You’ll input a string (e.g., “Hello World”) and get the 256-bit hash in 64 clock cycles. If you pipeline it, you can calculate millions of hashes per second. You’ve built the fundamental engine of a blockchain miner.

Example Output (Simulation):

Input: "abc"
Hash: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
Throughput: 100 MH/s (at 100MHz clock, fully pipelined)

The Core Question You’re Answering

“How do I maximize throughput for a compute-intensive algorithm?”

SHA-256 is a “one-way” function that requires 64 steps. In hardware, you can build 64 physical stages. This project teaches you how to keep every stage of the factory busy simultaneously.


Concepts You Must Understand First

Stop and research these before coding:

  1. SHA-256 Rounds
    • What are the A, B, C, D, E, F, G, H registers?
    • How are they updated in each round?
  2. Message Padding
    • How do you handle strings that aren’t exactly 512 bits long?

Questions to Guide Your Design

Before implementing, think through these:

  1. Iterative vs. Pipelined
    • An iterative SHA-256 core uses very little space. A pipelined core uses 64 times as much space but is 64 times faster. Which one fits on your FPGA?
  2. Adder Optimization
    • SHA-256 is mostly additions. Does your FPGA have “Carry Look-Ahead” hardware?

Thinking Exercise

The SHA-256 Message Schedule

To calculate round 16, you need data from rounds 0, 1, 9, and 14. W[i] = σ1(W[i−2]) + W[i−7] + σ0(W[i−15]) + W[i−16]

Questions:

  • How do you “remember” the previous 16 values in hardware? (Hint: A shift register of 32-bit words).
  • Why does SHA-256 use specific “Magic Numbers” (the fractional parts of prime roots)?

The Interview Questions They’ll Ask

  1. “What is the bottleneck for SHA-256 performance on an FPGA?”
  2. “Explain ‘Loop Unrolling’ and its impact on Fmax.”
  3. “How would you implement SHA-256 as an AXI-Stream peripheral for a Soft-core CPU?”
  4. “Compare the power efficiency of your FPGA SHA-256 core to a GPU.”
  5. “What is a ‘Carry Chain’ and how does it limit your clock speed?”

Hints in Layers

Hint 1: The Round Logic Create a component or function for a single SHA-256 round. It takes the 8 registers (A-H), a message word (W), and a constant (K).

Hint 2: The Message Scheduler Use a 16-element shift register of unsigned(31 downto 0).

Hint 3: The Pipeline If you unroll the loop, put a register after every 1, 2, or 4 rounds to keep the timing clean.

Hint 4: Verification NIST provides “Test Vectors”. If your output is off by even one bit, the whole hash will be wrong!


Books That Will Help

Topic Book Chapter
Hashing Theory “Serious Cryptography” by Jean-Philippe Aumasson Ch. 6
High-Speed Hardware “Digital Design and Computer Architecture” by Harris & Harris Ch. 5

Project 13: The Soft-Core CPU (MIPS Subset)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Assembly (to write code for your CPU)
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 5. The “Industry Disruptor”
  • Difficulty: Level 5: Master (The First-Principles Wizard)
  • Knowledge Area: Computer Architecture / ISAs
  • Software or Tool: MIPS Assembler (Mars or Spim)
  • Main Book: “Digital Design and Computer Architecture” by Harris & Harris

What you’ll build: A 32-bit RISC processor that implements a subset of the MIPS instruction set. You’ll build the Fetch, Decode, Execute, Memory, and Write-back stages.

Why it teaches VHDL: This is the ultimate synthesis of all previous concepts. A CPU is just a massive FSM controlling a massive datapath. You’ll learn how to implement Instruction Decoding, Register Files, and an Arithmetic Logic Unit (ALU).

Core challenges you’ll face:

  • Control Unit → Generating the correct “Select” signals for every mux in the chip based on an opcode.
  • Register File → Creating a memory block that allows two reads and one write in a single cycle.
  • Hazard Handling → (If pipelining) dealing with “Data Hazards” (using a result before it’s written).

Key Concepts

  • The 5-Stage Pipeline: “Digital Design and Computer Architecture” Ch. 7 - Harris & Harris.
  • ALU Design: “Computer Organization and Design” - Patterson & Hennessy.

Difficulty: Master Time estimate: 1 month+ Prerequisites: Project 1-4.


Real World Outcome

You’ll write a simple program in MIPS Assembly (like a Fibonacci calculator), compile it to hex, load it into your FPGA’s BRAM, and watch your own CPU execute it. You are no longer just a coder; you are a computer architect.

Example Output (Testbench Trace):

PC: 0x0004  Instr: ADDI $1, $0, 10  (Set R1 = 10)
PC: 0x0008  Instr: ADDI $2, $0, 20  (Set R2 = 20)
PC: 0x000C  Instr: ADD  $3, $1, $2  (Set R3 = 30)
Register 3 value: 30

The Core Question You’re Answering

“How does a piece of silicon ‘know’ how to follow instructions?”

By building the Fetch-Decode-Execute cycle, you’ll realize that “software” is just data that flips switches in your hardware.


Project 14: Neural Network Neuron (Hardware MAC)

  • File: FPGA_DESIGN_VHDL_MASTERY.md
  • Main Programming Language: VHDL
  • Alternative Programming Languages: Python (to train a simple model)
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 5. The “Industry Disruptor”
  • Difficulty: Level 4: Expert (The Systems Architect)
  • Knowledge Area: AI Hardware / Parallel Math
  • Software or Tool: TensorFlow/PyTorch (for weights)
  • Main Book: “Digital Signal Processing with FPGAs” by Uwe Meyer-Baese

What you’ll build: A hardware-accelerated “Neuron” that performs a high-speed Multiply-Accumulate (MAC) operation. You’ll take 8 inputs, multiply them by 8 weights (trained in Python), add them up, and pass them through a ReLU activation function.

Why it teaches VHDL: This project teaches you about DSP Slices. FPGAs have dedicated hardware for multiplying and adding. You’ll learn how to infer these blocks in VHDL and how to handle Parallel Data Loading for AI inference.

Core challenges you’ll face:

  • DSP Inference → Writing VHDL that the compiler recognizes as a DSP48 (Xilinx) or Multiplier (Intel) block.
  • Activation Functions → Implementing ReLU (simple) or Sigmoid (hard - use a lookup table!).
  • Quantization → Using 8-bit integers for AI weights instead of 32-bit floats.

Key Concepts

  • MAC Units: “Digital Design and Computer Architecture” Ch. 5.
  • Quantized AI: “AI Engineering” - Chip Huyen (General concept).

Difficulty: Expert Time estimate: 2 weeks Prerequisites: Project 4 (CORDIC/Fixed Point).


Real World Outcome

You’ll build a hardware accelerator that can perform AI classification (like identifying a handwritten ‘3’) thousands of times faster than a standard microcontroller.

Example Output (Hardware Trace):

Inputs: [1, 0, 1, 0...]
Weights: [0.5, -0.2, 0.8, 0.1...]
MAC Result: 1.4
ReLU Output: 1.4 (Active!)

Project Comparison Table

Project Difficulty Time Depth of Understanding Fun Factor
PWM Dimmer Level 1 Weekend Hardware Basics ⭐⭐
Traffic Light FSM Level 2 1 Week Logic Control ⭐⭐⭐
UART Controller Level 2 2 Weeks Communication ⭐⭐⭐⭐
CORDIC Rooter Level 3 2 Weeks Fixed-Point Math ⭐⭐⭐
LFSR Stream Cipher Level 2 1 Week Bitwise Crypto ⭐⭐⭐
VGA Generator Level 3 2 Weeks High-Speed Timing ⭐⭐⭐⭐⭐
Image Processor Level 3 2 Weeks Memory/Latency ⭐⭐⭐⭐
Sobel Edge Detect Level 4 4 Weeks Pipelining ⭐⭐⭐⭐⭐
TEA Encryptor Level 3 2 Weeks Datapath Design ⭐⭐⭐
AES-128 Core Level 5 1 Month Advanced Crypto ⭐⭐⭐⭐⭐
Median Filter Level 4 2 Weeks Sorting Networks ⭐⭐⭐⭐
SHA-256 Engine Level 5 4 Weeks Massive Parallelism ⭐⭐⭐⭐⭐
Soft-Core CPU Level 5 1 Month+ Full Systems ⭐⭐⭐⭐⭐
Neural Neuron Level 4 2 Weeks AI Hardware ⭐⭐⭐⭐

Recommendation

Start with Project 1 (PWM Dimmer) to understand the basic syntax of VHDL and the “Physicality” of the signals. Then, move to Project 3 (UART). Once you have a UART, you can “talk” to every other project from your PC, which makes debugging much easier.


Final Overall Project: The Encrypted Video Streamer

What you’ll build: A complete system that takes a real-time video feed (from a camera or BRAM), applies a Sobel Edge Detection filter, Encrypts the result using your AES-128 core, and outputs the encrypted data via Ethernet or High-Speed UART.

Why it teaches the whole stack: This project requires you to integrate:

  1. Video Buffering (Project 7/8)
  2. Complex Math Pipelining (Project 8/11)
  3. Advanced Cryptography (Project 10)
  4. System-on-Chip (SoC) integration (Project 13)

You will have to manage clock domains, large memory buffers, and massive data throughput simultaneously.


Summary

This learning path covers FPGA Design with VHDL through 14 hands-on projects. Here’s the complete list:

# Project Name Main Language Difficulty Time Estimate
1 PWM Dimmer VHDL Beginner Weekend
2 Traffic Light FSM VHDL Intermediate 1 Week
3 UART Controller VHDL Intermediate 1-2 Weeks
4 CORDIC Rooter VHDL Advanced 2 Weeks
5 LFSR Stream Cipher VHDL Intermediate 1 Week
6 VGA Generator VHDL Advanced 2 Weeks
7 Image Processor VHDL Advanced 2 Weeks
8 Sobel Edge Detect VHDL Expert 4 Weeks
9 TEA Encryptor VHDL Advanced 1-2 Weeks
10 AES-128 Core VHDL Master 1 Month
11 Median Filter VHDL Expert 2 Weeks
12 SHA-256 Engine VHDL Master 4 Weeks
13 Soft-Core CPU VHDL Master 1 Month+
14 Neural Neuron VHDL Expert 2 Weeks

For beginners: Start with projects #1, #2, #3, and #6. Focus on mastering the clock and state machines. For intermediate: Focus on projects #4, #7, #8, and #9. Master memory and pipelining. For advanced: Focus on projects #10, #12, and #13. This is where you build world-class hardware skills.

Expected Outcomes

After completing these projects, you will:

  • Understand VHDL from first principles (concurrency, signals, processes).
  • Be able to design high-speed hardware pipelines for any algorithm.
  • Master the use of BRAM, DSP slices, and PLLs.
  • Be able to implement industry-standard cryptographic and video protocols.
  • Understand computer architecture at the gate level by building your own CPU.

You’ll have built 14 working projects that demonstrate deep understanding of FPGA Design from first principles.