AN2094 Freescale Semiconductor / Motorola, AN2094 Datasheet - Page 6

no-image

AN2094

Manufacturer Part Number
AN2094
Description
ITU-T G.729 Implementation on StarCore SC140
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Optimization Process
The PC compiler used to check the modifications to the C code and generate the test vectors for unit testing was
Microsoft Visual C++ 6.0. The project was developed on the Windows 2000 Professional platform. Hardware tests
were run on the SC140 Software Development Platform (SDP).
2.2 Porting G.729 Code to the SC140
This section describes the considerations involved in porting the fixed-point C source code distributed by the ITU-
T for the G.729 Recommendation to the SC140.
2.2.1 Initial Compilation
The original C reference code was first compiled using the StarCore Enterprise C compiler with only minor
changes, and the resulting code passed all ITU-T test vectors on the software simulator. This verified that the
compiler is fully ANSI C compliant.
2.2.2 Initial Modifications
The first set of modifications to the original ITU-T C code was made to replace the DSP emulation instructions
with SC140 intrinsic functions and accommodate multi-channel environments.
2.2.2.1 Intrinsic Functions
The DSP emulation instructions in basic_op.c were replaced by intrinsic functions of the SC140 Enterprise C
compiler. The set of functions defined in the compiler’s prototype.h file is substantially richer than the set
provided in basic_op.c, so all emulation functions were easily replaced, with the exception of some minor
modifications described below that were required to handle overflow and saturation. In addition, the Word16,
Word32, and Flag data types used in the G.729 code were redefined in typedef.h to comply with SC140
architecture. For more details, refer to the StarCore SC100 C Compiler User’s Manual [9], section 3.4.4.
2.2.2.2 Overflow
The DSP emulation instructions in basic_op.c simulate two processor flags, overflow and carry. The carry flag
is used only inside the emulated operations, so there was no problem in removing it. However, the overflow flag is
set in several functions, and tested in other functions, so it must remain. Because the overflow flag was no longer
available as a global variable, two assembly routines were developed that allow C code to access the overflow flag.
These routines are called ClearOverflow() and GetOverflow().
2.2.2.3 Saturation
The G.729 code uses a
equivalent to the sat.w instruction, which is not implemented in the SC140. The nearest equivalent intrinsic
function, saturate(), saturates the upper 16 bits, and is translated by the compiler to a sat.f instruction. One
solution to this problem is to insert an inline assembly function that emulates sature(), as shown in Example 1.
asll
sat.l
asll
sat.f
6
#<8,d0
d0
#<8,d0
d0,d0
ITU-T G.729 Implementation on the StarCore™ SC140/SC1400 Cores, Rev. 1
sature()
Example 1. Assembly Emulation of Sature()
function, which saturates the lower 16 bits of a 32-bit value. This is virtually
Freescale Semiconductor

Related parts for AN2094