SPRADD8 November 2024 F29H850TU , F29H859TU-Q1
Space Vector Generation (SVGEN) is a common function found in motor control systems, where a vector (α, β) is mapped to a 6-segment space vector, to generate 3 PWM signals. In a normal implementation of SVGEN, as shown in Figure 3-5, if..else statements are used (left-side of Figure), and the compiler generates code that contains branches (right-side of Figure).
Figure 3-5 Normal Implementation of SVGEN. In an optimized implementation of SVGEN, as shown in Figure 3-6, the implementation uses the QUADF instruction of the C29, through an intrinsic, __builtin_c29_quadf32. The instruction breaks up the 2-D space into 16 segments. Then a switch() statement maps the 16-segment space to 6-segment space. The C code is illustrated on the left side of the Figure, and the compiler generated assembly on the right side of the Figure. The generated assembly is now straight line code, without branches, and is parallelized (four instructions in parallel every cycle).
Optimized implementation takes 24 cycles on the C29, irrespective of the inputs, whereas the normal implementation takes 26-43 cycles, depending on the inputs. On the C28, the normal implementation takes 70-100 cycles. On the Cortex-M7, the normal implementation takes 58-73 cycles, depending on the inputs.
Figure 3-6 Optimized Implementation of SVGEN on C29. TI provides libraries covering real-time control and DSP. Specific cases where an optimized implementation of a library yields performance improvements over a natural implementation are called out.