Altera Nios II C2H Compiler User Manual

Page 52

Advertising
background image

3–12

9.1

Altera Corporation

Nios II C2H Compiler User Guide

November 2009

One-to-One C-to-Hardware Mapping

Table 3–5

shows an example of a subfunction called by two different

functions. In this case, functions

foo()

and

bar()

both call a

subfunction

foobar_sub()

.

Figure 3–8

shows the hardware structure of the accelerators resulting

from the code in

Table 3–5

. Logic for the function

foobar_sub()

exists

within both accelerators.

Figure 3–8. Shared Subfunction Logic

The C2H Compiler does not support external subfunctions. You must
locate the subfunction in the same source file as the accelerated function.
This is because, unlike the

#include

construct, a C external function

reference requires the presence of a linker. The C2H Compiler has no
linker.

Table 3–5. Shared Subfunction foobar_sub()

Top-Level Accelerated Function: foo() Top-Level Accelerated Function: bar()

void foo(int *data_in,

int *data_out)

{

...

foobar_sub();

...

}

void bar(int *data_in,

int *data_out)

{

...

foobar_sub();

...

foobar_sub();

...

}

Advertising