User manual
DSM tutorials
while (1)
{
/*
* Run the two displays in parallel
*/
par
{
seq
{
/*
* Increment up to 15, then wrap round to 0
*/
Count++;
/*
* Write Count to display
*/
PalSevenSegWriteDigit (PalSevenSegCT (0), Count, 0);
}
seq
{
/*
* Increment up to 5, then reset to 0
*/
Circle = (Circle == 5) ? 0 : (Circle + 1);
/*
* Look up value in ROM, and set display
*/
PalSevenSegWriteShape (PalSevenSegCT (1),
CircleDisplayEncode[Circle]);
}
}
}
Each iteration of the
while(1) loop takes two clock cycles to complete, as the par{} statement
causes the two sequential code blocks within it to be executed in parallel. Without the use of
par{}, the
loop would take four clock cycles to execute.
The execution time can in fact be reduced to a single clock cycle by removing the
seq{} from around
the two code blocks, causing all four lines of code to be executed in parallel. This creates a simple
two-stage pipeline, as in Handel-C values are only assigned to variables at the end of a clock cycle.
Therefore the value displayed would be that held by the counter during the previous clock cycle.
Try executing the
parexample project in the TutorialHCBasics workspace in simulation, and changing the
code to make each loop iteration take 1 or 4 clock cycles. Use the F11 key to step through the code one
cycle at a time, and observe its behaviour. If the
Variables Debug Window is open, and the Locals tab
selected, the value of the variables in the project will be visible.
If an RC200 board is available, try compiling the project for it, and using the Xilinx Place & Route tools to
create a bitfile to download to the board. Note that the call to
Sleep() will now be active, slowing the
program down in the hardware so it can be observed. The behaviour should be the same as that seen in
simulation.
www.celoxica.com
Page 46