A collection of various tips and tricks when using FPGA tools, namely Intel Quartus Prime Suite and ModelSim/Questa.
- Keep projects separate. Don't include RTL for two unique designs in the same Quartus/ModelSim project.
- Always practice good naming conventions for projects/files/signals/everything! You'll thank yourself down the road for getting into this habit.
- Here's a good naming conventions cheatsheet to help you.
- Always use multi-process state machines. It's just better when debugging.
- When writing Finite State Machines (FSMs), use an
ERROR
state. In your logic to choose next states, do something like the following:
case state is
-- ...
when others => next_state <= ERROR;
end case;
- This may help to ensure that all states are well-defined in the FSM. If states are missing, the simulation may end up in the ERROR state.
- Set unused pins as "Input Tri-stated" to avoid strange behavior/potentially damaging your device.
- You typically don't have to resynthesize all the time. Quartus saves the most recent synthesis outputs as files.
- For example, you don't need to resynthesize to program your board. Just locate the
.sof
or.pof
file that Quartus saved for you. That's the most recent synthesis. - Don't include testbenches in your Quartus project. Unless you're using Quartus to run simulations, testbenches do not belong in your Quartus project.
- For example, you don't need to resynthesize to program your board. Just locate the
You can save the configuration of your pin planner for future use via "File > Export...":
This will save your pin configuration as a .csv
file.
To import it later, in Quartus (NOT in the pin planner), choose "Assignments > Import Assignments":
- If your compile fails the first time, compile a second time.
- This is due to ModelSim not understanding the dependency order of your files, since it doesn't do any introspection about the layout of your RTL like other compilers do these days.
- Alternatively, you can use the
Compile Order > Autogenerate
which should compile your files on the first try!
- You can recompile and restart a simulation without leaving the current simulation.
The toolbar at the top is very overcrowded, but has some useful buttons that I find useful:
These buttons, from left-to-right, are:
- Compile selected file
- Compile Out of Date
- Compile All
- Simulate: Starts a new simulation
- Break: Pauses simulation (not used often)
These are enabled when running a simulation.
These buttons, from left-to-right, are:
- Restart: Resets simulation to the beginning
- Run: Runs the sim for n time, which is selected in the input box. (In this example, Run would run the simulation for 100ps)
- ContinueRun: Not used often, helpful for debugging
- Run -all: Runs simulation to completion
- Break: Pauses simulation
- Stop: Stops simulation early
- Add a cursor
- Remove the selected cursor (see selected cursor at the bottom of the Wave view pane)
When a signal in wave view is selected:
- Find previous/next transition
- Find previous/next falling/rising edge
- Zoom in (
I
key) - Zoom out (
O
key) - Zoom full (
F
key): Shows out until beginning and end can both be seen in the window - Zoom in on active cursor (
C
key): Centers cursor and zooms in on it. - Zoom between cursors: Zooms on a section between two cursors.
-
Zoom in and out with the
I
andO
keys. -
Change the radix of a signal by right-clicking on the signal in the Wave view and selecting "Radix":
-
Change the color of signals by selecting them in the Wave view pane, right-clicking, and selecting "Properties...":
-
Add a divider to group your signals for better readability.
Putting all these together, you can see that the Wave view becomes much more readable:
-
Once you get a configuration you like, save the format of the wave view via "File > Save Format...":
-
Group signals together so you can view their overall value, as well as collapse/hide them.
- Select signals to group, then Right-click and choose "Group".
During a simulation, a quick way to add all signals to the Wave view is by focusing the Objects pane (shown above), and using Ctrl+A
to select all signals, followed by Ctrl+W
to add them to the Wave view.
Timing simulations tend to cause confusion. Here's my approach:
- Keep Quartus/ModelSim projects separate. (See above bullet point for more info)
- Rename your
.sdc
file to something descriptive.- Having a unique project for each output may be sufficient for this.
- You only need to recreate (via re-synthesizing) this file if your design has changed.
- Group your
.vho
and.sdc
files together to make it easier to locate and add them into their respective ModelSim project.
Bookmarks can be used to save a location in a wave, and goto that location later on. I personally haven't used these much but they seem helpful.