User manual
DSM tutorials
• Making a driver portable (see page 55)
4.1 Handel-C language basics
The TutorialHCBasics workspace illustrates the use of some of the Handel-C operators and constructs
which are not present in C or C++. To open the workspace, select
Start>Programs>Celoxica>Platform
Developer's Kit
>Tutorials>TutorialHCBasics.
• Use of parallel code:
parexample and swapexample projects
• Channel communication:
channelexample project
• Bit manipulation:
dropexample, takeexample, selectexample and catexample projects
• Use of signals:
signalexample project
4.1.1 Use of parallel code
par{} is one of the key Handel-C constructs used to improve the performance of a program. It executes
multiple code blocks in parallel. The
seq{} construct is used to explicitly execute code sequentially,
instead of in parallel. Sequential execution is the default if neither
par{} or seq{} is specified.
The
parexample project in the TutorialHCBasics workspace runs two counters (Count and Circle) in
parallel. They cycle from 0 to 15 and 0 to 5 respectively.
Count is displayed on one of the
seven-segment displays, while
Circle is used to index the ROM CircleDisplayEncode, which
contains the appropriate values to display a lit segment moving around a display. The declaration of the
variables is shown below:
static rom unsigned 8 CircleDisplayEncode[6] = {0x1,0x2,0x4,0x8,0x10};
unsigned 4 Count;
unsigned 3 Circle;
After calling the required PAL functions to request and initialize the seven-segment displays, the
Count
and Circle variables are initialized to zero, and the following loop is executed forever:
www.celoxica.com
Page 45