FPGA Programming and Hardware Essentials
Kick off with the MAX1000 and VHDPlus
By Dogan Ibrahim
Published by Elektor International Media B.V.
Preface
This book serves as a guide to understanding and implementing FPGA programming, with a practical focus on the MAX1000 development board and the VHDPlus development environment.
Chapter 1: Introduction
1.1 What is a Field Programmable Gate Array (FPGA)?
A Field Programmable Gate Array (FPGA) is an integrated circuit that can be configured by the user after manufacturing. It contains an array of programmable logic blocks and reconfigurable interconnects, allowing for flexible hardware design.
1.2 Some popular FPGA development boards
The landscape of FPGA development boards is diverse, offering various features and capabilities for learning and prototyping. This guide specifically utilizes the MAX1000 board.
Chapter 2: The MAX1000 FPGA Hardware
This chapter provides a detailed examination of the MAX1000 FPGA development board's hardware components and architecture.
2.1 Overview
A general overview of the MAX1000 board's features and purpose.
2.2 The MAX1000 Hardware
Detailed description of the MAX1000 hardware.
2.2.1 Board Indicator LEDs
Information regarding the LEDs present on the board for status indication.
2.2.2 Block Diagram
A visual representation of the MAX1000 board's internal architecture.
2.2.3 Clock Circuitry
Explanation of the clock generation and distribution mechanisms.
2.2.4 User LEDs
Details on the user-programmable LEDs for output visualization.
2.2.5 Push Buttons
Description of the integrated push button inputs.
2.2.6 Accelerometer
Information on the onboard accelerometer for motion detection.
2.2.7 Arduino Connectors
Details on the board's compatibility and connection options via Arduino headers.
2.2.8 Pmod Connector
Explanation of the Pmod interface for connecting expansion modules.
2.2.9 UART Communication
Description of the Universal Asynchronous Receiver-Transmitter (UART) for serial communication.
2.2.10 Power supply circuitry
Details on the power management and supply circuits of the board.
Chapter 3: Software Installation – VHDPlus IDE
This chapter guides users through the installation and setup process for the VHDPlus Integrated Development Environment (IDE).
3.1 Overview
An introduction to the VHDPlus IDE and its role in FPGA development.
3.2 Installing the VHDPlus IDE
Step-by-step instructions for installing the VHDPlus IDE on your system.
3.3 Your first program
A practical walkthrough of creating and running a simple initial program.
3.3.1 Downloading the compiled code to your FPGA
Instructions on how to transfer the compiled code from the IDE to the MAX1000 FPGA.
3.3.2 Installing packages and library files to VHDPlus
Guidance on managing project dependencies, including installing necessary packages and library files.
3.3.3 Simulating the program
How to utilize the IDE's simulation tools to test and verify program logic before hardware deployment.
Chapter 4: The VHDPlus Language
This section delves into the VHDPlus programming language, covering its syntax, data types, operators, and control flow statements.
4.1 Overview
An introduction to the VHDPlus language and its features.
4.2 Data types and operators
4.2.1 Data types
Description of the fundamental data types available in VHDPlus, such as integers and booleans.
4.2.2 Operators
Explanation of the various operators used for performing operations in VHDPlus.
4.3 Binary logical operators
4.3.1 Relational operators
Operators used for comparing values (e.g., ==, !=, <, >).
4.3.2 Arithmetic operators
Operators for mathematical calculations (e.g., +, -, *, /).
4.3.3 Concatenation operator
The operator used for joining signals or values together.
4.3.4 Shift operators
Operators for performing bitwise left and right shifts.
4.3.5 Type conversion
Methods and syntax for converting data from one type to another.
4.4 Declarations, assignments, and constants
4.4.1 Declarations
How to declare variables, signals, and other entities within VHDPlus.
4.4.2 Assignments
Rules and syntax for assigning values to declared entities.
4.4.3 Constants
Defining and utilizing constants in VHDPlus code for improved readability and maintainability.
4.5 VHDPlus program flow statements
4.5.1 If..Else..Elsif
Conditional execution structures based on boolean expressions.
4.5.2 Case and When
Multi-way branching statements for selecting code paths based on a value.
4.5.3 For
A loop construct for executing a block of code a predetermined number of times.
4.5.4 While
A loop construct that continues execution as long as a specified condition remains true.
4.5.5 Wait
Statements used to introduce delays or synchronize with specific events.
4.5.6 Step
Description of the 'Step' statement within the VHDPlus language.
4.6 VHDPlus program template
4.6.1 Main
The structure of the main program entry point.
4.6.2 Process
Explanation of process blocks for concurrent or sequential code execution.
4.6.3 Thread
Description of how threads are implemented and used in VHDPlus.
4.6.4 Function
Defining and using reusable functions within VHDPlus programs.
Chapter 5: Example VHDPlus Projects
This chapter presents a series of practical projects designed to help users apply their VHDPlus programming skills and understand FPGA capabilities.
5.1 Overview
An introduction to the collection of example projects.
5.2 Project 1 – Flashing LED
A fundamental project demonstrating basic LED control.
5.3 Project 2 – Two alternately flashing LEDs
A project involving synchronized flashing of multiple LEDs.
5.4 Project 3 – Using an external LED
Instructions for connecting and controlling an external LED.
5.5 Project 4 – Chasing LEDs
Creating a sequential lighting effect with a series of LEDs.
5.6 Project 5 – Binary counter with LEDs
Implementing a binary counter whose output is displayed on LEDs.
5.7 Project 6 - LED with button control
Controlling an LED's state based on a push button input.
5.8 Project 7 - LED with External Button Control
Utilizing an external button to control an LED.
5.9 Project 8 – Event counter
A project designed to count external events.
5.10 Project 9 – Full adder
Implementation of a digital full adder circuit.
5.11 Project 10 – Multiplexer
Building a multiplexer circuit using VHDPlus.
5.12 Project 11 – BCD to seven-segment display decoder
Project to decode Binary-Coded Decimal (BCD) values for seven-segment displays.
5.12.1 Connecting a 7-segment display to the FPGA
Instructions for wiring a seven-segment display to the FPGA.
5.13 Project 12 – BCD to seven-segment display decoder counter with Arduino Uno R4
A project combining BCD decoding with an Arduino Uno R4.
5.14 Project 13 – 4-bit counter
Implementation of a 4-bit digital counter.
5.15 Project 14 – 8-bit serial-in parallel-out shift register
Building an 8-bit shift register.
5.16 Project 15 – Edge triggered D-type flip-flop
Implementation of an edge-triggered D-type flip-flop.
5.17 Project 16 – Demultiplexer
Building a demultiplexer circuit.
5.18 Project 17 – Multiplexed 4-digit 7-segment LED
Project involving a multiplexed 4-digit seven-segment display.
5.19 Project 18 – Multiplexed 4-digit 7-segment LED event counter
An event counter using a multiplexed 4-digit seven-segment display.
5.20 Project 19 – Multiplexed 4-digit 7-segment LED seconds counter
A seconds counter using a multiplexed 4-digit seven-segment display.
5.21 Project 20 – Switch contact debouncing
Implementing switch debouncing logic.
Chapter 6: Analog-to-Digital Converter (ADC)
6.1 Overview
Introduction to Analog-to-Digital Converters (ADCs) and their application.
6.2 MAX1000 analog inputs
Details on the analog input capabilities of the MAX1000 board.
6.3 Project 1 – Voltmeter
A project to build a voltmeter using the ADC.
6.3.1 Extending the input range
Methods for extending the measurement range of the voltmeter.
6.4 Project 2 – Temperature sensor
Using the ADC to read temperature sensor data.
6.5 Project 3 – Light dependent resistor (LDR)
Interfacing with a Light Dependent Resistor (LDR) using the ADC.
Chapter 7: Serial Communication
7.1 Overview
Introduction to serial communication protocols.
7.2 MAX1000 FPGA serial port
Information on the serial port capabilities of the MAX1000 FPGA.
7.3 Project 1 – Controlling the on-board LEDs with serial communication
A project to control LEDs via serial communication.
Chapter 8: Pulse Width Modulation (PWM)
8.1 Overview
Introduction to Pulse Width Modulation (PWM).
8.2 Basic theory of the pulse width modulation
Explanation of the fundamental principles of PWM.
8.3 Project 1 – PWM waveform with a fixed-duty cycle
Generating a PWM signal with a constant duty cycle.
8.4 Project 2 – Mosquito repeller
A project demonstrating a mosquito repeller circuit using PWM.
8.5 Project 3 – Variable duty cycle – Dimming an LED
Controlling LED brightness by varying the PWM duty cycle.
Chapter 9: Ultrasonic Sensor
9.1 Overview
Introduction to ultrasonic sensors and their applications.
9.2 Project 1 – Ultrasonic distance measurement
A project to measure distance using an ultrasonic sensor.
Chapter 10: The I2C Bus
10.1 Overview
Introduction to the Inter-Integrated Circuit (I2C) bus protocol.
10.2 The I2C bus
Detailed explanation of the I2C bus.
10.3 The I3C bus
Information on the I3C bus, a successor to I2C.
10.4 Differences between the I2C and I3C
A comparison highlighting the distinctions between I2C and I3C.
10.5 Project 1 – Port expander using the I2C bus on MAX1000 FPGA
Implementing a port expander using the I2C bus with the MAX1000 FPGA.
Chapter 11: The SPI Bus
11.1 Overview
Introduction to the Serial Peripheral Interface (SPI) bus.
11.2 Project 1 – SPI Port expander
Implementing a port expander using the SPI bus.
Chapter 12: Using LCD
12.1 Overview
Introduction to using Liquid Crystal Displays (LCDs).
12.2 HD44780 LCD module
Details on the HD44780 LCD controller module.
12.3 Project 1 – Displaying text on LCD
A project to display text on an LCD screen.
Chapter 13: Programming in VHDL
13.1 Overview
Introduction to programming FPGAs using VHDL (VHSIC Hardware Description Language).
13.2 Project 1 – Flashing LED
Implementing an LED flashing program in VHDL.
13.3 Project 2 – Button and LED
A project to control an LED with a button input using VHDL.
13.4 VHDPlus to VHDL conversion
Information on converting VHDPlus code to VHDL.
Chapter 14: MAX1000 FPGA Python Programming
14.1 Overview
Introduction to programming the MAX1000 FPGA using Python.
14.2 Python programming
Details on Python programming for the MAX1000 FPGA.
Chapter 15: NIOS II
15.1 Overview
Introduction to the NIOS II embedded processor.
15.2 Creating a NIOS II processor
Steps for creating and configuring a NIOS II processor.
15.3 Project 1 – Displaying a message using the NIOS II processor as Arduino
A project demonstrating message display using NIOS II, emulating Arduino functionality.
15.4 Project 2 – Alternately flashing two LEDs
Controlling two LEDs to flash alternately using NIOS II.
Chapter 16: Accelerometer Project
16.1 Overview
Introduction to accelerometer projects.
16.2 The project
Details of the accelerometer project.
16.2.1 Testing the program
Instructions for testing the accelerometer project program.
Chapter 17: Other Projects Provided With the VHDPlus IDE
This chapter lists additional projects available with the VHDPlus IDE.
Chapter 18: Quartus Prime Lite Schematic Design
18.1 Overview
Introduction to schematic design using Quartus Prime Lite.
18.2 Project 1 – D-type flip-flop with LED output
Implementing a D-type flip-flop with LED output in Quartus Prime Lite.
18.3 Project 2 – Electronic lock
Designing an electronic lock schematic.
18.3.1 The truth table
The truth table associated with the electronic lock project.
Appendix
Bibliography
List of references and further reading materials.
Index
An index of terms and topics covered in the book.
Code Snippet Example
An example code snippet from the document:
{
elsif(digits(3) = '1') then
Segment <= N(m/10 mod 10);
elsif(digits(2) = '1') then
Segment <= N(m/100 mod 10);
elsif(digits(1) = '1') then
Segment <= N(m/1000 mod 10);
end if;
}
if(rising_edge(CLK)) then
i <= if(i + 3610000) > 9999999 then 0 else i + 3610000;
if (i = 0) then
digits(3) <= '1';
else
digits(3) <= '0';
end if;
digits(2 downto 0) <= to_unsigned(i / 1000000, 3);
end if;