Motorola once sc140 Manual De Usuario

Descargar
Página de 40
Compiler Support on StarCore
6
Introduction to the SC140 Tools
2.2   Compiler Support on StarCore
The StarCore compiler implements fractional arithmetic using built-in intrinsic functions based on integer 
data types. Any fractional values or constants must therefore be defined using their integer equivalent. 
Useful relationships for deriving these integer representations from the fractional vales are as follows:
16-bit Integer Value = Fractional Value * 2
15
32-bit Integer Value = Fractional Value * 2
31
40-bit Integer Value = Fractional Value * 2
39
The names of the built-in intrinsics conform to the ITU/ETSI basic operation functions. For instance, the 
L_mac() intrinsic function is used in the following example (see Figure 3), and a complete list of the 
intrinsic functions for fractional arithmetic can be found in the SC100 C/C++ Compiler User’s Manual
The example illustrates how the instructions are mapped based on the type of the arithmetic required. For 
integer arithmetic, the compiler generates integer instructions (for example, imac). For fractional 
arithmetic, it generates fractional instructions (for example, mac). Also, move instructions are generated 
with correct data alignment.
Figure 3.   Integer and Fractional Compiler Support
Hands On
The energy of a signal,  x, represented by Equation 1, is considered:
, (1)
where x(i) is the signal input sample at iteration iy is the energy of the signal, and N is the signal length.
1. Open the example file 
Ex2.c
.
Integer Arithmetic
2. Compile the file using 
ccsc100 -Ot2 Ex2.c -o Ex2.eld
 where the
 -Ot2
 option optimizes the 
code for time (Force Parallelization).
3. Run the executable using runsc100.
4. Recompile the file with the 
-S
 option, which stops the compiler after compilation.
Integer
a = a + b * c;
a = L_mac(a,b,c);
imac
 d0,d1,d2
mac
 d0,d1,d2
(Supported by intrinsics)
move.
w
 (r0),d0
move.
f
 (r0),d0
long a;
short b, c;
long a;
short b, c;
Fractional
y
x
2
i
( )
i
0
=
N
1
=