Creation of avalon-mm master ports, Consolidation of equivalent pointers – Altera Nios II C2H Compiler User Manual

Page 57

Advertising
background image

Altera Corporation

9.1

3–17

November 2009

Nios II C2H Compiler User Guide

C-to-Hardware Mapping Reference

Because the array subscript operation and the member operation for
structures and unions can be expressed in terms of an address
computation and a pointer dereference, this section is fundamental to
understanding how arrays, structures, and unions translate to hardware
as well.

Creation of Avalon-MM master ports

In general, the C2H Compiler creates a master port on the accelerator for
every instance of the indirection operator. The following are exceptions to
this rule:

The C2H Compiler identifies certain opportunities for optimization.
In some cases it can collapse multiple master ports to a single master
port without affecting performance, which reduces resource
utilization.

If the C2H Compiler determines that two pointers are exactly
equivalent, it consolidates them to a single master port.

There are considerations for multidimensional arrays. Refer to
section

“Array Subscript Operator” on page 3–26

.

Consolidation of Equivalent Pointers

The C2H Compiler consolidates pointer dereferences when it determines
that the address expressions are always equal and the referenced data
cannot change between dereferences. In this case, the pointer
dereferences share an Avalon-MM master port.

Example 3–9

shows two dereferences that are identical. The

C2H Compiler consolidates them into a single master port.

Example 3–9. Equivalent Pointers

void equivalent_pointers(char *packed_data)
{
char ms_nibble = *packed_data >> 4;
char ls_nibble = *packed_data & 0x0f;
...
}

Advertising