You are on page 1of 16

Lab 2: Nios II-Processor

Lab 2: Nios II - Processor


First Program – Hello World

OBJECTIVE
The objective of this Lab is to understand the nios system, as well as use this tool for
supporting in creating a custom project.
- Use DE10-Standard System Builder Tool to create the first project using Nios II.
- Use Quartus 18.1 programmer to download .sof file to the development board (DE10-
standard) via JTAG interface.
- Use Eclipse Software to program first program: Hello World.

Figure 1: Diagram of a first simple project using NIOS II

Reference:
Chapter 3 - Using the DE10-Standard Board (DE10-Standard User Manual.pdf)
Chapter 4 - DE10-Standard System Builder (DE10-Standard User Manual.pdf)

Department of Electronics
Microcomputer Laboratory
1
Lab 2: Nios II-Processor

PROCEDURE
Design flow
1. The students must read carefully “Chapter 4 - DE10-Standard System Builder
(DE10-Standard User Manual.pdf)” to understand about DE10-Standard
System Builder tool and the multiple parts of this tool.
2. The design flow of building a Quartus II project for DE10-Standard under the
DE10-Standard System Builder is illustrated in Figure 2.

Figure 2: Design flow of building a project from the beginning to the end

Department of Electronics
Microcomputer Laboratory
2
Lab 2: Nios II-Processor

CONFIGURE MICROCOMPUTER USING QUARTUS


 Step 1: Open System Builder tool and choose necessary peripherals, DO NOT
choose HPS. For first project, we only need CLOCK, 7-Segment, LED, Switch
and Button. Remember to save project in a directory path which MUST NOT
contain space.

 Step 2: Open project using Quartus 18.1, and choose icon to open Platform
Designer.

Department of Electronics
Microcomputer Laboratory
3
Lab 2: Nios II-Processor

 Step 3: At tab IP Catalog, search IP and add to our system. Search, config and
add nios II, JTAG UART, On Chip Memory and Pio.

 Choose Nios II processor. When the popup appears, choose type NiosII/f.

 Next, choose JTAG UART. Do not configure anything here.

Department of Electronics
Microcomputer Laboratory
4
Lab 2: Nios II-Processor

 Next, choose PIO (Parallel I/O). This PIO block used to connect to LEDs.
Because we have 10 LEDs, we configure Width with value 10. To control
LEDs, the direction of PIN need to be OUTPUT.

 Finally, choose On-Chip Memory and add to the system. This block is the
memory of the system. We change to total of memory size into 204800. The
Slave S1 Data width is 32 which means a word of memory has 32 bits. The
type of memory is RAM which means we can write and read to this mem.

Department of Electronics
Microcomputer Laboratory
5
Lab 2: Nios II-Processor

 Step 4: Connect wire and change name of external_connection of pi_0 block to


led_wire as picture below. This means, the output PIN used to connect to LED
is labeled to “led_wire”.

You can change the name of each block to remind the its ultility.

Department of Electronics
Microcomputer Laboratory
6
Lab 2: Nios II-Processor

Turn back to Nios II configuretion popup (labeled as CPU), choose tab Vectors.
Change reset vector memory and exception vector memory to MEMORY.s1 (or
the name of Instruction Memory Block.s1).

 Step 5: Choose Assign Base Address as picture below.

 Step 6: Make sure no errors, then save Qsys Design and generate HDL.

Department of Electronics
Microcomputer Laboratory
7
Lab 2: Nios II-Processor

Create a new folder named qsys to save and set name for qsys design. Remember,
the name of qsys design MUST NOT the same as project’s (which is lab2nios at
step 1).

Step 7: After generating HDL, comeback to Quartus and choose File at Tab
Project Navigator as picture below.

Department of Electronics
Microcomputer Laboratory
8
Lab 2: Nios II-Processor

Right click at File and choose Add/Remove Files in Project…

At directory File name, choose path to folder systhesis, add {qsys design’name.v}.
Next, in folder systhesis, choose folder subsystem, add all files in this folder.

Department of Electronics
Microcomputer Laboratory
9
Lab 2: Nios II-Processor

Department of Electronics
Microcomputer Laboratory
10
Lab 2: Nios II-Processor

After that, click OK and come back to quartus. Right click on .SDC file and choose Set
as Top-Level Entity.

Department of Electronics
Microcomputer Laboratory
11
Lab 2: Nios II-Processor

 Step 8: Open file {qsys project}.cmd in folder systhesis and copy the instance to
file {main project}.vhd. After that, connect input and output of entity ports to
input and output signals of main project (which is created by SystemBuilder).
Look at a sample below.

After this step, compile the project. If there are no errors, continue to step 9. If not,
return to previous steps and check for problems.

Department of Electronics
Microcomputer Laboratory
12
Lab 2: Nios II-Processor

 Step 9: Download program to kit DE10.

Don’t cancel while doing next steps.

 Step 10: Open Nios II Software Build Tools for Eclipse.

Choose directory path for the software project and click OK. Remember, this directory
path MUST NOT have space.

Department of Electronics
Microcomputer Laboratory
13
Lab 2: Nios II-Processor

 Step 11: Click File  New  Nios II Application and BSP from Template.

Department of Electronics
Microcomputer Laboratory
14
Lab 2: Nios II-Processor

 Step 12: When asked .sopcinfo, choose in folder qsys as example below. Then,
click finish.

Department of Electronics
Microcomputer Laboratory
15
Lab 2: Nios II-Processor

 Step 12: Right click on project with no BSP in name, choose Build Project.

 Step 13: After finish compiling, right click on this project and then choose Run
As  Nios II Hardware.

If you compile and run as successfully, you should see “Hello from Nios II!” in the
console. If not, please return to previous steps and check for problems.

Department of Electronics
Microcomputer Laboratory
16

You might also like