Altera Nios II C2H Compiler User Manual
Page 99

Altera Corporation
9.1
4–5
November 2009
Nios II C2H Compiler User Guide
Understanding the C2H View
Example 4–1. Vector Power Calculation
#pragma altera_accelerate connect_variable power_calculation/voltage to onchipRAM1
#pragma altera_accelerate connect_variable power_calculation/current to onchipRAM1
#pragma altera_accelerate connect_variable power_calculation/power to onchipRAM2
void power_calculation ( short * _ _ restrict_ _ voltage,
short * _ _ restrict_ _ current,
short * _ _ restrict_ _ power,
short downscale,
int length)
{
int i;
for(i = 0; i < length; i++)
{
*power++ = (*voltage++ * *current++) >> downscale;
}
}
requires Avalon-MM read and write master ports to
perform memory accesses. It also requires a multiplier and a barrel shifter
to perform the right shift operation. The pragma statements inform the
C2H Compiler that the input data is stored in a memory called
onchipRAM1
and the output data is to be stored in
onchipRAM2
. When
the C2H Compiler compiles this function, the Nios II IDE generates a
build report as shown in