Compiler Support on StarCore
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.
Integer
long a; short b, c;
Fractional
long a; | (Supported by intrinsics) |
|
short b, c; | |
Figure 3. Integer and Fractional Compiler Support
Hands On
The energy of a signal, x, represented by Equation 1, is considered:
i = 0
where x(i) is the signal input sample at iteration i, y 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 -Ot2option optimizes the code for time (Force Parallelization).
3.Run the executable using runsc100.
4.Recompile the file with the -Soption, which stops the compiler after compilation.
6 | Introduction to the SC140 Tools |