C-to-hardware mapping reference, One-to-one c-to-hardware mapping, Arithmetic and logical operators – Altera Nios II C2H Compiler User Manual
Page 41: Chapter 3. c-to-hardware mapping reference, One-to-one c-to-hardware mapping –1, Chapter 3, c-to-hardware mapping reference, Chapter 3, c-to, Hardware mapping reference
Altera Corporation
9.1
3–1
November 2009
3. C-to-Hardware Mapping
Reference
This chapter describes how the Nios
®
II C-to-Hardware Acceleration
(C2H) Compiler translates ANSI C constructs into functional blocks in a 
hardware accelerator. Understanding the C-to-hardware mappings 
enables you to write C functions optimized for the C2H Compiler to 
achieve higher performance and lower resource utilization.
One-to-One 
C-to-Hardware 
Mapping
The C2H Compiler translates each element of C syntax to an equivalent 
hardware structure using straightforward mapping rules. The mapping 
rules provide a one-to-one association between elements of C syntax and 
their equivalent hardware structures. By learning the C-to-hardware 
mappings, you can control the hardware structure of an accelerator, based 
on the structure of the C code. 
The C2H Compiler can perform resource-sharing optimizations which 
reduce the resource utilization for an accelerator. In these cases, the result 
is a better than one-to-one mapping. 
Arithmetic and Logical Operators
Every arithmetic and logical operator in the C code translates to a 
corresponding hardware block in the accelerator. Consider the function 
MAC()
shown in
Example 3–1. Function with Arithmetic and Logical Operators
long long MAC (int* a, int* b, int len) 
{
 long long result = 0;
 while (len > 0)
 {
 result += *a++ * *b++;
 len--;
 }
 return result;
}