Skip to content

Instantly share code, notes, and snippets.

@benjamin051000
Last active July 8, 2024 03:05
Show Gist options
  • Save benjamin051000/ba754bf007011943dfe36d5b79a15cd6 to your computer and use it in GitHub Desktop.
Save benjamin051000/ba754bf007011943dfe36d5b79a15cd6 to your computer and use it in GitHub Desktop.
FPGA pro tips

FPGA Pro Tips

A collection of various tips and tricks when using FPGA tools, namely Intel Quartus Prime Suite and ModelSim/Questa.

Table of Contents


General Tips

  • 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.

HDL Tips

  • 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.

Synthesis with Quartus

  • 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.

Pin Planner

You can save the configuration of your pin planner for future use via "File > Export...": image 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": image

Simulation with ModelSim

Compiling

  • 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.

Toolbar

The toolbar at the top is very overcrowded, but has some useful buttons that I find useful:

Compilation Tools

image

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)

Simulation Tools

These are enabled when running a simulation.

Manage simulation

image

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

Cursor/Jump tools

image

  • 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

Wave view Zoom

image

  • 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.

Simulation Tips

  • Zoom in and out with the I and O keys.

  • Change the radix of a signal by right-clicking on the signal in the Wave view and selecting "Radix": image

  • Change the color of signals by selecting them in the Wave view pane, right-clicking, and selecting "Properties...":

    • Click "Color Settings > Wave Color > Colors..." to adjust the color: image
  • Add a divider to group your signals for better readability.

    • Right click in empty (grey) space in the Wave view pane, and select "Add > New Divider": image

Putting all these together, you can see that the Wave view becomes much more readable: image

  • Once you get a configuration you like, save the format of the wave view via "File > Save Format...": image

    • When you reopen the simulation later, you can import the configuration via "Load > Macro File...": image
  • 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".

Keyboard Shortcuts

Add signals to Wave view quickly

image

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

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.

Misc.

Bookmarks

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment