Motorola SC140 user manual Code Generated Assembly Code

Page 17

Compiler Support on StarCore

Hands On

1.Open the Ex5.c file.

2.Build the code with -Ot2, then run it and notice the output result.

3.Split the current implementation of the loop (that is, res = L_mac(res, x[i], x[i]);) into four independent equations as represented in Figure 9.

“Independent” means that the four equations are accumulated into different variables. Therefore, create four variables for each product. Tip: Watch your index increment.

4.Recompile the file and run it. The output result should be the same as before.

5.Recompile with the -Soption and view the .sl file.

6.Your code is optimized when the loop is only one cycle and computes four operations at a time.

If the inner loop is equal to one cycle for four operations and the result is still correct, congratulations. You have completed Exercise 5.

7.In the box provided below, write the optimized inner loop code:

C Code

Generated Assembly Code

The split summation technique allows full use of all four ALUs, reducing the cycle time by more than 70 percent relative to use of a single ALU. The 4-ALU technique does not guarantee bit-exactness with the single-ALU technique because the order of accumulation is different. Using the 4-ALU technique therefore has implications in applications that are defined by bit-exact standards, such as speech coding standards from ITU, ETSI,TIA/EIA, and so on.

Introduction to the SC140 Tools

17

Image 17
Contents Motorola Typical development process is represented in Figure Compiler Good To Know File I/O ExerciseHands On Interpretation of 16-bit Integer and Fractional Data Values Integer and Fractional Arithmetic ExerciseInteger Arithmetic Compiler Support on StarCoreFractional Arithmetic Good To Know Local Optimization Local Versus Global Optimization ExerciseCompiler Support on StarCore StarCore C Compiler Global Optimization Local OptimizationMemory Alignment Exercise AA BB CC DD First Code Section Second Code Section Split Summation Exercise Code Generated Assembly Code = ∑ a i x n For 0 ≤ n L Multi-Sample ExerciseIntermediate Version Compromise Between Memory and Speed Further Speed Optimization Control Code The True Bit Exercise Save Ex7.c as Ex71.c Calling an Assembly Routine From C Exercise Current Following output should be displayed Challenge Introduction to the SC140 Tools Solutions to ExercisesAligned ExerciseExpected Motorola INC Intermediate version Compromise between Memory and Speed Compiler Support on StarCore Further Optimizing the Speed Compiler Support on StarCore Compiler Support on StarCore Motorola INC Zoffset equ Moffset equ Exercise Compiler Support on StarCore Compiler Support on StarCore AN2009/D