Getting Started: Quartus Prime & OpenOCD

From spiderboard.org
Jump to: navigation, search

Prerequisites

Quartus Prime Project

  1. Create a new Quartus Prime Project. Name the project Example, this will set our top level entity for later.
  2. In Family, Device & Board Settings, select Family "MAX 10" and then search for your FPGA.
    • Project and Top-Level-Entity are being set.
    • In this example the 10M08SAU169C8G FPGA is installed on the module.
  3. Go to Assignments -> Device -> Device and Pin Options -> Voltage and select 3.3-V LVCMOS as Default I/O Standard.
  4. 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).
    • Quartus-assignment-device.png
    • Quartus-device-pin-options.png
    • Quartus-set-voltage.png
    • Quartus-enable-svf.png
  5. Open the new file dialog and create a VHDL file.
  6. Copy and paste the code below.
  7. Save the VHDL file. This file contains our top level entity Example, which matches our project configuration.
  8. Run Analysis & Elaboration, this will create nodes for pin assignment.
  9. 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_J12

    For a complete pin assignment table see here.

    • Analysis & Elaboration
    • Pin Planner
    • Quartus-pin-planner.png
  10. Run Compilation
    • Compilation
  11. 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.
  12. 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 arch 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 arch;

Programming via OpenOCD

  1. If not done already install and configure OpenOCD.
  2. Open a terminal and run the command
    $ mx10spider <path/to/file.svf>
  3. If your project for example is under /opt/quartus_projects/Example run either:
    $ mx10spider /opt/quartus_projects/Example/output_files/Example.svf
    $ mx10spider /opt/quartus_projects/Example/output_files/Example_pof.svf
    for programming the .sof or .pof file respectively.
  • Terminal after successfully running Example.svf

Programming via USB Blaster

  1. Connect the USB Blaster to the JTAG Header on the SpiderBase.
  2. In Quartus Prime, open the Programmer (Tools -> Programmer).
  3. Choose whether you want to use the .sof or the .pof file.
  4. Click Hardware Setup... and select your USB Blaster, if there is none available you may need to start the jtag service.
  5. Press Start
  • SpiderSoM and SpiderBase with USB-Blaster connected.
  • Programmer-hwsetup.png
  • Programmer-select-blaster.png
  • Programmer-start-success.png