User manual

Tutorial: Handel-C and VGA graphics output
signal unsigned 16 temp1, temp2;
par
{
temp1 = b << c;
temp2 = b * d;
a = temp1 + temp2;
}
This code still has the complex statement broken into three parts however as
temp1 and temp2 are
signals all the operations must still be performed in one clock cycle. This is because signals do not store
the values assigned to them, so the results from the first two lines of code are fed straight into the third
line in the same cycle.
In summary:
Avoid division wherever possible, and use shifts or subtracts instead.
Break complex statements up into several simpler statements
Remember that signals "stack up" the complexity of the lines of code which write and read
them in parallel.
6.1.2 Arrays and memories
Handel-C supports arrays in the same way as in C. However, there are differences resulting from the
way arrays are implemented in hardware. An array can be seen as a collection of variables which can all
be accessed in parallel, with elements either specified explicitly or indexed by a variable. Explicit access
to individual array elements is efficient but indexing through an array can generate significant amounts
of hardware, particularly if it is done from more than one point in the code. Arrays are good for
implementing shift registers and allowing initialization of the contents of every element in a single cycle,
as shown below. This use of arrays is efficient, as every element is specified explicitly.
unsigned 8 Array[4];
par /* Initialise array in single cycle */
{
Array[0] = 23;
Array[1] = 25;
Array[2] = 26;
Array[3] = 29;
}
while (1)
{
par /* Move data through shift register */
{
Array[0] = Input;
Array[1] = Array[0];
Array[2] = Array[1];
Array[3] = Array[2];
}
}
RAM and ROM
If random access into an array can not be avoided it is better to use a RAM, simply by adding the
ram
keyword at the start of the array declaration:
www.celoxica.com
Page 72