User manual
Tutorial: Handel-C and VGA graphics output
6.2.4 Nested control
Using nested if() statements, or long chains of if()...else() blocks can result in a design having
a low clock rate. This is because the worst case is that all the nested conditions must be executed in a
single cycle, so the delay can become significant. If possible, Handel-C code should be written to avoid
nesting control statements more than a few layers deep. If this is not avoidable, there are two options for
reducing the impact:
• Ensure that the first line of code to be execute after nested control statements is relatively
simple, so as not to adversely affect the clock rate.
• Break up the nesting of control statements by executing a line of code in the middle:
if (a == 1)
if (b == 1)
{
x = 0; // execute code here to break up nested control
if (c == 1)
if (d == 1)
e = 0;
else
delay;
else
delay;
}
else
delay;
else
delay;
www.celoxica.com
Page 77