Motorola SC140 user manual Memory Alignment Exercise, Good To Know

Page 12

Compiler Support on StarCore

To understand how global optimization makes best use of available information, perform these steps:

6.Recompile the application with -S option (Stop After Compilation) and with the local optimization: ccsc100 -Ot2 Ex3_main.c Ex3_prod.c -S.

7.Rename the .sl files as Ex3_main1.sl and Ex3_prod1.sl.

8.Open the files to see what the compiler has produced.

9.Enable global optimization: ccsc100 -Ot2 -Og Ex3_main.c Ex3_prod.c -S.

10.Open Ex3_main.sl to see what the compiler has produced.

Since the compiler has all information on the application, it optimizes the application further than with local optimization. The compiler avoids calling the function by in-lining the function into the main code (as shown in Ex3_main.sl). Therefore, it eliminates the cycle overhead associated with jumping to and returning from the function and passing the parameters to the functions.

Congratulations, you have completed Exercise 3.

Good To Know

Global optimization requires a longer compilation time than local optimization.

Global optimization further optimizes the application speed.

4 Memory Alignment Exercise

The memory alignment exercise shows the usage of wide data moves and the necessary alignments for performing these moves. The SC140 memory has byte granularity (as represented in Figure 7). Two arithmetic address units (AAUs) transfer the data from memory to the 4 ALUs (and vice versa) via two 64-bit data buses. Each data bus allows the transfer of up to eight bytes from memory to the data registers in one cycle (and vice versa).

If the compiler must generate the wide data move instructions available in the StarCore instruction

set—such as move.2w, move.2f, move.4w, and so on—data must be correctly aligned in memory. This is due to the way the address and data buses operate for multi-byte accesses in the StarCore architecture. The compiler does not generate wide data move instructions if alignment is not guaranteed. However, if a function is implemented in assembly language and uses wide data move instructions, you must ensure that the data is aligned on the appropriate boundary. Otherwise, the wrong data is transferred.

P:0x00

AA

 

BB

 

CC

DD

 

EE

 

FF

 

AB

BC

8 bytes

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P:0x08

01

 

23

 

45

 

67

 

89

 

AB

 

CD

 

EF

 

8 bytes

P:0x10 ....

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 7.

Memory Granularity

 

12

Introduction to the SC140 Tools

Image 12
Contents Motorola Typical development process is represented in Figure Compiler File I/O Exercise Hands OnGood To Know Integer and Fractional Arithmetic Exercise Interpretation of 16-bit Integer and Fractional Data ValuesCompiler Support on StarCore Integer ArithmeticFractional Arithmetic Good To Know Local Versus Global Optimization Exercise Local OptimizationCompiler Support on StarCore StarCore C Compiler Local Optimization Global OptimizationMemory Alignment Exercise AA BB CC DD First Code Section Second Code Section Split Summation Exercise Code Generated Assembly Code Multi-Sample Exercise = ∑ a i x n For 0 ≤ n LIntermediate 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 Solutions to Exercises Introduction to the SC140 ToolsExercise AlignedExpected 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