Quick Quartus: Verilog
← Back to E15 Lab page ←
Please
contact me if you find any errors or other problems (e.g., something is
unclearly stated) in this web page
This document presents a (very) quick introduction to the use of Quartus to
design a system using verilog.
The Basics
Adding a clock
Adding a counter
Simulation
Some Useful References
- Start Quartus (it is in the "Altera" folder in the Windows Start menu).
- Select "Create a New Project (New Project Wizard)"
- Hit "Next >" to get past
"Introduction" page.
- On the next page ("Directory, Name, Top-Level Entity [page 1 of 5]") choose a working directory (preferably one you can
access from anywhere on campus) and choose a project name. Then hit
"Next >"
- Hit "Next >" (from "Add Files [page 2 of 5]").
- On the next page ("Family and Device Settings [page 3 of 5]"):
- choose Family: "Cyclone II"
- choose Available Devices: "EP2C35F672C6" (the
number on the large chip on the DE2 Altera board). Note, these are
not alphabetical, so you need to scroll through the choices.
- hit "Next >"
- Important - this is
different than what we did for schematic entry.
On the next page ("EDA Tool Settings
[page 4 of 5]"), under "Tool Type→Simulation" pick "ModelSim-Altera" for
the "Tool name". Then hit "Next >".
(Note: this is only necessary for projects that
you will be simulating; if you don't expect to simulate, you don't need to
do this. Also, if you only want to simulate, you can use ModelSim
alone without Quartus; you'll learn about this in class (the process is much
faster).).
- Hit "Finish" ("Summary [page 5 of
5]")
- From the Quartus main menu choose "File→New→Verilog
HDL File"
then "OK"
- Enter the text below into the file and save in a file "E15Lab2_Simple.v". Note that the file
name and module name should be the same as the top level entity (the name
you chose previously). As with "C," there are no rules about indenting
- but be neat and be consistent.
- Go to "Assignment→Import Assignments..." and choose the
E15DE2_IO.qsf
file. This should automatically assign the proper pins.
- Compile your code, then program the device. Verify that it works
as expected.
We can also add our own circuits to those supplied by Altera. In
particular, it will sometimes be useful to add a slow clock and a counter so that we can cylce
through multiple inputs. Let's start with the clock.
- Add the file "E15Clock1Hz.v" to your
working directory. You'll learn what's in the .v file
later. Essentially it takes the 50MHz clock on the DE2 board and
converts it to a 1Hz clock.
- Go to "Project→Add/Remove Files in Project..." and add
"E15Clock1Hz.v" to the project.
- Create a new verilog file called "E15Lab2_LessSimple.v" and enter
the following text. Save it in your working directory.
- Now make this new file the active one by going to the "Project
Navigator" pane, choosing the "Files" tab.
Then
right-click on "E15Lab2_LessSimple.v" and choose "Set
as top-level entity".
- Compile and download. Figure out what it should do, and verify
that it works as expected. Try to use KEY[0] to keep the middle LED on
the I/O board turned on. Fun, fun, fun...
- Now add the file "E15Counter.v" to
your working directory and include it in your project. This file counts up to a predetermined maximum
count (like the one you used in lab 1).
- Create a new file ("E15Lab2_EvenLessSimple.v") with the following code:
- Save the file and make it the top-level entity, compile it, and run it. Make
sure you understand what it is doing (you'll be using "E15Clock1Hz.v" and
"E15Counter.v" later in the lab).
-
Go to the "Project
Navigator" pane and set "E15Lab2_Simple.v" as the top level entity.
-
Compile it, and then go to "Tools→Run EDA
Simulation Tool→EDA RTL Simulation". A program called
"ModelSim" should start. (Note: we
are doing a functional simulation only, the actual timing of signals (e.g.,
gate delays...) is not considered)
- If you get an error "Can't launch the ModelSim-Altera software
-- the path..." you'll need to add the path to the simulator.
- Close the error window and go to "Tools→Options"
and choose "EDA Tool Options" under the "General"
category.
- Under ModelSim-Altera choose "
C:/altera/10.0/modelsim_ase/win32aloem"
- Hit "OK"
-
In the "Library" pane, expand the "work" library (at
bottom of window). Double click "E15Lab2_Simple" to load the design.
-
Either go to "View→Wave" or enter "View wave"
(without quotes) in the transcript window. This opens a waveform
viewer.
-
In the "Objects" pane select "KEY[0]" and "KEY[1]".
RIght click on the selection and choose "Add→To
wave→Selected signals".
-
In the "Transcript" pane enter "add wave LEDY_M"
-
Right click on the KEY[0] signal in the waveform viewer, select "Clock..." and
set it to a square wave with a period of 100 simulation units:

Notice that a command (something like "force -freeze
{sim:/E15Lab2_Simple/KEY[0]} 1 0, 0 {50 ps} -r 100") appears in the transcript
window. This is telling ModelSim that we want a repeating clock with a 50%
duty cycle. More commands are
here.
-
For "KEY[1]" use:

-
Now let simulate. Go to "Simulate→Run→Run 100". This tells the simulator
to run for 100 time steps. The "Wave" pane has the results of the
simulation:

-
Increase the length of the simulation by typing "run 200" in the "Transcript"
pane. The simulation now runs for 200 more cycles. You can
right-click on the "Wave" pane and select "Zoom Full" (or just press "F" on the
keyboard).

- It is also possible to run a simulation from a script. Create a file by
going to "File→New→Source→Do" and enter the following:
restart -force -nowave
delete wave *
add wave KEY(1:0)
add wave LEDY_M
force -freeze KEY(0) 0 0, 1 {10 ns} -r 20 ns
force -freeze KEY(1) 0 0, 1 {20 ns} -r 40 ns
run 200 ns
More ".do" commands are
here.
- Save as "myfirst.do"
*IMPORTANT* If you
make changes to the ".do" file, you must save them before they take effect.
- In the transcript window enter "do myfirst.do".
This will run all the commands in the ".do" file, resulting in the following
waveform.

*IMPORTANT* If you
make changes to the ".do" file, you must save them before they take effect.
← Back to E15 Lab page ←
Please
contact me if you find any errors or other problems (e.g., something is
unclearly stated) in this web page