Altera Nios II C2H Compiler User Manual

Page 85

Advertising
background image

Altera Corporation

9.1

3–45

November 2009

Nios II C2H Compiler User Guide

C-to-Hardware Mapping Reference

Figure 3–22

shows the dependency graph for the

do

loop in

Example 3–36

, which has loop-carried dependencies.

Example 3–36. Loop-Carried Dependency

int simple_hash(int *data, int len)
{
int hash = 0;
do
{
int data_word = *data++;
hash = hash + data_word;
hash = hash ^ data_word;
} while (len--);
return hash;
}

Figure 3–22. Loop-Carried Dependency

Variables

data

and

hash

have loop-carried dependencies, illustrated by

the cyclic arrows in

Figure 3–22

. The arrow for

hash

indicates that the

calculation on State 1 in iteration N is dependent on the result of the
calculation from State 2 in iteration (N-1). The arrow for

data

in State 0

illustrates the ideal case in which a state depends only on its own output.
The ideal case does not restrict the scheduling of successive iterations.

Advertising