Quartus VHDL Tutorial
Quartus VHDL Tutorial
Introduction
Quartus II is a powerful tool for entering, editing, simulating, and building digital circuits. In this tutorial, you will learn how to enter a VHDL design in Quartus II, edit it, compile it, and simulate it.
Getting started
Before starting Quartus II
Before starting your project, you should first create a folder (File | New | Folder from any Explorer Window) to store your circuit and simulation information in. There are different choices to make depending on whether you are using a school computer or your home computer. Home computer: You may make a folder wherever you like to store your data Use Windows to create this directory. Lab computer: Use your netstore drive (N:) Create a directory on this drive, such as N:\alterawork\tutorial1\. At this point, you now have a folder in which to keep work for this tutorial.
Starting up Quartus II
Start up Quartus II by clicking on the Quartus II link from the Start Menu. On lab machines, this is in Start | Engineering Sciences | Altera | Quartus II (ver) Web Edition. A getting started window will appear. Choose Create a New Project. Next, youll be asked to pick a project directory and name your project. 1. Select the directory you set up in the beginning (or make a new one now). Give your project a name, such as circuit2. The top-level entry should have the same name. Click Next. 2. Add files. You have no existing files, so just click Next. 3. Family and Device. Select the chip used in the Altera DE1 boards Cyclone II 2C20F484C7. Click Next. 4. EDA Tools Settings. Just click Next. 5. Summary. Look over the settings and click Finish. At this point, the main Quartus II environment should be open. You should see the project name you entered (circuit1) listed in the upper left under Entity.
Building a circuit
The next step is to describe a circuit using the Quartus II editor. For this tutorial, we will use a graphical (logic gate) drawing to describe our circuit.
Now enter the ARCHITECTURE, which should specify the logic function Z = AB + ABC + BC. Remember to refer to circuit2 in the of clause.
3. Make sure that the middle drop-down box reads Pins: all. Click List. The pins A,B,C, and Z should show up on the left side under Nodes Found. (see below) 4. Copy all the nodes to the Selected Nodes on the right size by using the > or >> buttons. 5. Click OK to both windows. The simulator will now show the four nodes you selected, as shown in the third diagram below.
Simulating
Now were ready to simulate! Follow these steps to simulate your circuit. 1. Start the simulation by selecting Processing|Start Simulation or clicking the appropriate tool button . 2. The circuit will be simulated. When it is done, a confirmation window will pop up. Click OK. The simulation results will pop up you can switch between your simulation setup and the report with results by clicking the appropriate tab near the top.
3. Examine the results (below). You can confirm the correct operation by reading the simulation results like a truth table the first 100ns correspond to inputs A=0, B=0, C=0 and output Z=0. 4. Notice that there is a slight delay (about 8ns) from the input change to the output change this is because the simulation is done with actual timing data for the chip.
We want to connect Input A to SW2, Input B to SW1, Input C to SW0, and Output Z to LEDR0. We need to note the pin numbers for each of these parts from the table above and map them using the Pin Assignments tool. 1. Select Assignments | Pins. This brings up a somewhat intimidating map of all the pins of the chip, with a table at the bottom for entering assignments. For now, ignore the fancy diagram on top. 2. The table at the bottom indicates pin assignments. Note that it has a row for A,B,C, and Z already, but there is nothing in the Location field yet. 3. Assign Input A to SW2 by selecting PIN_M22 as its location. You can just type in M22 and the software will figure out the rest for you. 4. Repeat the assignments for B, C, and Z, as shown below. Note that the pins correspond to the appropriate switches and LEDs as shown in the diagram above. 5. Close the Pin Assignments window and Recompile the project. Do not forget this step or all of your pin assignments will be ignored!
temporarily; if you turn off power to the board, the programming will be lost. Of course, you can always reprogram the chip. 1. Make sure that the DE1 board is connected to the computer using a USB cable. 2. Turn on the DE1 board by pressing the red switch. A demonstration light show will appear. 3. Select the programmer (Tools | Programmer) or . 4. Ensure that the hardware is set to the USB-Blaster (seen below). Use the Hardware Setup button to change this if needed. 5. Confirm that the file selected is the circuit you just compiled (circuit2.sof). 6. Press the Start button. You will see a blue LED light up briefly on the board as your file is downloaded. When it is complete, the light show program is replaced with your circuit.