Altera Nios II C2H Compiler Uživatelský manuál Strana 59

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 138
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 58
Altera Corporation 9.1 3–19
November 2009 Nios II C2H Compiler User Guide
C-to-Hardware Mapping Reference
Example 3–12 demonstrates another case of non equivalent pointers.
Example 3–12 is similar to Example 3–10, but a value is written to address
some_other_pointer between the reads from address
(packed_data + i).
Example 3–12. Nonequivalent Pointers Due to Potential Aliasing
void nonequivalent_pointers(char *packed_data,
int *some_other_pointer,
int len)
{
int i = 0;
while (i < len)
{
char ms_nibble = *(packed_data + i) >> 4;
char ls_nibble;
*some_other_pointer = i;
ls_nibble = *(packed_data + i) & 0x0f;
...
}
}
In this code, the C2H Compiler cannot determine if
some_other_pointer and packed_data overlap addresses (known
as aliasing), which would affect the result of the second evaluation of
*(packed_data + i). Therefore, the C2H Compiler creates a separate
master port for each dereference, creating a total of three master ports. For
details on how to inform the C2H Compiler that two pointers do not alias,
see section “Pointer Aliasing” on page 3–32.
Volatile Type Qualifier
The C2H Compiler does not consolidate or optimize pointers for
dereferenced types that use the volatile type qualifier. The volatile
type qualifier forces the variable to be evaluated strictly according to the
rules of the language. volatile is normally used to access non-memory
peripherals, such as timers and communication devices.
1 The volatile type qualifier overrides the __restrict__
pointer qualifier. For further information, see “Pointer Aliasing”
on page 3–32.
Zobrazit stránku 58
1 2 ... 54 55 56 57 58 59 60 61 62 63 64 ... 137 138

Komentáře k této Příručce

Žádné komentáře