Analog Devices, Inc. · NASDAQ:ADI

Analog Devices — Technical Presentation (December 2008)

43 slides from Analog Devices's technical presentation, December 2008

  1. Slide 1: About this Module

    Slide 1: About this Module

    About this Module This Module Describes the Basic Software Build Process of VisualDSP++, Specific Blackfin Programming “Gotchas”, and Basic Code Optimization Strategies. Users Will See an Example Demonstrating “Zero Effort” Optimization by Using Built-In Optimizer and Cache. 1

  2. Slide 2: Agenda

    Slide 2: Agenda

    Agenda ‹ Software Build Process in VisualDSP++ ‹ Explanation of Linker Description File (LDF) ‹ Programming Blackfin Processors In C ‹ Creating Efficient C Code ‹ Ogg Vorbis Tremor Example 2

  3. Slide 3: Software Build Process in VisualDSP++

    Slide 3: Software Build Process in VisualDSP++

    Software Build Process in VisualDSP++ 3

  4. Slide 4: Porting C Code to Blackfin

    Slide 4: Porting C Code to Blackfin

    Porting C Code to Blackfin Ported C Code Will Build and Execute Out-of-Box z Code Can Be Large and Slow ‹ If Code Is Too Large to Fit in Internal Memory… z It Spills Into External Memory z Fetching from External Memory Is Slower ‹ Optimization Switches Are Off z Generates Unoptimized Functional Code

  5. Slide 5: Software Development Flow

    Slide 5: Software Development Flow

    Software Development Flow What Files Are Involved? 33rdrdParty Party Libraries Libraries (.DLB) (.DLB) Source Files Object Files Executable (.C and .ASM) (.DOJ) (.DXE) Debugger (In-Circuit Emulator, Simulator, or EZ-KIT Lite ) Compiler & Linker Assembler Loader / Splitter Boot Boot Code Code Boot Im

  6. Slide 6: C Run-Time Header (basiccrt.s)

    Slide 6: C Run-Time Header (basiccrt.s)

    C Run-Time Header (basiccrt.s) ‹ Sets Up C Run-Time (CRT) Environment z Sets Up Stack Pointer z Enables Cycle Counters for Benchmarking Code z Configures Cache, If Requested z Change Clock/Voltage Settings, If Requested ‹ Can Be Modified Through Project Options Window 6

  7. Slide 7: Software Build Process

    Slide 7: Software Build Process

    Software Build Process Step-1 Example: C Source cFile1.C cFile1.DOJ main() Object Section = program { _main: int j = 12; C-Compiler C-Compiler ... int k = 0; // main ASM code k += j * 2; ... func1(); _func1: } .S ... // func1 ASM code void func1(void) ... { int var1; foo = 1; Assembler Assembler Obj

  8. Slide 8: Compiler-Generated Object Section Names

    Slide 8: Compiler-Generated Object Section Names

    Compiler-Generated Object Section Names ‹ Compiler Uses Default Section Names that Will Be Used By the Linker Name Contents program Program Instructions data1 Global and “static” Data constdata Data Declared as “const” ctor C++ Constructor Initializations cplb_code Instruction Cache Config Tables cp

  9. Slide 9: C Source with Alternate Sections

    Slide 9: C Source with Alternate Sections

    C Source with Alternate Sections foo.DOJ foo.C section (“sdram0”) int array[256]; Object Section = sdram0 section (“L1_code”) void bar(void) { _array [00] int foovar; _array [01] foovar = 1; … foovar ++; _array [255] } Object Section = L1_code _bar : . . . C-Compiler C-Compiler Assembler Assembler /

  10. Slide 10: Other Convenient Input Section Names

    Slide 10: Other Convenient Input Section Names

    Other Convenient Input Section Names ‹ sdram0 z Code/Data to be Explicitly Placed in External Memory ‹ L1_code z Code to be Mapped Directly into On-Chip Program Memory ‹ L1_data_a; L1_data_b z Data to be Mapped Directly into On-Chip Data Memory (Banks A and B, Respectively) 10

  11. Slide 11: Software Development Flow

    Slide 11: Software Development Flow

    Software Development Flow Step 2 - Linking 33rdrdParty Party Libraries Libraries (.DLB) (.DLB) Source Files Object Files Executable (.C and .ASM) (.DOJ) (.DXE) Debugger (In-Circuit Emulator, Simulator, or EZ-KIT Lite ) Compiler & Linker Assembler Loader / Splitter Boot Boot Code Code Boot Image Link

  12. Slide 12: VisualDSP++ Linker

    Slide 12: VisualDSP++ Linker

    VisualDSP++ Linker ‹ Inputs z Compiled/Assembled Code Object Files (DOJ) z Linker Description File (LDF) z Compiled Libraries (3rd Party or Other) ‹ Outputs A Fully Resolved Blackfin Executable File (DXE) z Can Be Run In Simulator z Can Be Loaded Onto Target Via Emulator or Debug Monitor ‹ LDF Defin

  13. Slide 13: Blackfin Memory

    Slide 13: Blackfin Memory

    Blackfin Memory ‹ Blackfin Processors Have Highly Efficient Memory Architecture ‹ Memory Supported by A Hierarchical Memory Scheme z On-Chip Level 1 Memory – L1 z On-Chip Level 2 Memory – L2 (BF535 and BF561) z Off-Chip Memory – SDRAM/SRAM ‹ Each Type of Memory Has Its Own Address Range ‹ Memory Acc

  14. Slide 14: Explanation of Linker Description File (LDF)

    Slide 14: Explanation of Linker Description File (LDF)

    Explanation of Linker Description File (LDF) 14

  15. Slide 15: Link Process

    Slide 15: Link Process

    Link Process Object and Library Files Executable (.DOJ and .DLB) (.DXE) cFile1.DOJ “L1_code ” OUTPUT “program” ProjLib.DLB SECTION “ data1 “ “ data1” OUTPUT “ sdram0 “ “ program “ OBJECT SECTION OBJECT SECTION OBJECT SECTION OBJECT SECTION LINKER SECTION OBJECT SECTION OUTPUT OBJECT SECTION SECTION

  16. Slide 16: LDF Expresses How Program Is Mapped (1)

    Slide 16: LDF Expresses How Program Is Mapped (1)

    LDF Expresses How Program Is Mapped (1) ‹ Linker Description File (LDF) Is the Way the User Describes Where in Memory to Place Parts of a Program z Every Project MUST Include an LDF z Default LDF Chosen By Linker if None Specified ‹ User Sets the Target: ARCHITECTURE() ‹ User Defines the Memory Layo

  17. Slide 17: Setting Target & Defining Memory Layout

    Slide 17: Setting Target & Defining Memory Layout

    Setting Target & Defining Memory Layout ‹ User Must Declare All Available System Memory ‹ Refer To Blackfin System Memory Map When Defining Segments ARCHITECTURE (ADSP-BF537) SEARCH_DIR ($ADI_DSP\Blackfin\lib) $OBJECTS = $COMMAND_LINE_OBJECTS; Global Commands MEMORY { MEM_L1_DATA_A { TYPE(RAM) START

  18. Slide 18: LDF Expresses How Program Is Mapped (2)

    Slide 18: LDF Expresses How Program Is Mapped (2)

    LDF Expresses How Program Is Mapped (2) ‹ User Describes Where in Memory to Place Input Sections: PROCESSOR{ SECTIONS{ … INPUT_SECTIONS()… } } z INPUT_SECTIONS() Describes What Contents from Input Files Are to be Mapped into the Current Output Section INPUT_SECTIONS{ file_source ( input_labels ) } ‹

  19. Slide 19: Example LDF (Continued)

    Slide 19: Example LDF (Continued)

    Example LDF (Continued) Link Commands – Heart of LDF PROCESSOR p0 OBJECT SECTIONS from .ASM/.S files { OUTPUT( $COMMAND_LINE_OUTPUT_FILE ) SECTIONS DXE SECTION NAMES MEMORY SEGMENTS { Declared in the LDF Used in .map file sec_data_a { INPUT_SECTIONS( $OBJECTS(data1) ) } > MEM_L1_DATA_A sec_data_b {

  20. Slide 20: Using Macros

    Slide 20: Using Macros

    Using Macros ‹ $OBJECTS = CRT, $COMMAND_LINE_OBJECTS z CRT Is the C Run-Time Object File basiccrt.doj z $COMMAND_LINE_OBJECTS ‹ Contains All Object (.doj) Files that Are Included in Your Project ‹ Ordering of DOJ Files Is Exactly the Order in Which Source Files Appear in Project sec_prog { INPUT_SEC

  21. Slide 21: How Does The Linker Work?

    Slide 21: How Does The Linker Work?

    How Does The Linker Work? ‹ Object Sections Can Be Mapped to Many Memory Segments ‹ SECTIONS Parsed Left-to-Right and Top-to-Bottom z If Object Section Fits, It Goes Into the Memory Segment z If It Doesn’t Fit, Linker Proceeds to… ‹ Put It Off To Side Until Next Executable Section Is Processed ‹ Che

  22. Slide 22: Example LDF (Elaborated)

    Slide 22: Example LDF (Elaborated)

    Example LDF (Elaborated) Input Files: main.c and file2.c sec_data_a { INPUT_SECTIONS( $OBJECTS(data1) ) } > MEM_L1_DATA_A sec_prog { INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_L1_CODE sec_sdram { INPUT_SECTIONS( $OBJECTS(data1) ) INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_SDRAM0 Expand Macro: sec_

  23. Slide 23: Optimizing Using the Linker/LDF

    Slide 23: Optimizing Using the Linker/LDF

    Optimizing Using the Linker/LDF ‹ For Size, Use “Eliminate Unused Objects” Feature ‹ For Performance z Move Frequently Used Program/Data into Internal Memory section(“L1_code”) void myFunction (void); section(“L1_data_a”) char myArray[256]; z Place Data into Different Banks to Avoid Access Conflicts

  24. Slide 24: Expert Linker

    Slide 24: Expert Linker

    24 Expert Linker ANALOG DEVICES

  25. Slide 25: Expert Linker

    Slide 25: Expert Linker

    Expert Linker ‹ Presents Graphical Interface for Manipulating LDF Files ‹ Resize Memory by Grab/Stretch z Enlarge One Memory Segment at Expense of Another ‹ Map Sections with Drag/Drop ‹ Displays Run-Time Information z Watermarks for Stack/Heap ‹ Simply Changing a Text File; Makes Changes Locally, N

  26. Slide 26: Create an LDF with Expert Linker

    Slide 26: Create an LDF with Expert Linker

    Create an LDF with Expert Linker ‹ Proceed Through Dialog, Selecting: z LDF Name z Language (C, C++, or ASM) ‹ Template LDF Files Are in ldf Installation Directory C:\Program Files\VisualDSP++ 4.0\Blackfin\ldf z Named with _ASM, _C, _CPP Suffixes i.e., ADSP-BF537_C.ldf 26

  27. Slide 27: Programming Blackfin Processors In C

    Slide 27: Programming Blackfin Processors In C

    Programming Blackfin Processors In C 27

  28. Slide 28: Making Use of Peripherals

    Slide 28: Making Use of Peripherals

    Making Use of Peripherals ‹ Blackfin Peripherals Are Programmed/Used Via Sets of Memory-Mapped Registers (MMRs) ‹ System Services and Device Drivers Automatically Handle Programming of These MMRs 28

  29. Slide 29: Blackfin Header Files (defBF537.h)

    Slide 29: Blackfin Header Files (defBF537.h)

    Blackfin Header Files (defBF537.h) #include <def_LPBlackfin.h> /* Include all Core registers and bit definitions */ #include <defBF534.h> /* Include all MMR and bit defines common to BF534 */ /* Define EMAC Section Unique to BF536/BF537 */ /* 10/100 Ethernet Controller (0xFFC03000 - 0xFFC031FF) */ #

  30. Slide 30: C Header Files (cdefBF537.h)

    Slide 30: C Header Files (cdefBF537.h)

    C Header Files (cdefBF537.h) #include <cdefBF534.h> /* Include MMRs Common to BF534 */ #include <defBF537.h> /* Include all Core registers and bit definitions */ /* Include Macro "Defines" For EMAC (Unique to BF536/BF537) */ /* 10/100 Ethernet Controller (0xFFC03000 - 0xFFC031FF) */ #define pEMAC_ST

  31. Slide 31: One Special Gotcha (cdefBF537.h)

    Slide 31: One Special Gotcha (cdefBF537.h)

    One Special Gotcha (cdefBF537.h) /* SPORT0 Controller (0xFFC00800 - 0xFFC008FF) */ #define pSPORT0_TX ((volatile unsigned long *)SPORT0_TX) #define pSPORT0_RX ((volatile unsigned long *)SPORT0_RX) #define pSPORT0_TX32 ((volatile unsigned long *)SPORT0_TX) #define pSPORT0_RX32 ((volatile unsigned lon

  32. Slide 32: Special Case Code

    Slide 32: Special Case Code

    Special Case Code //---------------------------------------------------------------------------------------------------------- // // Function: Init_SPORT // // // // Description: This function initializes SPORT0 for 16-bit data // //-------------------------------------------------------------------

  33. Slide 33: Creating Efficient C Code for Blackfin

    Slide 33: Creating Efficient C Code for Blackfin

    Creating Efficient C Code for Blackfin 33

  34. Slide 34: Optimizing C Code

    Slide 34: Optimizing C Code

    Optimizing C Code ‹ Optimization Can Decrease Code Size or Lead to Faster Execution z Controlled Globally by Optimization Switch or Compiler Tab of Project Options no switch optimization disabled -O optimization for speed enabled -Os optimization for size enabled -Ov num enable speed vs size optimiz

  35. Slide 35: General Optimization Guidelines

    Slide 35: General Optimization Guidelines

    General Optimization Guidelines ‹ Native Data Types Are Optimal ‹ Try to Avoid Division ‹ Take Advantage of Memory Architecture z Internal vs External z Cache z DMA ‹ C-Libraries Are Already Optimized!! 35

  36. Slide 36: Ogg Vorbis Tremor Example

    Slide 36: Ogg Vorbis Tremor Example

    The World Leader in High Performance Signal Processing Solutions Ogg Vorbis Tremor Example

  37. Slide 37: What Is Ogg Vorbis Tremor?

    Slide 37: What Is Ogg Vorbis Tremor?

    What Is Ogg Vorbis Tremor? ‹ Flash-Based Ogg Vorbis Decoder with an Audio DAC Interface ‹ Ogg Vorbis1 is an Audio Compression Format z Fully Open z Patent- and Royalty-Free ‹ Tremor Is A Free Ogg Vorbis Decoder Implementation z Fixed-Point (Integer Arithmetic Only) 37 1 www.xiph.org

  38. Slide 38: Ogg Vorbis Overview

    Slide 38: Ogg Vorbis Overview

    Ogg Vorbis Overview Focus of Example 38 source: http://oggonachip.sourceforge.net

  39. Slide 39: Simple Steps To Increase Efficiency

    Slide 39: Simple Steps To Increase Efficiency

    Simple Steps To Increase Efficiency ‹ Optimizer Enables Compiler to Generate More Efficient Code z Performs Basic C Optimization Analysis z Produces ASM Code that Takes Advantage of Blackfin Architecture ‹ Multi-Issue Instructions ‹ Hardware Loops ‹ Pipeline Considerations ‹ Instruction Cache Consid

  40. Slide 40: Compiler Optimization Strategies

    Slide 40: Compiler Optimization Strategies

    Compiler Optimization Strategies ‹ Reference Code Based On Host File I/O z Compiles Out-of-the-Box z Replace File I/O With Flash I/O ‹ Benchmark On Simulator and/or BF537 EZ-KIT Lite ‹ Computation Cycles vs. Data Access Cycles z Decrease Computation Cycles Now z Optimize Memory Later ‹ Profile for H

  41. Slide 41: Optimizing for Execution Speed

    Slide 41: Optimizing for Execution Speed

    Optimizing for Execution Speed Assembly Optimization 100.00% Turn on Optimization 90.00% let compiler optimize 80.00% 70.00% 60.00% 50.00% Enable Cache exploit architecture features 40.00% 30.00% efficient memory layout 20.00% use specialized instructions 10.00% streamline 0.00% data flow 0 1 2 3 4

  42. Slide 42: Conclusion

    Slide 42: Conclusion

    Conclusion ‹ Walked Through Software Development Process ‹ Described How To Use The Linker to Help With Optimization ‹ Demonstrated Simple 2-Step Process for Significant Performance Increase 42

  43. Slide 43: For Additional Information

    Slide 43: For Additional Information

    For Additional Information ‹ For VisualDSP++ : http://www.analog.com/processors/resources/crosscore or Analog Devices : http://www.analog.com ‹ Embedding Ogg Vorbis: http://oggonachip.sourceforge.net or Ogg Vorbis Itself : http://www.xiph.com Or Click the “Ask A Question” Button 43

Source: Internet Archive copy of analog.com

More decks from Analog Devices, Inc.

All 53 Analog Devices decks