Create and configure a hardware accelerator, Create and configure a hardware accelerator –8 – Altera Nios II C2H Compiler User Manual
Page 30

2–8
9.1
Altera Corporation
Nios II C2H Compiler User Guide
November 2009
Tutorial
2.
Observe the execution time in the Console view.
results of approximately 86000 milliseconds. The results you see
might be different, depending on the memory characteristics of the
target board and the clock speed of the example design.
Example 2–1. Execution Results as Software-Only Implementation
This simple program copies 1048576 bytes of data from a source buffer to a
destination buffer.
The program performs 100 iterations of the copy operation, and calculates
the time spent.
Copy beginning
SUCCESS: Source and destination data match. Copy verified.
Total time: 86520 ms
Create and Configure a Hardware Accelerator
In this section, you create an accelerator for the
do_dma()
function. To
create the hardware accelerator, perform the following steps:
1.
Open the dma_c2h_tutorial.c
source file in the Nios II IDE editor, if
it is not already open.
2.
In the source file, double-click the name of the
do_dma()
function
to select it.
3.
Right-click do_dma and click Accelerate with the Nios II
C2H Compiler
. The C2H view appears in the bottom pane of Nios II
IDE.
1
In this example, for simplicity, the
do_dma()
function exists in
the same file as the rest of the application code. However, a good
practice is to isolate functions for acceleration into a separate C
file. The project makefile cannot determine specifically what
part of a file has changed. As a result, if an accelerated function
coexists in the same file with other unaccelerated code, the
C2H Compiler is forced to rebuild the accelerator, even if you
edit unrelated code.
4.
Set the build options for the new accelerator, as shown in
a.
Click the + icon to expand c2h_tutorial_sw in the C2H view.