
3–18 9.1 Altera Corporation
Nios II C2H Compiler User Guide November 2009
Memory Accesses
Example 3–10 shows two dereferences that are identical inside of a loop.
The C2H Compiler consolidates them into a single master port.
Example 3–10. Equivalent Pointers in a Loop
void equivalent_pointers(char *packed_data, int len)
{
int i = 0;
while (i < len)
{
char ms_nibble = *(packed_data) >> 4;
char ls_nibble = *(packed_data++) & 0x0f;
...
i++;
}
}
Example 3–11 demonstrates a case of non equivalent pointers.
Example 3–11 is similar to Example 3–10, but packed_data increments
between the two pointer dereferences. In this case the address
expressions have different values, which translate to two separate master
ports.
Example 3–11. Nonequivalent Pointers
void nonequivalent_pointers(char *packed_data, int len)
{
int i = 0;
while (i < len)
{
char ms_nibble = *(packed_data++) >> 4;
char ls_nibble = *(packed_data) & 0x0f;
...
i++;
}
}
Comentarios a estos manuales