Altera Nios II C2H Compiler User Manual
Page 80

3–40
9.1
Altera Corporation
Nios II C2H Compiler User Guide
November 2009
Scheduling
For the purposes of scheduling, the C2H Compiler treats a loop and its
dependencies as a unit. No lines of code past the loop block execute until
the whole loop completes.
shows the dependency graph for
the function
transform_and_hash_matrix()
, shown in
Example 3–33. Dependency Graph for a Function Containing a Loop
int transform_and_hash_matrix(int *matrix,
int length, int width)
{
int n_words = length * width;
int hash = 1;
int i;
for (i=0; i
...perform some transform...
hash = ...some hash calculation...
}
return hash;
}
Figure 3–19. Dependency Graph for a Function Containing a Loop
, some part of the
for
loop depends on
n_words
, and so the C2H Compiler does not schedule the loop until after
the assignment to
n_words
completes. The
return
statement outside
the loop depends on
hash
, which is assigned inside the loop. As a result,
the C2H Compiler does not schedule the
return
statement until the loop
completes.
In this case, the state machine for
transform_and_hash_matrix()
has three states. However, the state machine does not complete in three
clock cycles, because State 1 consists of a sub-state-machine, which
requires multiple clock cycles to complete.