Getting Started: Quartus Prime & OpenOCD
From spiderboard.org
Contents
Prerequisites
- Quartus Prime
- A SpiderSoM or MX10 with SpiderBase
- One of the following:
- OpenOCD (Linux only)
- USB Blaster and Quartus Programmer
Quartus Prime Project
- Create a new Quartus Prime Project. Name the project Example, this will set our top level entity for later.
- In Family, Device & Board Settings, select Family "MAX 10" and then search for your FPGA.
- Go to Assignments -> Device -> Device and Pin Options -> Voltage and select 3.3-V LVCMOS as Default I/O Standard.
- If you plan to use OpenOCD, you can enable automatically creating a .svf file. Under Device and Pin Options -> Programming Files select Serial Vector Format File (.svf).
- Open the new file dialog and create a VHDL file.
- Copy and paste the code below.
- Save the VHDL file. This file contains our top level entity Example, which matches our project configuration.
- Run Analysis & Elaboration, this will create nodes for pin assignment.
- Open Pin Planner and edit the location for the existing signals:
Node Name SpiderSoM MX 10 button[1] PIN_A5 PIN_T13 button[0] PIN_B7 PIN_T7 led[1] PIN_L2 PIN_T6 led[0] PIN_L1 PIN_T12 clk25 PIN_H4 PIN_F9 For a complete pin assignment table see here.
- Run Compilation
- The subfolder output_files now contains an Example.sof file, an Example.pof file and if enabled the respective .svf files.
.sof (.svf) directly configures the FPGA. This configuration will be lost when the FPGA powers down.
.pof (_pof.svf) writes to flash memory. When the FPGA powers up, it will load the configuration stored in the flash memory. - After programming the FPGA via OpenOCD or USB Blaster the yellow LED on the base should start blinking and the green LED lights up if exactly one user button is pressed.
VHDL Code:
library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity Example is port ( clk25 : in std_logic; button : in std_logic_vector(1 downto 0); led : out std_logic_vector(1 downto 0) ); end entity Example; architecture archExample of Example is signal counter : integer range 1 to 12500000 := 1; signal led_yellow : std_logic := '0'; begin process (clk25) begin if (clk25 = '1' and clk25'EVENT) then if (counter < 12500000) then counter <= counter + 1; else led_yellow <= not led_yellow; counter <= 1; end if; end if; end process; led(1) <= led_yellow; led(0) <= button(0) xor button(1); end architecture archExample;
Programming via OpenOCD
- If not done already install and configure OpenOCD.
- Open a terminal and run the command
- $ mx10spider_prog <path/to/file.svf>
- If your project for example is under /opt/quartus_projects/Example run either:
- $ mx10spider_prog /opt/quartus_projects/Example/output_files/Example.svf
- $ mx10spider_prog /opt/quartus_projects/Example/output_files/Example_pof.svf
- for programming the .sof or .pof file respectively.
Programming via USB Blaster
- Connect the USB Blaster to the JTAG Header on the SpiderBase.
- In Quartus Prime, open the Programmer (Tools -> Programmer).
- Choose whether you want to use the .sof or the .pof file.
- Click Hardware Setup... and select your USB Blaster, if there is none available you may need to start the jtag service.
- Press Start