Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

Nios® V Processor Installation and Hello World Execution, Part 1

symmt_Intel
Employee
1,535 Views

Note: This article is an English translation of this Japanese article. Please refer to the original article for updates.

Introduction

This article targets those who are new to FPGA, covering the overview, installation, hardware construction, and execution of Hello World for the Nios® V/m embedded processor. Those who already have experience with FPGA may skim through certain parts like the installation.

The Operating Systems used for operational verification are as follows:

  • Windows 11 Enterprise Version: 22H2, Build: 22621.2715
  • Ubuntu 22.04.3 LTS (Jammy Jellyfish), Kernel version: 6.2.0-36-generic

The work will primarily be conducted on Linux, and explanations will include actual logs. However, when commands differ significantly on Windows, they will be explained as necessary.

Below are reference materials for the Nios® V/m embedded processor:

1. Overview of the Nios® V/m Embedded Processor

1.1 Instruction Set

The Nios® V/m embedded processor supports the RV32IA instruction set. RV32I denotes a 32-bit integer instruction set, and the symbols following it indicate extensions. The main extensions are listed below.

Extension Description

MInteger Multiplication and Division
AAtomic Instructions
FSingle-Precision Floating-Point
DDouble-Precision Floating-Point
QQuad-Precision Floating-Point
CCompressed Instructions

Therefore, R32IA supports 32-bit integer instructions and atomic instructions. The processor has 32 32-bit wide integer registers, implemented using block memories like M20K. As indicated by the extension symbols, floating-point registers (f0-f31, fcsr) are not implemented. For more details, please refer to RISC-V Unprivileged Spec v.20191213.

1.2 Configuration

The basic configuration is shown below.

 

Item Details

General Purpose Register file32-bit width x 32 integer general-purpose register file
Arithmetic Logic Unit (ALU)Performs arithmetic, comparison, logical, and shift operations. Also used for generating addresses for loads and stores
Control and Status Registers (CSR)Control registers
Exception ControllerException processing controller
Interrupt ControllerInterrupt controller, level-triggered
Instruction BusInstruction bus
Data BusData bus
RISC-V based Debug ModuleDebug module

Here are the main differences from Nios® II:

Item Nios® V/m Embedded Processor Nios® II

BusArm* ABMA* AXIAvalon-MM
Number of Interrupt Terminals1632
DebugOpen OCD (On-Chip Debugger) compliantProprietary specification

1.3 Instruction, Data Bus

While Nios® II used the Avalon-MM bus, the Nios® V/m Processor has switched to Arm* ABMA* AXI. This change allows for exceptions to be triggered in the Nios® V/m Processor when the response from AXI is not OK. The types of AXI responses are as follows:

RESP[1:0] Response Description

2'b00OKAYNormal access OK
2'b01EXOKAYExclusive access OK
2'b10SLVERRSlave returned an error
2'b11DECERRNo slave at the specified address

For more details, please refer to Read and Write Response Structure.

1.4 Pipeline

The Nios® V/m embedded processor is a 5-stage pipeline CPU. An overview of each stage is provided below.

Stage Denotation Function

Instruction FetchF• PC+4 calculation<br>• Next instruction fetch<br>• Pre-decode for register file read
Instruction DecodeD• Decode the instruction<br>• Register file read data available<br>• Hazard resolution and data forwarding
Instruction ExecuteE• ALU operations<br>• Memory address calculation<br>• Branch resolution<br>• CSR read/write
MemoryM• Memory and multicycle operations<br>• Register file write<br>• Branch redirection
Write BackW• Facilitates data dependency resolution by providing General Purpose Register value.

1.5 Exceptions

The exceptions currently defined are as follows:

Exception Description

Instruction Address MisalignedException is issued when the Program Counter (PC) is not aligned on a 32-bit boundary during the instruction fetch stage (i.e., the lower 2 bits of the PC are not zero).
Instruction Access FaultException is issued if the AXI response during instruction read is not OKAY.
Illegal InstructionException is issued if an unimplemented or undefined instruction is detected during instruction decode, or if an unimplemented or undefined CSR access is detected during the execute stage.
BreakpointException is issued at the decode stage when a break instruction is executed.
Load Address Misaligned<br>Store/AMO Address MisalignedException is issued during the memory access stage if the load/store instruction's address is not aligned with the access size.
Load Access Fault<br>Store/AMO Access FaultException is issued if the AXI bus returns a response other than OKAY during memory access.
Environment Call from U-modeException is issued when ECALL instruction is executed in U-mode.
Environment Call from S-modeException is issued when ECALL instruction is executed in S-mode.
Environment Call from M-modeException is issued when ECALL instruction is executed in M-mode.
Instruction Page Fault<br>Load Page Fault<br>Store/AMO Page FaultException is issued when accessing a virtual address that does not correspond to a physical address, or when access rights are insufficient.

1.6 CSR Registers

The registers mapped in the CSR area are shown below. For more details on the registers, please refer to RISC-V Privileged Spec v.20190608.

Register Name Description

mvendoridMachine Vendor ID Register
marchidMachine Architecture ID Register
mimpidMachine Implementation ID Register
mhartidHart ID Register
mstatusMachine Status Register
mtvecMachine Trap-Vector Base-Address Register
mipMachine Interrupt-pending Register
mieMachine Interrupt-enable Register
mcounterenMachine Counter-enable Register
mepcMachine Exception Program Counter
mcauseMachine Cause Register

The registers mapped in the memory-mapped area are shown below.

Register Name Description Offset

mtimecmpMachine Time Register0x00
mtimeMachine Time Register0x08

1.7 Supported Devices

The FPGA devices currently supported are as follows:

Intel® Quartus® Prime Edition Device Family

ProIntel® Cyclone® 10 device
ProIntel® Arria® 10 device
ProIntel® Stratix® 10 device
ProIntel Agilex® 7 device
StandardIntel® MAX® 10
StandardIntel® Cyclone® IV E
StandardIntel® Cyclone® IV GX
StandardIntel® Cyclone® V
StandardIntel® Cyclone® 10 LP
StandardIntel® Arria® 10
StandardIntel® Arria® II GX
StandardIntel® Arria® II GZ
StandardIntel® Arria® V
StandardIntel® Arria® V GZ
StandardIntel® Stratix® IV
StandardIntel® Stratix® V

 

2. Obtaining a License

To use the Nios® V/m embedded processor, you need to acquire a free license. This section explains the procedure for obtaining a license. Additionally, we will also obtain a license for Questa*-Intel® FPGA Edition Software, used as a simulator.

2.1 Sign In

Click on the Self Service Licensing Center. A Sign In screen like the one below will appear, so please sign in with your Intel account.

40ae22bb-42c2-2f60-09c0-fdc1fd480cc5

If you do not have an Intel account, please create one.

2.2 Obtaining a Nios® V/m Embedded Processor License

After signing in, the following screen will appear.

9f72a32b-aed6-c4b7-37f2-45b3914163ba

Select Intel® FPGA IP IP-NIOSVM, enter "1" in "# of Seats", and click "Get License" at the bottom right.

2.3 Registering a New Computer

The following screen will appear.

e3116bdf-53dc-7087-9708-ffce273a6996

If you are obtaining a license for the first time, select "Create a New Computer". If you have already registered, select "Assign an Existing Computer" and click the "Generate" button at the bottom right. This time, we will register a new computer, creating an ID using the Ethernet MAC ID.

2.4 Entering New Computer Information

The following screen will appear, where you set up the computer you are using.

Enter the necessary items below and click "Generate License".

Item Description

Computer NameEnter any name
License TypeSelect FIXED
Computer NameSelect NIC ID
Primary Computer IDEnter the PC's Ethernet MAC ID

2.5 Checking the Nios® V/m Embedded Processor License File

Once generated, the following screen will appear, and the license file will be sent to the registered email address, so please check the file.

8ca68d3b-031d-785f-4844-55ac268dc22b

2.6 Obtaining a Questa*-Intel® FPGA Edition Software License

Follow the same procedure to obtain a license for Questa*-Intel® FPGA Edition Software. If you already have a license, proceed to the next chapter. As before, click on Self Service Licensing Center.

Select Questa*-Intel® FPGA Starter software Edition SW-QUESTA, enter "1" in "# of Seats", and click "Get License" at the bottom right.

2.7 Adding to an Existing Computer

If the following screen appears, specify the PC you registered earlier by selecting "Assign an Existing Computer", enter the MAC ID, and press the "Generate" button at the bottom right.

068a2bbb-62ce-8d18-45d5-c3075e4b3358

2.8 Checking the Questa*-Intel®

FPGA Edition Software License File

Once generated, the following screen will appear, and the license file will be sent to the registered email address.

059b4344-ce84-932f-4208-4dbd50f0df5c

With this, the process of obtaining the license is complete.

3. Installation

This chapter explains how to download and install Intel® Quartus® Prime Software, and how to set up environment variables.

3.1 Installing Intel® Quartus® Prime Pro Edition 23.3

3.1.1 Download

First, click on the FPGA Software Download Center and go to the page below. Follow the instructions for your OS to click on the corresponding version of Intel® Quartus® Prime Software. This explanation will cover installation on Linux.

317d0ab3-0340-1865-e5ec-97691b4c9565

Clicking will bring up the following page. Verify that the version is 23.3, then scroll down.

Download the Intel® Quartus® Prime Pro Edition Installer (RUN) from the page below. For Windows, download the Intel® Quartus® Prime Pro Edition Installer (EXE).

e7d856cb-1fa3-6ed3-8e65-4b3adc63f75f

Once downloaded, enter the following commands in the download directory to launch the installer:

 

$ chmod +x *.run
$ ./qinst-linux-23.3-104.run

 

For Windows, double-click the downloaded qint-windows-23.3-104.exe.

When the installer launches, select:

  • Intel® Quartus® Prime Pro Edition Part 1 (includes Nios II EDS)
  • Intel® Quartus® Prime Pro Edition Part 2
  • Questa*-Intel® FPGA and Starter Editions
  • Intel® Arria® 10 device support
  • Ashling RiscFree IDE for Intel® FPGAs Check "Agree to Intel License Agreement" and click Download. If you wish to change the download or installation location, do so on this screen.

4d65ccd3-9e40-195f-82f5-359315df0ba2

For Windows, ensure the following are checked under After-install actions:

  • Launch USB Blaster driver installation
  • Launch USB blaster II driver installation
  • Install JTAG Server as a Windows service

8235a2d5-ed7e-96d6-3746-5f9a1ab1ec94

During download & installation on Windows, the Device Driver Installation Wizard will open for Intel® FPGA Download Cable II (formerly USB Blaster II) and Intel® FPGA Download Cable (formerly USB Blaster), which are necessary for FPGA configuration and debugging the Nios® V/m embedded processor. Please install them. For Linux, follow "1.6. Installing the Intel FPGA Download Cable II Driver on Linux Systems" in the Intel® FPGA Download Cable II User Guide.

Install the Intel® FPGA Download Cable (formerly USB Blaster) driver. Click Next.

7ac9aaea-d4d7-71c6-f538-bff180e7a47b

Click Finish.

0d9de627-b4b4-1b04-a7a9-c22149e0ac90

Install the Intel® FPGA Download Cable II (formerly USB Blaster II) driver. Click Next.

40171aba-5327-042c-62d9-a0b126b819d2

Click Finish.

0d9de627-b4b4-1b04-a7a9-c22149e0ac90

This is the screen after completing the Quartus installation.

6f695455-0f18-df5d-3040-87c804cb29b4

With this, the installation of Intel® Quartus® Prime Pro Edition is complete.

3.2 Setting up Environment Variables

3.2.1 Linux

Execute the following to set paths to tools and specify the license file.

 

#!/bin/bash
export QUARTUS_ROOTDIR="$HOME/intelFPGA_pro/23.3/quartus"
export QSYS_ROOTDIR="$QUARTUS_ROOTDIR/../qsys/bin"
export SOPC_KIT_NIOS2="${QUARTUS_ROOTDIR}/../nios2eds"

# Tools
QUARTUS="$QUARTUS_ROOTDIR/bin64"
QSYS="$QSYS_ROOTDIR"
NIOSV="$QUARTUS_ROOTDIR/../niosv/bin"
NIOS2EDS="$QUARTUS_ROOTDIR/../nios2eds/bin"
MAKE="$QUARTUS_ROOTDIR/../riscfree/build_tools/bin"
CMAKE="$QUARTUS_ROOTDIR/../riscfree/build_tools/cmake/bin"
GCC="$QUARTUS_ROOTDIR/../riscfree/toolchain/riscv32-unknown-elf/bin"

if [ -d "$QUARTUS_ROOTDIR/../questa_fe" ]; then
    QSIM="$QUARTUS_ROOTDIR/../questa_fe/bin"
elif [ -d "$QUARTUS_ROOTDIR/../questa_fse" ]; then
    QSIM="$QUARTUS_ROOTDIR/../questa_fse/bin"
else
    echo "Questa not found"
fi

export PATH="$QUARTUS:$QSYS:$NIOSV:$NIOS2EDS:$MAKE:$CMAKE:$GCC:$QSIM:$PATH"

# License files
export LM_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat"
export MGLS_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat"

 

Regarding the license, $HOME/license/1-V4ICFB_License.dat is specified. If you have multiple license files, separate them with ":" in the following two lines:

 

export LM_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat"
export MGLS_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat"

 

For example:

 

# Example
export LM_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat:$HOME/license/XXX_License.dat"
export MGLS_LICENSE_FILE="$HOME/license/1-V4ICFB_License.dat:$HOME/license/XXX_License.dat"

 

3.2.2 Windows

For Windows, use the Nios V Command Shell, so setting the tool paths is not necessary. Only specify the license. Press the Windows key on your keyboard and type "env".

c05adcae-5cc6-9c66-d295-ede47be97d56

Then select "Edit the system environment variables". 

The following dialog opens, click on "Environment Variables".

a682076e-3812-8b4d-7cf3-bdc5717af580

In the User Environment Variables settings, as shown in the red frame, specify LM_LICENSE_FILE and MGLS_LICENSE_FILE to the license file. If there are multiple files, separate them with ";".

29f1acd8-ae10-4521-1cbd-5582944174e5

After restarting, the setup is complete.

4. Hardware Construction

4.1 Design Sample & Preparation

Here, we construct a design using the Nios® V/m embedded processor. Please download the Intel® Arria® 10 FPGA - Nios® V/m Processor based Hello World version 23.3 from the FPGA Design Store. The file name is top.par.

379f7a90-89ff-243f-05bd-a086e5aa73de

Once the download is complete, copy top.par to your work directory.

If your work directory is $HOME/ws, then execute:

 

 

 

 

cp $HOME/Downloads/top.par $HOME/ws

 

For Windows, if your work directory is C:\ws, then drag and drop to copy the file.

Next, set up the environment variables in Terminal for Linux or launch Nios V Command Shell (Quartus Prime Pro 23.3) from the Start menu in Windows.

Move to $HOME/ws and execute the following:

 

quartus top.par &

 

When Quartus launches, it will ask for the location to expand the Example Design. Specify your preferred work directory and click OK. From now on, we will proceed assuming the Example Design is expanded in $HOME/ws/top_project for Linux and C:/ws/top_project for Windows. All terminal commands should be executed from $HOME/ws/top_project or C:/ws/top_project.

53382c06-af08-d55e-81f7-e5803ffb4ff2

As you can see in $HOME/ws/top_project/hw/top.v, this design uses only one 50MHz clock input, making it easy to port to other FPGAs. For more details, see 4.5 Porting to Other FPGAs. For the reset, we use an IP that controls signals from JTAG called ISSP (In-System Source & Probe) and perform the reset with toggle_issp.tcl. For more details, see 5.1.6 CPU Reset by ISSP (In-System Source & Probe).

File Description

readme.txtREADME file
hw/top.qpfQuartus Project file
hw/top.qsfQuartus Settings file
hw/top.sdcSynopsys Design Constraints file
hw/top.vDesign TOP RTL file
scripts/create_qsys.tclPlatform Designer creation script
scripts/toggle_issp.tclReset execution script
sw/app_hal/hello.cMain file for HAL Hello World
sw/app_ucosii/hello_ucosii.cMain file for uC/OS-II Hello World
sw/app_freertos/hello_freertos.cMain file for FreeRTOS™ Hello World

As a premise, the Example Design just downloaded and expanded is in a ready-to-test state, meaning all files and binaries required for running the Nios® V/m embedded processor are already included. The FPGA configuration file is at $HOME/ws/top_project/ready_to_test/top.sof, and the ELF files for the Nios® V/m embedded processor application are at $HOME/ws/top_project/ready_to_test/app_hal.elf, $HOME/ws/top_project/ready_to_test/app_ucosii.elf, $HOME/ws/top_project/ready_to_test/app_freertos.elf. Use these for testing on actual hardware. The following will explain the steps for compiling the hardware design and building the application for the Nios® V/m embedded processor.

4.2 Checking the Platform Designer Design

Let's check the Platform Designer design in the GUI. There are two ways to launch Platform Designer: one is to launch it from the Intel® Quartus® Prime software, and the other is to launch it via command from the Terminal.

4.2.1 Launching Platform Designer from Intel® Quartus® Prime Software

  • Execute the following in the Terminal to launch Quartus:

 

quartus &

 

For Windows, you can also launch Quartus from the Start menu by selecting Quartus Prime Pro Edition 23.3.0.104 -> Quartus (Quartus Prime Pro 23.3).

292ed1be-0c93-8990-463b-d12923aa0317

  • From the File menu, select "Open Project..." and specify $HOME/ws/top_project/hw/top.qpf, then click "Open".

  • From the Tools menu, select "Platform Designer".

  • In the "Open System" dialog that appears, click the red frame and specify the $HOME/ws/top_project/hw/sys.qsys file.

1f16e437-762b-c2a0-e01b-83a295a0d22d

  • Click Open.

4.2.2 Launching Platform Designer from Terminal

Move to $HOME/ws/top_project and enter the following command:

 

qsys-edit --quartus-project=hw/top.qpf hw/sys.qsys

 

4.2.3 Platform Designer Design

Here, we'll check the design configuration and settings for each IP. The following is the overall design configuration:

522ca06c-fc69-c500-fd39-18d4eac5e744

4.2.3.1 Clock

This is the configuration screen for the clock input IP. If the input clock differs, change this value. If you change it, also modify the clock period in top.sdc (period is specified in ns).

0ea0f1df-0c4d-44c1-2f9d-19875a7b3b84

For IP details, please refer to 7.1.1. Clock Bridge Intel® FPGA IP.

4.2.3.2 Reset

This is the configuration screen for the reset input IP.

a98c88ee-80f6-7567-a752-0a0c0ede928c

For IP details, refer to 6.6.3. Reset Bridge.

4.2.3.3 Nios® V/m Embedded Processor

This is the configuration screen for the Nios® V/m embedded processor IP.

028bfb88-fb12-ded3-097d-8e2b3a5f18d2

For details on each parameter, refer to the following:

4.2.3.4 Internal RAM

This is the configuration screen for the internal RAM IP.

f616a5de-a261-297c-ad83-270e50acf187

For details on each parameter, refer to the following:

4.2.3.5 JTAG UART

This is the configuration screen for the JTAG UART IP.

278352a6-b7fc-9869-5db1-0c22729874cd

For details on each parameter, refer to the following:

Once you have confirmed the settings, please close Platform Designer.

4.3 Compiling the Design

Next, execute the following command in the Terminal to start compiling the design:

 

quartus_sh --flow compile hw/top

 

Output:

 

Info: *******************************************************************
Info: Running Quartus Prime Shell
    ... [Output Truncated for Brevity] ...
Info: Quartus Prime Shell was successful. 0 errors, 35 warnings
    Info: Peak virtual memory: 1034 megabytes
    Info: Processing ended: Mon Nov 27 17:18:51 2023
    Info: Elapsed time: 00:02:25
    Info: System process ID: 64166

 

If you look at line 10 in $HOME/ws/top_project/hw/top.qsf:

 

set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files

 

This indicates where the design compilation outputs are stored, and the .sof file is generated in $HOME/ws/top_project/hw/output_files.

4.4 Configuring the FPGA

Execute the next command to configure the FPGA. Note that the command slightly differs between Linux and Windows.

Linux:

 

quartus_pgm -c 1 -m JTAG -o p\;hw/output_files/top.sof@1

 

Output:

 

Info: *******************************************************************
Info: Running Quartus Prime Programmer
    ... [Output Truncated for Brevity] ...
Info: Quartus Prime Programmer was successful. 0 errors, 0 warnings
    Info: Peak virtual memory: 1917 megabytes
    Info: Processing ended: Mon Nov 27 17:20:32 2023
    Info: Elapsed time: 00:00:13
    Info: System process ID: 67118

 

Windows:

 

quartus_pgm -c 1 -m JTAG -o p;hw/output_files/top.sof@1

 

Output:

 

Info: *******************************************************************
Info: Running Quartus Prime Programmer
    ... [Output Truncated for Brevity] ...
Info: Quartus Prime Programmer was successful. 0 errors, 0 warnings
    Info: Peak virtual memory: 1296 megabytes
    Info: Processing ended: Tue Nov 28 23:35:04 2023
    Info: Elapsed time: 00:00:17
    Info: System process ID: 26872

 

4.5 Porting to Other FPGAs

If you are porting this design to other FPGA boards, the main changes will be the device and clock pins.

  • From the Assignments menu, select "Device..." and in the dialog that appears, specify the device you are using.

f9dc9215-1f60-ccf7-9e65-d275b15ad15c

  • Once the device is changed, Quartus will display "IP update required" in red at the top left. Click "Launch IP Upgrade Tool...".

90eb387c-5f7e-bc60-e9d3-a6613558657d

  • In the dialog that appears, click "Auto Upgrade" to update the IP.

2e976ddf-190d-775c-90f6-a442ba53a1ed

  • Once the IP update is complete and the Status column shows "Success," you can close the dialog.

  • From the Processing menu, select “Start Compilation..." to re-run the compilation. You may encounter errors in the Fitter stage if you haven't set up the clock pin, but you can ignore these for now.
  • From the Assignments menu, select "Pin Planner..." and in the dialog that appears, update the location of the clock pin. Also, update the I/O Standard accordingly.

  • Finally, from the Processing menu, select “Start Compilation..." again and ensure that the compilation runs without errors this time.

 

References

Notices & Disclaimers

Intel technologies may require enabled hardware, software, or service activation. No product or component can be absolutely secure. Your costs and results may vary.

© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.

The products described may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.​

Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from the course of performance, course of dealing, or usage in trade.

Nios is a trademark of Intel Corporation or its subsidiaries.

0 Kudos
1 Reply
symmt_Intel
Employee
1,523 Views
0 Kudos
Reply