SPRADD8 November   2024 F29H850TU , F29H859TU-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction to Real-Time Control
  5. 2C29 CPU and Key Features
    1. 2.1 Parallel Architecture and Compiler Entitlement
  6. 3C29 Performance Benchmarks
    1. 3.1 Signal Chain Benchmark with ACI Motor Control
    2. 3.2 Real-time Control and DSP Performance
      1. 3.2.1 Examples and Factors Contributing to Results
        1. 3.2.1.1 Saturation (or Limiting) Example
        2. 3.2.1.2 Dead Zone Example
        3. 3.2.1.3 Space Vector Generation (SVGEN) Example
        4. 3.2.1.4 Software Pipelining
      2. 3.2.2 Customer Control and Math Benchmarks
    3. 3.3 General Purpose Processing (GPP) Performance
      1. 3.3.1 Examples and Factors Contributing to Results
        1. 3.3.1.1 Discontinuity Management
        2. 3.3.1.2 Switch() Example
    4. 3.4 Model-Based Design Benchmarks
    5. 3.5 Application Benchmarks
      1. 3.5.1 Single Phase 7kW OBC Description
      2. 3.5.2 Vienna Rectifier-Based Three Phase Power Factor Correction
      3. 3.5.3 Single-Phase Inverter
      4. 3.5.4 Machine Learning
    6. 3.6 Flash Memory Efficiency
    7. 3.7 Code-size Efficiency
  7. 4Summary
  8. 5References

Switch() Example

Special branch instructions allow the C29 compiler to collapse multiple branch destinations into a single instruction. switch is a common construct that occurs in general purpose code, such as housekeeping tasks. The C29 ISA has multiway branch instructions QDECB and DDECB that allow very efficient implementation. In quad decrement branch (QDECB), four destinations are allowed, with the fifth option being linear execution. In dual decrement branch (DDECB), two destinations are allowed, and the third option is linear execution.

A 16 case switch statement is illustrated in the code block below. On the C29 CPU, the switch is implemented with one branch instruction (BCMP) and four QDECB instructions, taking 10 to 17 cycles, depending on the input. On the Cortex-M7, the switch is implemented with compare and branch instructions for each case, thus taking 6 to 51 cycles, depending on the input.

switch(state) { case 15: .... break; case 14: .... break; case 13: .... break; ... ... case 0: .... break; default: .... break; }  

C29 Implementation
LD.32 A14,@State  
BCMP @default,A.GT,A14,#15   QDECBA14,#0x4,@case15,@Case14,@Case13,@Case12,@  QDECBA14,#0x4,@case11,@Case10,@Case9,@Case8,@   QDECBA14,#0x2,@case7,@case6,@case5,@case4,@  
QDECBA14,#0x2,@case3,@case2,@case1,@case0,@  
default:
.... 
.... 
LB @State_end
case15:
.... 
.... 
LB @State_end 
case14:
.... 
.... 
LB @State_end 
case13:
.... 
.... 
LB @State_end 
....
....
....
case2: 
.... 
.... 
LB @State_end 
case1: 
.... 
.... 
LB @State_end 
case0: 
.... 
.... 
State_end:

M7 Implementation
LDRSB R6,[State]
CMP   R6,#15  
BGT.N default  
BEQ.N case15  
CMP   R6,#14  
BEQ.N case14  
.... 
CMP   R6,#0  
BEQ.N case0   
default:
.... 
.... 
B  State_end 
case15:
.... 
.... 
B  State_end 
case14:
.... 
.... 
B  State_end 
case13:
.... 
.... 
B  State_end 
....
....
....
case2: 
.... 
.... 
B  State_end 
case1: 
.... 
.... 
B  State_end 
case0: 
.... 
.... 
State_end: