Hello everyone! I started doing FPGA projects back in my second year of undergraduate, and it was really fun because it allowed me to create almost any digital circuits that I had in mind without having to fabricate a PCB.
In this tutorial, I will be walking through the steps necessary to start a FPGA project, create a digital circuit, and upload the digital circuit onto the FPGA.
Table Of Contents
Getting Started with a FPGA project
I started by making an account on the Intel website to get myself a Intel Quartus Prime Lite 16.1.
You can start a project by going to File > New project wizard. Leave all the settings on default. Select Empty Project for the Project Type. For the Family, Device & Board Settings, select the chip used in your FPGA. In my case, I was using the DE10 Nano which uses a Cyclone® V, thus I selected 5CSEBA6U23I7S.
Try looking into your FPGA’s manual or the FPGA product page for the chip’s model number. If you have good eyes or a decent magnifying glass, another option is to check the small letters printed onto the FPGA’s chip (you can ignore the last few characters printed onto the chip, like how mine says 5CSEBA6U23I7NDK but the NDK part can be ignored).
Leave all other settings on default and click Finish to end the project creation phase.
Creating a digital circuit
There are various ways to express a digital circuit, and these include the Verilog HDL and Block Diagrams. I will first talk about using the latter as this is more suited towards beginners who haven’t learned Verilog HDL yet.
As an example, I will create a digital circuit that lights up an LED on the FPGA by pressing KEY1 or KEY2, or both.
Using Block Diagrams
Go to File > New > Block Diagram/Schematic File, it will bring you to a block diagram creation window.
To use a logic gate, click this icon.
Then go libraries menu, select /intelFPGA/16.1/quartus/libraries/ > primitives > logic to find your required logic gate (or simply type the logic name into the search bar). Here, I will be using or2, then you can click to place the logic gates onto your desired location.
For the inputs and outputs, click this icon and place them onto the desired locations.
After placing the or and not gate, input and output, my block diagram looks like the following.
We will now wire the components together by clicking on this icon.
After wiring the components together, it will look like the following.
Now save the block diagram, make the name the same as the project name to make it a top level module.
The DE10 Nano’s input KEYS are low while pressed, and high while released. Thus for the signal to be high when pressed, the not gate was added.
Using Verilog HDL
I highly recommend learning Verilog HDL, as this allows for more complex digital circuits to be created. When I tried making adders in Block Diagrams, it was extremely tedious (while it only required a few lines in Verilog HDL!). One place to get started with Verilog HDL would be Altera’s Verilog HDL basics.
Go to File > New > Verilog HDL File. The digital circuit which was created previously can be written in Verilog HDL as shown in the following.
Save the Verilog File, make the name the same as the project name to make it a top level module.
Compiling and uploading onto the FPGA
After creating the digital circuit (Block Diagram or Verilog HDL), double click on Analysis & Synthesis.
Once that completes successfully, go to Assignments > Pin Planner. At this point, the inputs and outputs have not yet been assigned their pins, and the pin locations are empty as shown below.
For the pin locations, I looked up the DE10 Nano User Manual. The KEY inputs and LED output locations of the DE10 Nano were shown to be the following.
In the Location column of the Pin Planner, I typed in the Pin names, and should look like the following.
Once that’s done, close the Pin Planner. Now double click on the Compile Design.
If everything completes successfully, the Task window should look like this.
Power on your FPGA and connect it to your computer.
Go to Tools > Programmer and click on Hardware Setup. It should automatically detect the FPGA, and it would be the DE-SoC in my case as shown below.
(If your device is not detected, close the Programmer window, and type this into your command line and relaunch the Programmer.)
Now close the Hardware setup, and click on Auto Detect on the Programmer.
Double click on the FPGA device (5CSEBA6 in my case).
Then go to output_files and select the .sof file. Make sure the Program/Configure check box for the FPGA device is selected.
Press Start, and once the Progress bar reaches 100%, the FPGA should act as desired. In my case, pressing either KEY1 or KEY2 (or both) would light up the LED.
What’s next?
Before moving on, I highly recommend checking out the IoT System Design class on edX, as this is where I learned how to use the FPGA and it covers this topic in-depth.
Once you have familiarized yourself with Verilog HDL and Quartus Prime, you can move onto my next tutorial, which focuses on creating more complicated FPGA projects with external inputs and outputs.
Thank you for reading, and good luck with your FPGA projects!
Originally published at https://dev.to on August 14, 2021.