SlideShare a Scribd company logo
1 of 43
Download to read offline
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
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
Software Build Process in
          VisualDSP++




3
Porting C Code to Blackfin

Ported C Code Will Build and Execute Out-of-Box

    Code Can Be Large and Slow
     If Code Is Too Large to Fit in Internal Memory…
      It Spills Into External Memory
      Fetching from External Memory Is Slower
     Optimization Switches Are Off
      Generates Unoptimized Functional Code
      Includes Debug Information

    Default Clock Settings Used

    Cache Is Off


4
Software Development Flow
  What Files Are Involved?

                                         3rd Party
                                          3rd 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 Code
                                                                Boot Code
                                                                               Boot Image
          C Run-Time
          C Run-Time                   Linker                    (.DXE)
                                                                  (.DXE)         (.LDR)
            Header
             Header                 Description
          (basiccrt.s)
           (basiccrt.s)             File (.LDF)
 5
C Run-Time Header (basiccrt.s)

                          Sets Up C Run-Time
                          (CRT) Environment
                           Sets Up Stack Pointer
                           Enables Cycle Counters
                           for Benchmarking Code
                           Configures Cache, If
                           Requested
                           Change Clock/Voltage
                           Settings, If Requested

                          Can Be Modified
                          Through Project
                          Options Window



6
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
                                          Object Section = stack

       foo ++;                            _j   : 12
    }                                     _k : 0
                                          _var1: 1



7
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
            cplb_data          Data Cache Config Tables




8
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       // bar ASM code



                                                      Object Section = stack
       Note: The section( ) directive is used to
     place data or code into a section other than
      the default section used by the compiler.
                                                       _foovar: 1



9
Other Convenient Input Section Names

     sdram0
      Code/Data to be Explicitly Placed in External Memory

     L1_code
      Code to be Mapped Directly into On-Chip Program Memory

     L1_data_a; L1_data_b
      Data to be Mapped Directly into On-Chip Data Memory (Banks A
      and B, Respectively)




10
Software Development Flow
  Step 2 - Linking

                                        3rd Party
                                         3rd 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 Code
                                                               Boot Code
                                                                              Boot Image
                                      Linker                    (.DXE)
                                                                 (.DXE)         (.LDR)
                                   Description
                                   File (.LDF)
 11
VisualDSP++ Linker
     Inputs
      Compiled/Assembled Code Object Files (DOJ)
      Linker Description File (LDF)
      Compiled Libraries (3rd Party or Other)

     Outputs A Fully Resolved Blackfin Executable File (DXE)
      Can Be Run In Simulator
      Can Be Loaded Onto Target Via Emulator or Debug Monitor

     LDF Defines the Hardware System for VisualDSP++
      Specifies Processor Being Used
      Specifies All Available Internal/External System Memory
       If It’s Not Specified, the Linker Cannot Use It!!
       User Assigns Code/Data to Available Memory

12
Blackfin Memory
     Blackfin Processors Have Highly Efficient Memory
     Architecture

     Memory Supported by A Hierarchical Memory Scheme
      On-Chip Level 1 Memory – L1
      On-Chip Level 2 Memory – L2 (BF535 and BF561)
      Off-Chip Memory – SDRAM/SRAM

     Each Type of Memory Has Its Own Address Range

     Memory Accesses Automated by Processor




13
Explanation of Linker
     Description File (LDF)




14
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
                        OBJECT SEGMENT
                       OBJECT SECTION
     OBJECT SECTION     OBJECT SEGMENT
                                                    OUTPUT
             OBJECT SEGMENT
     OBJECT SECTION    OBJECT SECTION               SECTION
            OBJECT SEGMENT
                      OBJECT SECTION

            OBJECT SEGMENT
                      OBJECT SECTION
                                                    OUTPUT

             OBJECT SECTION               LDF       SECTION

             OBJECT SECTION




15
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
      Every Project MUST Include an LDF
      Default LDF Chosen By Linker if None Specified

     User Sets the Target:
      ARCHITECTURE()

     User Defines the Memory Layout:
      MEMORY{}




16
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_DSPBlackfinlib)
$OBJECTS = $COMMAND_LINE_OBJECTS;                            Global Commands


MEMORY
{
  MEM_L1_DATA_A              { TYPE(RAM) START(0xFF800000) END(0xFF803FFF) WIDTH(8) }
  MEM_L1_DATA_B              { TYPE(RAM) START(0xFF902000) END(0xFF907FFF) WIDTH(8) }
  MEM_L1_CODE                { TYPE(RAM) START(0xFFA00000) END(0xFFA0BFFF) WIDTH(8) }
  MEM_SDRAM0                 { TYPE(RAM) START(0x00000004) END(0x1FFFFFFF) WIDTH(8) }
}
                                               Start Address        End Address
        Memory Segment                                            (User-Specified)
                                              (User-Specified)
      (User-Assigned Name)
 17
LDF Expresses How Program Is Mapped (2)
     User Describes Where in Memory to Place Input Sections:
      PROCESSOR{
        SECTIONS{
             … INPUT_SECTIONS()…
        }
      }

      INPUT_SECTIONS() Describes What Contents from Input Files Are
      to be Mapped into the Current Output Section
               INPUT_SECTIONS{ file_source ( input_labels ) }
        file_source - List of Files or LDF Macro that Expands into a File List
        input_labels - List of Section Names
        Example:
               INPUT_SECTIONS{ main.doj (program) }
       Maps All Code in “program” Section from main.doj File

18
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
              { INPUT_SECTIONS( $OBJECTS(L1_data_b) ) } > MEM_L1_DATA_B

              sec_prog
              { INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_L1_CODE

              sec_sdram
              { INPUT_SECTIONS( $OBJECTS(data1) )
                INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_SDRAM0
         }
     }
19
Using Macros

     $OBJECTS = CRT, $COMMAND_LINE_OBJECTS
      CRT Is the C Run-Time Object File basiccrt.doj
      $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_SECTIONS( $OBJECTS(program) )
     } > MEM_L1_CODE




20
How Does The Linker Work?

     Object Sections Can Be Mapped to Many Memory Segments

     SECTIONS Parsed Left-to-Right and Top-to-Bottom
      If Object Section Fits, It Goes Into the Memory Segment
      If It Doesn’t Fit, Linker Proceeds to…
        Put It Off To Side Until Next Executable Section Is Processed
        Check Next Item(s) On Line For Object Sections That WILL Fit
        Check Next Line(s) For Object Sections That WILL Fit
      When All Executable Sections Have Been Processed, A Linker
      Error Is Generated If Any Object Sections Have Gone Unmapped




21
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_data_a
        { INPUT_SECTIONS( main.doj(data1) file2.doj(data1) ) } > MEM_L1_DATA_A
        sec_prog
        { INPUT_SECTIONS( main.doj(program) file2.doj(program) ) } > MEM_L1_CODE
        sec_sdram
        { INPUT_SECTIONS( main.doj(data1) file2.doj(data1) )
          INPUT_SECTIONS( main.doj(program) file2.doj(program) ) } > MEM_SDRAM0


22
Optimizing Using the Linker/LDF
     For Size, Use “Eliminate Unused Objects” Feature

     For Performance
      Move Frequently Used Program/Data into Internal Memory
              section(“L1_code”) void myFunction (void);
              section(“L1_data_a”) char myArray[256];

      Place Data into Different Banks to Avoid Access Conflicts
              section(“L1_data_a”) short vector_mult_1[256];
              section(“L1_data_b”) short vector_mult_2[256];

      Create Special Section Name and Map It Directly
              sec_prog
              { INPUT_SECTIONS( main.doj(Map1st) ) } > MEM_L1_CODE

      Create Special Macro List to Prioritize Input Files
                 $MY_L1_OBJECTS = file3.doj, file5.doj, file106.doj

23
Expert Linker




24
Expert Linker
     Presents Graphical Interface for Manipulating LDF Files

     Resize Memory by Grab/Stretch
      Enlarge One Memory Segment at Expense of Another

     Map Sections with Drag/Drop

     Displays Run-Time Information
      Watermarks for Stack/Heap

     Simply Changing a Text File; Makes Changes Locally, Not
     Globally
      Changes Made with Text Editor Will Be Reflected in Expert Linker
      Changes Made with Expert Linker Will Show Up in Text Editor

25
Create an LDF with Expert Linker




     Proceed Through Dialog, Selecting:
      LDF Name
      Language (C, C++, or ASM)

     Template LDF Files Are in ldf Installation Directory
             C:Program FilesVisualDSP++ 4.0Blackfinldf

      Named with _ASM, _C, _CPP Suffixes
             i.e., ADSP-BF537_C.ldf
26
Programming Blackfin
        Processors In C




27
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
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)                            */
 #define      EMAC_STAADD            0xFFC03014            /* Station Management Address             */

 /* EMAC_STAADD Masks                                                                                */
 #define   STABUSY                 0x00000001   /* Initiate Station Mgt Reg Access / STA Busy Stat   */
 #define   STAOP                   0x00000002   /* Station Management Operation Code (Write/Read*)   */
 #define   STADISPRE               0x00000004   /* Disable Preamble Generation                       */
 #define   STAIE                   0x00000008   /* Station Mgt. Transfer Done Interrupt Enable       */
 #define   REGAD                   0x000007C0   /* STA Register Address                              */
 #define   PHYAD                   0x0000F800   /* PHY Device Address                                */

 #define    SET_REGAD(x)           (((x)&0x1F)<< 6 )        /* Set STA Register Address              */
 #define    SET_PHYAD(x)           (((x)&0x1F)<< 11 )       /* Set PHY Device Address                */




     Associates MMR Names to Their Physical Addresses in Memory
     Defines All Bits in MMRs by Name to Be Used in More Legible Code
     Sets Up Useful Macros to Perform Common Tasks
     Located in C:Program FilesVisualDSP++ 4.0Blackfininclude

29
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_STAADD          ((volatile unsigned long *)EMAC_STAADD)


#include <cdefBF537.h>
main ( )
{
   *pEMAC_STAADD |= SET_PHYAD(0x15);     /* Set PHY Device Address to 0x15 */
}


     The cdef Headers Define Convenient Macros for MMR Access
     Using *p Pointer Notation, Each MMR Will Be Properly
     Accessed
     System Services and Device Drivers Care for This
     Automatically
30
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 long *)SPORT0_RX)
         #define pSPORT0_TX16   ((volatile unsigned short *)SPORT0_TX)
         #define pSPORT0_RX16   ((volatile unsigned short *)SPORT0_RX)

         /* SPORT1 Controller   (0xFFC00900 - 0xFFC009FF)        */
         #define pSPORT1_TX     ((volatile unsigned long *)SPORT1_TX)
         #define pSPORT1_RX     ((volatile unsigned long *)SPORT1_RX)
         #define pSPORT1_TX32   ((volatile unsigned long *)SPORT1_TX)
         #define pSPORT1_RX32   ((volatile unsigned long *)SPORT1_RX)
         #define pSPORT1_TX16   ((volatile unsigned short *)SPORT1_TX)
         #define pSPORT1_RX16   ((volatile unsigned short *)SPORT1_RX)


     SPORTx Data Registers Are the Only MMRs that Can Be Both
     16- and 32-bit, Depending on Hardware Configuration
     Using the Wrong Macro Results in Non-Functional SPORT
     Code
     Again, Device Drivers Care for This Automatically
31
Special Case Code
//----------------------------------------------------------------------------------------------------------   //
// Function:                   Init_SPORT                                                                      //
//                                                                                                             //
// Description:                This function initializes SPORT0 for 16-bit data                                //
//----------------------------------------------------------------------------------------------------------   //

#include<cdefBF537.h>

void Init_SPORT(void)
{
           *pSPORT0_TCR2                      = SLEN(15);                     // Configure SPORT0 for 16-bit data
           *pSPORT0_TX16                      = 0xAA55;                       // Use 16-bit Access Macro to Write Register
           *pSPORT0_TCR1                      |= TSPEN;                       // Enable SPORT0 Transmitter

               while(1)
               {
                 while(!(*pSPORT0_STAT & TXHRE));                             // wait for hold register to empty
                   *pSPORT0_TX32 = 0xAA55;                                    // INCORRECT: Using 32-bit Access Macro
                   *pSPORT0_TX   = 0xAA55;                                    // INCORRECT: Using 32-bit Access Macro

                   *pSPORT0_TX16 = 0xAA55;                                    // CORRECT: Using 16-bit Access Macro
               }
}

32
Creating Efficient C Code
            for Blackfin




33
Optimizing C Code
     Optimization Can Decrease Code Size or Lead to Faster Execution
      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 optimization (sliding scale)

      Controlled Dynamically In C Source Code Using Pragmas
      #pragma optimize_off                 - Disables Optimizer
      #pragma optimize_for_space           - Decreases Code Size
      #pragma optimize_for_speed           - Increases Performance
      #pragma optimize_as_cmd_line         - Restore optimization per command line options

      Many More Pragmas Available, These Are the Most Commonly Used

      Controlled Locally On Per-File Basis




34
General Optimization Guidelines

     Native Data Types Are Optimal

     Try to Avoid Division

     Take Advantage of Memory Architecture
     Internal vs External
     Cache
     DMA

     C-Libraries Are Already Optimized!!



35
The World Leader in High Performance Signal Processing Solutions




Ogg Vorbis Tremor Example
What Is Ogg Vorbis Tremor?

          Flash-Based Ogg Vorbis Decoder with an Audio DAC Interface

          Ogg Vorbis1 is an Audio Compression Format
           Fully Open
           Patent- and Royalty-Free

          Tremor Is A Free Ogg Vorbis Decoder Implementation
           Fixed-Point (Integer Arithmetic Only)




37   1   www.xiph.org
Ogg Vorbis Overview




                                                    Focus of
                                                    Example




38      source: http://oggonachip.sourceforge.net
Simple Steps To Increase Efficiency

     Optimizer Enables Compiler to Generate More Efficient Code
      Performs Basic C Optimization Analysis
      Produces ASM Code that Takes Advantage of Blackfin
      Architecture
       Multi-Issue Instructions
       Hardware Loops
       Pipeline Considerations

     Instruction Cache Considerably Increases Performance




39
Compiler Optimization Strategies
     Reference Code Based On Host File I/O
      Compiles Out-of-the-Box
      Replace File I/O With Flash I/O

     Benchmark On Simulator and/or BF537 EZ-KIT Lite

     Computation Cycles vs. Data Access Cycles
      Decrease Computation Cycles Now
      Optimize Memory Later

     Profile for Hotspots
      80/20 Rule
      Loops Important

     Global Compiler Settings
      Optimize for Speed
      Automatic Inlining




40
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         5          6            7          8          9
                                                Optimization Steps


41
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
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

More Related Content

What's hot

06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friendAlexandre Moneger
 
LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723Iftach Ian Amit
 
Dynamic Analysis (EVO 2008)
Dynamic Analysis (EVO 2008)Dynamic Analysis (EVO 2008)
Dynamic Analysis (EVO 2008)Tudor Girba
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...André Oriani
 
Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingPositive Hack Days
 
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHackito Ergo Sum
 
Unit 5 quesn b ans5
Unit 5 quesn b ans5Unit 5 quesn b ans5
Unit 5 quesn b ans5Sowri Rajan
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modellingVandanaPagar1
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationEelco Visser
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipelineGirish Ghate
 
Using Python3 to Build a Cloud Computing Service for my Superboard II
Using Python3 to Build a Cloud Computing Service for my Superboard IIUsing Python3 to Build a Cloud Computing Service for my Superboard II
Using Python3 to Build a Cloud Computing Service for my Superboard IIDavid Beazley (Dabeaz LLC)
 

What's hot (20)

06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friend
 
Assembler
AssemblerAssembler
Assembler
 
LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723LD_PRELOAD Exploitation - DC9723
LD_PRELOAD Exploitation - DC9723
 
Assembler
AssemblerAssembler
Assembler
 
Dynamic Analysis (EVO 2008)
Dynamic Analysis (EVO 2008)Dynamic Analysis (EVO 2008)
Dynamic Analysis (EVO 2008)
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...
 
Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash Cracking
 
Assembler
AssemblerAssembler
Assembler
 
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARFHES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
HES2011 - James Oakley and Sergey bratus-Exploiting-the-Hard-Working-DWARF
 
Alp 05
Alp 05Alp 05
Alp 05
 
Unit 5 quesn b ans5
Unit 5 quesn b ans5Unit 5 quesn b ans5
Unit 5 quesn b ans5
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
Chtp414
Chtp414Chtp414
Chtp414
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
Dynamic Linker
Dynamic LinkerDynamic Linker
Dynamic Linker
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipeline
 
Using Python3 to Build a Cloud Computing Service for my Superboard II
Using Python3 to Build a Cloud Computing Service for my Superboard IIUsing Python3 to Build a Cloud Computing Service for my Superboard II
Using Python3 to Build a Cloud Computing Service for my Superboard II
 

Similar to Basics of building a blackfin application

0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdfKhaledIbrahim10923
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel ToolsXavier Hallade
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeDmitri Nesteruk
 
Os7 2
Os7 2Os7 2
Os7 2issbp
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)Simen Li
 
Madeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareMadeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareESUG
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building BlocksMax Kleiner
 
Build process in ST Visual Develop
Build process in ST Visual DevelopBuild process in ST Visual Develop
Build process in ST Visual DevelopGourav Kumar
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
ARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdfARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdfhakilic1
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkAlexey Smirnov
 
EclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soupEclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soupBruce Griffith
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsJan Aerts
 

Similar to Basics of building a blackfin application (20)

0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel Tools
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
Os7 2
Os7 2Os7 2
Os7 2
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (3)
 
Madeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareMadeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable Hardware
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 
Build process in ST Visual Develop
Build process in ST Visual DevelopBuild process in ST Visual Develop
Build process in ST Visual Develop
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
ARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdfARM Embeded_Firmware.pdf
ARM Embeded_Firmware.pdf
 
DSP/Bios
DSP/BiosDSP/Bios
DSP/Bios
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
EclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soupEclipseCon 2011: Deciphering the CDT debugger alphabet soup
EclipseCon 2011: Deciphering the CDT debugger alphabet soup
 
Intro dotnet
Intro dotnetIntro dotnet
Intro dotnet
 
Embedded C.pptx
Embedded C.pptxEmbedded C.pptx
Embedded C.pptx
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 
01 dll basics
01 dll basics01 dll basics
01 dll basics
 

More from Pantech ProLabs India Pvt Ltd

Choosing the right processor for embedded system design
Choosing the right processor for embedded system designChoosing the right processor for embedded system design
Choosing the right processor for embedded system designPantech ProLabs India Pvt Ltd
 

More from Pantech ProLabs India Pvt Ltd (20)

Registration process
Registration processRegistration process
Registration process
 
Choosing the right processor for embedded system design
Choosing the right processor for embedded system designChoosing the right processor for embedded system design
Choosing the right processor for embedded system design
 
Brain Computer Interface
Brain Computer InterfaceBrain Computer Interface
Brain Computer Interface
 
Electric Vehicle Design using Matlab
Electric Vehicle Design using MatlabElectric Vehicle Design using Matlab
Electric Vehicle Design using Matlab
 
Image processing application
Image processing applicationImage processing application
Image processing application
 
Internet of Things using Raspberry Pi
Internet of Things using Raspberry PiInternet of Things using Raspberry Pi
Internet of Things using Raspberry Pi
 
Internet of Things Using Arduino
Internet of Things Using ArduinoInternet of Things Using Arduino
Internet of Things Using Arduino
 
Brain controlled robot
Brain controlled robotBrain controlled robot
Brain controlled robot
 
Brain Computer Interface-Webinar
Brain Computer Interface-WebinarBrain Computer Interface-Webinar
Brain Computer Interface-Webinar
 
Development of Deep Learning Architecture
Development of Deep Learning ArchitectureDevelopment of Deep Learning Architecture
Development of Deep Learning Architecture
 
Future of AI
Future of AIFuture of AI
Future of AI
 
Gate driver design and inductance fabrication
Gate driver design and inductance fabricationGate driver design and inductance fabrication
Gate driver design and inductance fabrication
 
Brainsense -Brain computer Interface
Brainsense -Brain computer InterfaceBrainsense -Brain computer Interface
Brainsense -Brain computer Interface
 
Median filter Implementation using TMS320C6745
Median filter Implementation using TMS320C6745Median filter Implementation using TMS320C6745
Median filter Implementation using TMS320C6745
 
Introduction to Code Composer Studio 4
Introduction to Code Composer Studio 4Introduction to Code Composer Studio 4
Introduction to Code Composer Studio 4
 
Waveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSPWaveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSP
 
Interfacing UART with tms320C6745
Interfacing UART with tms320C6745Interfacing UART with tms320C6745
Interfacing UART with tms320C6745
 
Switch & LED using TMS320C6745 DSP
Switch & LED using TMS320C6745 DSPSwitch & LED using TMS320C6745 DSP
Switch & LED using TMS320C6745 DSP
 
Led blinking using TMS320C6745
Led blinking using TMS320C6745Led blinking using TMS320C6745
Led blinking using TMS320C6745
 
Introduction to tms320c6745 dsp
Introduction to tms320c6745 dspIntroduction to tms320c6745 dsp
Introduction to tms320c6745 dsp
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 

Basics of building a blackfin application

  • 1. 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. 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. Software Build Process in VisualDSP++ 3
  • 4. Porting C Code to Blackfin Ported C Code Will Build and Execute Out-of-Box Code Can Be Large and Slow If Code Is Too Large to Fit in Internal Memory… It Spills Into External Memory Fetching from External Memory Is Slower Optimization Switches Are Off Generates Unoptimized Functional Code Includes Debug Information Default Clock Settings Used Cache Is Off 4
  • 5. Software Development Flow What Files Are Involved? 3rd Party 3rd 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 Code Boot Code Boot Image C Run-Time C Run-Time Linker (.DXE) (.DXE) (.LDR) Header Header Description (basiccrt.s) (basiccrt.s) File (.LDF) 5
  • 6. C Run-Time Header (basiccrt.s) Sets Up C Run-Time (CRT) Environment Sets Up Stack Pointer Enables Cycle Counters for Benchmarking Code Configures Cache, If Requested Change Clock/Voltage Settings, If Requested Can Be Modified Through Project Options Window 6
  • 7. 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 Object Section = stack foo ++; _j : 12 } _k : 0 _var1: 1 7
  • 8. 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 cplb_data Data Cache Config Tables 8
  • 9. 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 // bar ASM code Object Section = stack Note: The section( ) directive is used to place data or code into a section other than the default section used by the compiler. _foovar: 1 9
  • 10. Other Convenient Input Section Names sdram0 Code/Data to be Explicitly Placed in External Memory L1_code Code to be Mapped Directly into On-Chip Program Memory L1_data_a; L1_data_b Data to be Mapped Directly into On-Chip Data Memory (Banks A and B, Respectively) 10
  • 11. Software Development Flow Step 2 - Linking 3rd Party 3rd 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 Code Boot Code Boot Image Linker (.DXE) (.DXE) (.LDR) Description File (.LDF) 11
  • 12. VisualDSP++ Linker Inputs Compiled/Assembled Code Object Files (DOJ) Linker Description File (LDF) Compiled Libraries (3rd Party or Other) Outputs A Fully Resolved Blackfin Executable File (DXE) Can Be Run In Simulator Can Be Loaded Onto Target Via Emulator or Debug Monitor LDF Defines the Hardware System for VisualDSP++ Specifies Processor Being Used Specifies All Available Internal/External System Memory If It’s Not Specified, the Linker Cannot Use It!! User Assigns Code/Data to Available Memory 12
  • 13. Blackfin Memory Blackfin Processors Have Highly Efficient Memory Architecture Memory Supported by A Hierarchical Memory Scheme On-Chip Level 1 Memory – L1 On-Chip Level 2 Memory – L2 (BF535 and BF561) Off-Chip Memory – SDRAM/SRAM Each Type of Memory Has Its Own Address Range Memory Accesses Automated by Processor 13
  • 14. Explanation of Linker Description File (LDF) 14
  • 15. 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 OBJECT SEGMENT OBJECT SECTION OBJECT SECTION OBJECT SEGMENT OUTPUT OBJECT SEGMENT OBJECT SECTION OBJECT SECTION SECTION OBJECT SEGMENT OBJECT SECTION OBJECT SEGMENT OBJECT SECTION OUTPUT OBJECT SECTION LDF SECTION OBJECT SECTION 15
  • 16. 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 Every Project MUST Include an LDF Default LDF Chosen By Linker if None Specified User Sets the Target: ARCHITECTURE() User Defines the Memory Layout: MEMORY{} 16
  • 17. 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_DSPBlackfinlib) $OBJECTS = $COMMAND_LINE_OBJECTS; Global Commands MEMORY { MEM_L1_DATA_A { TYPE(RAM) START(0xFF800000) END(0xFF803FFF) WIDTH(8) } MEM_L1_DATA_B { TYPE(RAM) START(0xFF902000) END(0xFF907FFF) WIDTH(8) } MEM_L1_CODE { TYPE(RAM) START(0xFFA00000) END(0xFFA0BFFF) WIDTH(8) } MEM_SDRAM0 { TYPE(RAM) START(0x00000004) END(0x1FFFFFFF) WIDTH(8) } } Start Address End Address Memory Segment (User-Specified) (User-Specified) (User-Assigned Name) 17
  • 18. LDF Expresses How Program Is Mapped (2) User Describes Where in Memory to Place Input Sections: PROCESSOR{ SECTIONS{ … INPUT_SECTIONS()… } } INPUT_SECTIONS() Describes What Contents from Input Files Are to be Mapped into the Current Output Section INPUT_SECTIONS{ file_source ( input_labels ) } file_source - List of Files or LDF Macro that Expands into a File List input_labels - List of Section Names Example: INPUT_SECTIONS{ main.doj (program) } Maps All Code in “program” Section from main.doj File 18
  • 19. 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 { INPUT_SECTIONS( $OBJECTS(L1_data_b) ) } > MEM_L1_DATA_B sec_prog { INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_L1_CODE sec_sdram { INPUT_SECTIONS( $OBJECTS(data1) ) INPUT_SECTIONS( $OBJECTS(program) ) } > MEM_SDRAM0 } } 19
  • 20. Using Macros $OBJECTS = CRT, $COMMAND_LINE_OBJECTS CRT Is the C Run-Time Object File basiccrt.doj $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_SECTIONS( $OBJECTS(program) ) } > MEM_L1_CODE 20
  • 21. How Does The Linker Work? Object Sections Can Be Mapped to Many Memory Segments SECTIONS Parsed Left-to-Right and Top-to-Bottom If Object Section Fits, It Goes Into the Memory Segment If It Doesn’t Fit, Linker Proceeds to… Put It Off To Side Until Next Executable Section Is Processed Check Next Item(s) On Line For Object Sections That WILL Fit Check Next Line(s) For Object Sections That WILL Fit When All Executable Sections Have Been Processed, A Linker Error Is Generated If Any Object Sections Have Gone Unmapped 21
  • 22. 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_data_a { INPUT_SECTIONS( main.doj(data1) file2.doj(data1) ) } > MEM_L1_DATA_A sec_prog { INPUT_SECTIONS( main.doj(program) file2.doj(program) ) } > MEM_L1_CODE sec_sdram { INPUT_SECTIONS( main.doj(data1) file2.doj(data1) ) INPUT_SECTIONS( main.doj(program) file2.doj(program) ) } > MEM_SDRAM0 22
  • 23. Optimizing Using the Linker/LDF For Size, Use “Eliminate Unused Objects” Feature For Performance Move Frequently Used Program/Data into Internal Memory section(“L1_code”) void myFunction (void); section(“L1_data_a”) char myArray[256]; Place Data into Different Banks to Avoid Access Conflicts section(“L1_data_a”) short vector_mult_1[256]; section(“L1_data_b”) short vector_mult_2[256]; Create Special Section Name and Map It Directly sec_prog { INPUT_SECTIONS( main.doj(Map1st) ) } > MEM_L1_CODE Create Special Macro List to Prioritize Input Files $MY_L1_OBJECTS = file3.doj, file5.doj, file106.doj 23
  • 25. Expert Linker Presents Graphical Interface for Manipulating LDF Files Resize Memory by Grab/Stretch Enlarge One Memory Segment at Expense of Another Map Sections with Drag/Drop Displays Run-Time Information Watermarks for Stack/Heap Simply Changing a Text File; Makes Changes Locally, Not Globally Changes Made with Text Editor Will Be Reflected in Expert Linker Changes Made with Expert Linker Will Show Up in Text Editor 25
  • 26. Create an LDF with Expert Linker Proceed Through Dialog, Selecting: LDF Name Language (C, C++, or ASM) Template LDF Files Are in ldf Installation Directory C:Program FilesVisualDSP++ 4.0Blackfinldf Named with _ASM, _C, _CPP Suffixes i.e., ADSP-BF537_C.ldf 26
  • 27. Programming Blackfin Processors In C 27
  • 28. 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. 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) */ #define EMAC_STAADD 0xFFC03014 /* Station Management Address */ /* EMAC_STAADD Masks */ #define STABUSY 0x00000001 /* Initiate Station Mgt Reg Access / STA Busy Stat */ #define STAOP 0x00000002 /* Station Management Operation Code (Write/Read*) */ #define STADISPRE 0x00000004 /* Disable Preamble Generation */ #define STAIE 0x00000008 /* Station Mgt. Transfer Done Interrupt Enable */ #define REGAD 0x000007C0 /* STA Register Address */ #define PHYAD 0x0000F800 /* PHY Device Address */ #define SET_REGAD(x) (((x)&0x1F)<< 6 ) /* Set STA Register Address */ #define SET_PHYAD(x) (((x)&0x1F)<< 11 ) /* Set PHY Device Address */ Associates MMR Names to Their Physical Addresses in Memory Defines All Bits in MMRs by Name to Be Used in More Legible Code Sets Up Useful Macros to Perform Common Tasks Located in C:Program FilesVisualDSP++ 4.0Blackfininclude 29
  • 30. 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_STAADD ((volatile unsigned long *)EMAC_STAADD) #include <cdefBF537.h> main ( ) { *pEMAC_STAADD |= SET_PHYAD(0x15); /* Set PHY Device Address to 0x15 */ } The cdef Headers Define Convenient Macros for MMR Access Using *p Pointer Notation, Each MMR Will Be Properly Accessed System Services and Device Drivers Care for This Automatically 30
  • 31. 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 long *)SPORT0_RX) #define pSPORT0_TX16 ((volatile unsigned short *)SPORT0_TX) #define pSPORT0_RX16 ((volatile unsigned short *)SPORT0_RX) /* SPORT1 Controller (0xFFC00900 - 0xFFC009FF) */ #define pSPORT1_TX ((volatile unsigned long *)SPORT1_TX) #define pSPORT1_RX ((volatile unsigned long *)SPORT1_RX) #define pSPORT1_TX32 ((volatile unsigned long *)SPORT1_TX) #define pSPORT1_RX32 ((volatile unsigned long *)SPORT1_RX) #define pSPORT1_TX16 ((volatile unsigned short *)SPORT1_TX) #define pSPORT1_RX16 ((volatile unsigned short *)SPORT1_RX) SPORTx Data Registers Are the Only MMRs that Can Be Both 16- and 32-bit, Depending on Hardware Configuration Using the Wrong Macro Results in Non-Functional SPORT Code Again, Device Drivers Care for This Automatically 31
  • 32. Special Case Code //---------------------------------------------------------------------------------------------------------- // // Function: Init_SPORT // // // // Description: This function initializes SPORT0 for 16-bit data // //---------------------------------------------------------------------------------------------------------- // #include<cdefBF537.h> void Init_SPORT(void) { *pSPORT0_TCR2 = SLEN(15); // Configure SPORT0 for 16-bit data *pSPORT0_TX16 = 0xAA55; // Use 16-bit Access Macro to Write Register *pSPORT0_TCR1 |= TSPEN; // Enable SPORT0 Transmitter while(1) { while(!(*pSPORT0_STAT & TXHRE)); // wait for hold register to empty *pSPORT0_TX32 = 0xAA55; // INCORRECT: Using 32-bit Access Macro *pSPORT0_TX = 0xAA55; // INCORRECT: Using 32-bit Access Macro *pSPORT0_TX16 = 0xAA55; // CORRECT: Using 16-bit Access Macro } } 32
  • 33. Creating Efficient C Code for Blackfin 33
  • 34. Optimizing C Code Optimization Can Decrease Code Size or Lead to Faster Execution 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 optimization (sliding scale) Controlled Dynamically In C Source Code Using Pragmas #pragma optimize_off - Disables Optimizer #pragma optimize_for_space - Decreases Code Size #pragma optimize_for_speed - Increases Performance #pragma optimize_as_cmd_line - Restore optimization per command line options Many More Pragmas Available, These Are the Most Commonly Used Controlled Locally On Per-File Basis 34
  • 35. General Optimization Guidelines Native Data Types Are Optimal Try to Avoid Division Take Advantage of Memory Architecture Internal vs External Cache DMA C-Libraries Are Already Optimized!! 35
  • 36. The World Leader in High Performance Signal Processing Solutions Ogg Vorbis Tremor Example
  • 37. What Is Ogg Vorbis Tremor? Flash-Based Ogg Vorbis Decoder with an Audio DAC Interface Ogg Vorbis1 is an Audio Compression Format Fully Open Patent- and Royalty-Free Tremor Is A Free Ogg Vorbis Decoder Implementation Fixed-Point (Integer Arithmetic Only) 37 1 www.xiph.org
  • 38. Ogg Vorbis Overview Focus of Example 38 source: http://oggonachip.sourceforge.net
  • 39. Simple Steps To Increase Efficiency Optimizer Enables Compiler to Generate More Efficient Code Performs Basic C Optimization Analysis Produces ASM Code that Takes Advantage of Blackfin Architecture Multi-Issue Instructions Hardware Loops Pipeline Considerations Instruction Cache Considerably Increases Performance 39
  • 40. Compiler Optimization Strategies Reference Code Based On Host File I/O Compiles Out-of-the-Box Replace File I/O With Flash I/O Benchmark On Simulator and/or BF537 EZ-KIT Lite Computation Cycles vs. Data Access Cycles Decrease Computation Cycles Now Optimize Memory Later Profile for Hotspots 80/20 Rule Loops Important Global Compiler Settings Optimize for Speed Automatic Inlining 40
  • 41. 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 5 6 7 8 9 Optimization Steps 41
  • 42. 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. 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