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

Page 17
Image 17
Motorola SC140 user manual Code Generated Assembly Code