Altera Nios II Custom User Manual

Page 36

Advertising
background image

4–6

Chapter 4: Implementing a Nios II Custom Instruction in Qsys

Accessing the Custom Instruction from Software

Nios II Custom Instruction User Guide

January 2011

Altera Corporation

Table 4–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_qsys.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 4–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 Service Pack 1 and Nios II Embedded Design Suite (EDS) v10.1 Service Pack 1.

The output shows that the custom instruction CRC is more than 70 times faster than
the unoptimized CRC calculated purely in software and is more than 45 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 4–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