User manual
Tutorial: Handel-C and VGA graphics output
assignment to take a single clock cycle. The result is that for() loops have a single clock cycle
rhead so the example below takes 20 cycles to execute, rather than 10:
10; i++)
ample
ill now take 11 clock cycles instead of 20. In practice it may be possible to initialize
i to zero in
r operation, effectively reducing the number of cycles taken from 11 to 10.
< 10)
a[i] = 0;
i++;
}
ch actually
or example, the code shown below would have a low clock rate, even though the
use the condition for the while loop is so complicated.
* c) + d) > (d - b))
for() loops, if()…else statements, conditional assignments, and any
other co o
simple tech
ns (<, <=), as this
Set a single bit variable within the loop and test it in the loop control.
The code below illustrates the use of the second of these two techniques, using the complex example
above:
ove
fo
{
r (i = 0; i <
a[i] = 0;
}
To improve the performance, a
while() loop should be used instead as shown below. In this ex
the loop w
parallel with an earlie
i = 0;
(i while
{
par
{
}
6.2.2 Timing efficiency of loops
The section on Complex statements explained that they can result in a design having a low clock rate.
When control code such as a
while() loop or an if()...else statement is used, the logic
implementing the control must be execute in the same clock cycle as the first line of code whi
operates on data. F
operation
a++ is simple beca
unsigned 8 a;
signed 32 b, c, d; un
ile (((bwh
{
a++;
}
The same principle applies to
ntr l code which might be used. To increase the performance in loops there are a couple of
niques to use:
• Test for equality (
==, !=) where possible rather than using compariso
produces smaller and faster hardware.
•
www.celoxica.com
Page 75