The FPGA Programming Handbook - Second Edition

Book description

Develop solid FPGA programming skills in SystemVerilog and VHDL by crafting practical projects – VGA controller, microprocessor, calculator, keyboard – and amplify your know-how with insider industry knowledge, all in one handbook. Purchase of the print or Kindle book includes a free eBook in PDF format

Key Features

  • Explore a wide range of FPGA applications, grasp their versatility, and master Xilinx FPGA tool flow
  • Master the intricacies of SystemVerilog and VHDL to develop robust and efficient hardware circuits
  • Refine skills with CPU, VGA, and calculator projects for practical expertise in real-world applications

Book Description

In today's tech-driven world, Field Programmable Gate Arrays (FPGAs) are the foundation of many modern systems. Transforming ideas into reality demands a deep dive into FPGA architecture, tools, and design principles. This FPGA book is your companion to mastering FPGA development with SystemVerilog and VHDL.

In this edition, you will master both SystemVerilog and VHDL, gaining supreme versatility in FPGA design. These skills open doors to diverse opportunities and projects in the field. Move beyond theory with real-world projects, starting from LED control and progressing to advanced microcontroller applications, which are highly sought after in today's FPGA job market. You will journey from basic Boolean logic circuits to a resource-optimized calculator, showcasing your hardware design prowess. You will elevate your knowledge by designing a Video Graphics Array (VGA) controller, demonstrating your ability to synthesize complex hardware systems.

You can use this handbook as your FPGA development guide, where you will master intricacies, ignite creativity, and emerge with the expertise to craft hardware circuits using SystemVerilog and VHDL. The FPGA Programming Handbook isn't just another technical manual; it's your exhilarating journey to master theory and practice, accelerating your FPGA design skills to soaring new heights.

What you will learn

  • Understand the FPGA architecture and its implementation
  • Get to grips with writing SystemVerilog and VHDL RTL
  • Make FPGA projects using SystemVerilog and VHDL programming
  • Work with computer math basics, parallelism, and pipelining
  • Explore the advanced topics of AXI and keyboard interfacing with PS/2
  • Discover how you can implement a VGA interface in your projects
  • Explore the PMOD connectors-SPI and UART, using Nexys A7 board
  • Implement an embedded microcontroller in the FPGA

Who this book is for

This FPGA design book is for embedded system developers, engineers, and programmers who want to learn FPGA design using SystemVerilog or VHDL programming from scratch. FPGA designers looking to gain hands-on experience in working on real-world projects will also find this book useful.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Get in touch
  2. Introduction to FPGA Architectures
    1. Technical requirements
    2. What is an ASIC?
      1. Why an ASIC or FPGA?
      2. How does a company create a programmable device using an ASIC process?
      3. Introduction to HDLs
        1. Logical versus bitwise operations
        2. Creating gates using HDL
        3. Assign statement (SystemVerilog/Verilog)
        4. Assign statement equivalent (VHDL)
        5. Single line comments
        6. Multiline comments
        7. if statement
      4. Fundamental logic gates
        1. Logical NOT
        2. Logical AND
        3. Logical OR
        4. XOR
        5. More complex operations
    3. Introducing FPGAs
      1. Exploring the Xilinx Artix-7 and 7 series devices
        1. Combinational logic blocks
        2. Storage
        3. Clocking
        4. I/Os
        5. DSP48E1 – Xilinx DSP core in 7 series devices
        6. ASMBL architecture
    4. Evaluation boards
      1. Nexys A7 100T (or 50T)
    5. Summary
    6. Questions
    7. Answers
    8. Further reading
  3. FPGA Programming Languages and Tools
    1. Technical requirements
      1. Hardware
        1. Information on the Nexys A7
      2. Software
    2. Hardware Description Languages (HDLs)
      1. SystemVerilog versus Verilog
      2. SystemVerilog versus VHDL
    3. Introducing Vitis and Vivado
      1. Vivado installation
      2. Design flow
        1. Design definition/specification
        2. Design entry/constraints
        3. Simulation
        4. Synthesis
        5. Implementation
      3. Running the example
        1. Loading the design
      4. Directory structure
      5. Testbench
        1. VHDL testbench
        2. Running a simulation
        3. Implementation
        4. Program the board
    4. Summary
    5. Questions
    6. Answers
    7. Challenge
    8. Further reading
  4. Combinational Logic
    1. Technical requirements
    2. Creating FPGA designs
      1. How to create reusable code – parameters and generics
    3. Understanding the basics of HDL design
      1. Introducing data types
      2. Creating arrays
        1. Querying arrays
        2. Assigning to arrays
      3. Handling multiple-driven nets
      4. Handling signed and unsigned numbers
      5. Adding bits to a signal by concatenating
      6. Casting signed and unsigned numbers
      7. Creating user-defined types
      8. Accessing signals using values with enumerated types
      9. Packaging up code using functions
      10. Creating combinational logic
        1. Handling assignment operators
        2. Incrementing signals
        3. Making decisions – if-then-else
        4. Introducing the case statement (SystemVerilog)
        5. Using the conditional operator to select data
        6. Introducing the case statement (VHDL)
      11. Using custom data types
        1. Creating structures
        2. Creating unions (SystemVerilog)
    4. Project 2 – Creating combinational logic
      1. Testbench
        1. Simulating using targeted testing
        2. Simulating using randomized testing
        3. Simulating using constrained randomization
      2. Implementing an LOD using the case statement (SystemVerilog)
        1. Controlling implementation using generate
      3. Designing a reusable LOD using a for loop
        1. Setting SELECTOR = DOWN_FOR
        2. Setting SELECTOR = UP_FOR
      4. Counting the number of ones
      5. Implementing an adder/subtractor
        1. Adder
        2. Subtractor
      6. Implementing a Multiplier
      7. Bringing it all together
        1. Adding a latch
    5. Summary
    6. Questions
    7. Answers
    8. Challenge
    9. Further reading
  5. Counting Button Presses
    1. Technical requirements
    2. What is a sequential element?
      1. Clocking your design
      2. Looking at a basic register
        1. Creating a Flip-Flops using SystemVerilog
        2. Creating a flip-flop using VHDL
        3. When to use always @() for FF generation
        4. Using non-blocking assignments
      3. Registers in the Artix 7
        1. How to retain state using clock enables
        2. Resetting the FF
    3. Project 3 – Counting Button Presses
      1. Introducing the seven-segment display
      2. Detecting button presses
        1. Analyzing timing
        2. Looking at asynchronous issues
        3. Using the asynchronous signal directly
        4. Problem with push buttons
        5. Designing a safe implementation
        6. Switching to decimal representation
        7. Introducing the ILA
      3. What about simulation?
    4. Deep dive into synchronization
      1. Why use multiple clocks?
      2. Two-stage synchronizer
      3. Synchronizing control signals
      4. Passing data
    5. Summary
    6. Questions
    7. Answers
    8. Challenge
    9. Further reading
  6. Let’s Build a Calculator
    1. Technical requirements
    2. What is a state machine?
      1. Writing a purely sequential state machine
      2. Splitting combination and sequential logic in a state machine
      3. Designing a calculator interface
      4. Designing a Moore state machine
      5. Implementing a Mealy state machine
      6. Practical state machine design
    3. Project 4 – Building a Simple Calculator
      1. Packaging for reuse
      2. Coding the top level
        1. Changing frequencies by using a PLL or MMCM
      3. Investigating the divider
        1. Building a non-restoring divider state machine
        2. Simulating the divider
        3. Sizing the intermediate remainder
    4. Project 5 – Keeping cars in line
      1. Creating the state diagram
      2. Displaying our traffic lights
        1. Pulse width modulation
        2. Implementing delays with a counter
    5. Summary
    6. Questions
    7. Answers
    8. Challenge
      1. Extra challenge
    9. Further reading
  7. FPGA Resources and How to Use Them
    1. Technical requirements
    2. What is a digital microphone?
      1. What is PDM?
    3. Project 6 – Listening and learning
      1. Simulating the microphone
      2. Introducing storage
        1. Inferring, instantiating, or using the IP catalog to generate RAM
        2. Basic RAM types
        3. Using xpm_cdc for clock domain crossing
        4. Instantiating memories using xpm_memory
        5. Vivado language templates
        6. Using the IP catalog to create memory
      3. Capturing audio data
    4. Project 7 – Using the temperature sensor
      1. Processing and displaying the data
      2. Smoothing out the data (oversampling)
        1. A deeper dive into FIFOs
        2. Constraints
        3. Generating our FIFO
    5. Summary
    6. Questions
    7. Answers
    8. Further reading
  8. Math, Parallelism, and Pipelined Design
    1. Technical requirements
    2. Introduction to fixed-point numbers
    3. Project 8 – Using fixed-point arithmetic in our temperature sensor
      1. Using fixed-point arithmetic to clean up the bring-up time
      2. Temperature conversion using fixed-point arithmetic
      3. What about floating-point numbers?
        1. Floating-point addition and subtraction
        2. Floating-point multiplication
        3. Floating-point reciprocal
        4. A more practical floating-point operation library
      4. A quick look at the AXI streaming interface
    4. Project 9 – Updating the temperature sensor project to a pipelined floating-point implementation
      1. Fixed-to-floating-point conversion
      2. Floating-point math operations
      3. Float-to-fixed-point conversion
      4. Simulation
        1. Simulation environment
    5. Parallel designs
      1. ML and AI and massive parallelism
      2. Parallel design – a quick example
    6. Summary
    7. Questions
    8. Answers
    9. Challenge
    10. Further reading
  9. Introduction to AXI
    1. Technical requirements
    2. AXI streaming interfaces
    3. Project 10 – Creating IP for Vivado using AXI streaming interfaces
      1. Seven-segment display streaming interface
      2. Developing the adt7420 IP
      3. Understanding the flt_temp core
      4. Introduction to the IP Integrator
        1. IP Integrator debugging
      5. Packaging the project
    4. AXI4 interfaces (full and AXI-Lite)
    5. Developing IPs – AXI-Lite, full, and streaming
      1. Adding an unpackaged IP to the IP Integrator
    6. Summary
    7. Questions
    8. Answers
    9. Completed designs
    10. Further reading
  10. Lots of Data? MIG and DDR2
    1. Technical requirements
    2. Note on VHDL
    3. Project 11 – Introducing external memory
      1. Introduction to DDR2
      2. Generating a DDR2 controller using the Xilinx MIG
        1. Setting AXI parameters
        2. Setting memory options
        3. Defining the FPGA options
      3. Modifying the design for use on the board
    4. Introducing a few other external memory types
      1. QDR SRAM
      2. HyperRAM
      3. SPI RAM
    5. Summary
    6. Questions
    7. Answers
    8. Challenge
    9. Further reading
  11. A Better Way to Display – VGA
    1. Technical requirements
    2. Project 12 – Introducing the VGA
      1. Defining registers
        1. Coding a simple AXI-Lite interface
      2. Generating timing for the VGA
        1. The VGA monitor timing generator
      3. Displaying text
        1. Requesting memory
      4. Testing the VGA controller
      5. Examining the constraints
    3. Summary
    4. Questions
    5. Answer
    6. Challenge
    7. Further reading
  12. Bringing It All Together
    1. Technical requirements
    2. Investigating the keyboard interface
    3. Project 13 – Handling the keyboard
      1. Testing the PS/2
    4. Project 14 – Bringing it all together
      1. Displaying PS/2 keycodes on the VGA screen
      2. Displaying the temperature sensor data
        1. Adding a custom character to the text ROM
      3. Displaying audio data
    5. Summary
    6. Questions
    7. Answers
    8. Challenge
    9. Further reading
  13. Using the PMOD Connectors – SPI and UART
    1. Technical requirements
      1. UART PMOD
      2. ACL2 PMOD
    2. Understanding Peripheral Modules (PMODs)
      1. PMOD Type 1 and 1A
      2. PMOD Type 2 and 2A
      3. PMOD Type 3 and 3A
      4. PMOD Type 4, 5, and 5A
      5. PMOD Type 6 and 6A
      6. PMOD Type 7 and 7A
    3. Introduction to Universal Asynchronous Receiver-Transmitter (UART)
      1. Bus interface
      2. Waveform
      3. Register interface
        1. RBR – Receive Buffer Register
        2. THR – Transmit Holding Register
        3. IER – Interrupt Enable Register
        4. ISR – Interrupt Status Register
        5. FCR – FIFO Control Register
        6. LCR – Line Control Register
        7. MCR – Modem Control Register
        8. LSR – Line Status Register
        9. MSR – Modem Status Register
        10. SCRATCH – Scratch Pad Register
        11. DLL, DLM – Divisor Register LSB and MSB
      4. UART Implementation
        1. CPU Interface
        2. UART Core
      5. My UART origins
      6. Testing
        1. Simulation
        2. On-board testing
    4. Understanding Serial Peripheral Interface (SPI)
      1. ACL2 PMOD
      2. Generic SPI
        1. SPI physical interface
        2. SPI protocol interface
      3. Constructing the SPI
        1. SPI state machine
    5. Summary
    6. Questions
    7. Answers
    8. Further reading
  14. Embedded Microcontrollers Using the Xilinx MicroBlaze
    1. Technical requirements
    2. Understanding Embedded Microcontrollers
      1. Soft vs hard processors
      2. Creating the MicroBlaze project
        1. Block Design
        2. MicroBlaze Peripherals
        3. Exporting the design
      3. The Software Project
        1. GPIOs
        2. Our Software Application
    3. Summary
    4. Questions
    5. Answers
    6. Challenge
  15. Advanced Topics
    1. Technical requirements
    2. Exploring more advanced SystemVerilog constructs
      1. Interfacing components using the interface construct
      2. Using structures
      3. Block labels
      4. Looping using for loops
      5. Looping using do…while
      6. Exiting a loop using disable
      7. Skipping code using continue
      8. Using constants
      9. Packing operators
        1. Indexed part select, +:, -:
        2. Streaming operators
    3. Exploring some more advanced verification constructs
      1. Introducing SystemVerilog queues
      2. Display formatting enhancements
      3. A quick introduction to assertions
      4. Using $error or $fatal in synthesis
    4. Other gotchas and how to avoid them
      1. Inferring single-bit wires
      2. Bit-width mismatches
      3. Upgrading or downgrading Vivado messages
      4. Handling timing closure
        1. How to pipeline a design
    5. Summary
    6. Questions
    7. Answers
    8. Further reading
  16. Other Books You May Enjoy
  17. Index

Product information

  • Title: The FPGA Programming Handbook - Second Edition
  • Author(s): Frank Bruno, Guy Eschemann
  • Release date: April 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781805125594