Accessing the custom instruction from software, Accessing the custom instruction from software –6 – Altera Nios II Custom User Manual

Page 28

Advertising
background image

3–6

Chapter 3: Implementing a Nios II Custom Instruction in SOPC Builder

Accessing the Custom Instruction from Software

Nios II Custom Instruction User Guide

January 2011

Altera Corporation

Accessing the Custom Instruction from Software

Adding a custom instruction to a Nios II processor results in a significant change to
the SOPC Builder system. In this section, you create and build a new software project
using the Nios II software build flow, and run the software that accesses the custom
instruction. The software source files are included in the downloadable design files.

Table 3–1

lists the CRC application software source files and their corresponding

descriptions.

To run the application software, you must create an Executable and Linking Format
File (.elf) first. To create the .elf file, follow the instructions in the Nios II Software
Build Flow section in the readme_sopcb.txt file in the extracted design files.

The application program runs three implementations of the CRC algorithm on the
same pseudo-random input data: an unoptimized software implementation, an
optimized software implementation, and the custom instruction CRC. The program
calculates the processing time and throughput for each of the versions, to demonstrate
the improved efficiency of a custom instruction compared to a software
implementation.

Example 3–1

shows the output from the application program run on a Nios II

Embedded Evaluation Kit, Cyclone III Edition (NEEK) using the Quartus II software
v10.1 and Nios II Embedded Design Suite (EDS) v10.1.

The output shows that the custom instruction CRC is 75 times faster than the
unoptimized CRC calculated purely in software and is almost 50 times faster than the
optimized version of the software CRC. The results you see using different target
device and board may vary depending on the memory characteristics of the board
and the clock speed of the device, but these ratios are representative.

Table 3–1. CRC Application Software Source Files

File Name

Description

crc_main.c

Main program that populates random test data, executes the CRC both in
software and with the custom instruction, validates the output, and reports
the processing time.

crc.c

Software CRC algorithm run by the Nios II processor.

crc.h

Header file for crc.c.

ci_crc.c

Program that accesses CRC custom instruction.

ci_crc.h

Header file for ci_crc.c.

Advertising