User manual

Tutorial: Handel-C code optimization
#define WIDTH 8
unsigned WIDTH sum[WIDTH];
unsigned WIDTH a[WIDTH];
unsigned WIDTH b[WIDTH];
while(1)
{
par
{
sum[0] = ((a[0][0] == 0) ? 0 : b[0]);
par (i=1; i<=(WIDTH-1); i++)
{
sum[i] = sum[i - 1] + ((a[i][0] == 0) ? 0 : b[i]);
a[i] = a[i - 1] >> 1;
b[i] = b[i - 1] << 1;
}
}
}
The first line of code inside the
while(1) loop sets the value of sum[0], then the replicated par
moves the shifted inputs through the
a[] and b[] arrays, and the results through the sum[] array. The
final result is available in the last element of the
sum[] array, after a latency equal to the width of the
input data. The
TutorialMult workspace contains a copy of this code set up for simulation, using chanin
to get input data from two files, and chanout to write data to another file. You can open the workspace
by selecting
Start>Programs>Celoxica>Platform Developer's Kit>Tutorials>TutorialMult.
7.3 Client-server architecture
When an operation or device driver is particularly complex or requires significant resources when
implemented in hardware, it may not be efficient to use it repeatedly in different locations in a Handel-C
program. A client-server architecture puts all the complexity into a "server" process which runs
indefinitely, and provides a "client" API through which you can gain access to the resources of the
server. The end result is similar to using a function in Handel-C, but allows more control, as you can
specify an API and devise methods of handling multiple simultaneous requests for access to the
resource.
The following examples illustrate how to implement client-server architectures, first using a simple divide
operation, then a more complex Flash Memory driver:
Client-Server divide example (see page 80)
Flash Memory client-server example (see page 82)
7.3.1 Client-server divide example
A simple example of a client-server architecture can be based on a divider, which inherently requires a
large amount of hardware. If the divider is used several times throughout a program, but never more
than once simultaneously, then it can be implemented in a server process as follows.
Create a data structure which will be used to access the server:
www.celoxica.com
Page 80