User manual

DSM tutorials
Take operator
The takeexample project in the TutorialHCBasics workspace shows how to use the take bits <- operator.
The source code is shown below:
while (1)
{
par
{
/*
* Increment up to 15, then wrap round to 0
*/
Count++;
/*
* Write Count and Count <- 3 to display
*/
PalSevenSegWriteDigit (PalSevenSegCT (0), Count, 0);
PalSevenSegWriteDigit (PalSevenSegCT (1), adju( (Count <- 3), 4), 0);
}
}
The
<- operator returns the n least significant bits from its operand.
The value of
Count is shown on the first 7-segment display, while the second display shows the value of
the lowest three bits of
Count. The adju() macro from the Standard Macro Library is used to adjust the
width of the modified value of count to four bits, as this is the width required to be passed to
PalSevenSegWriteDigit(). The example uses Count <- 3 to take the lowest 3 bits, so while the
first display counts once from 0 to 0xF, the second counts twice from 0 to 7, as shown in the table below.
Count
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Display 1
0 1 2 3 4 5 6 7 8 9 A B C D E F
Count<-3
000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
Display 2
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
TAKE EXAMPLE DISPLAYS
Select operator
The selectexample project in the TutorialHCBasics workspace shows how to use the select bits [m:n]
operator. The source code is shown below:
www.celoxica.com
Page 50