Download presentation
Presentation is loading. Please wait.
Published byIra Woods Modified over 9 years ago
1
Microcomputer Systems 1 Introduction to Visual DSP++ Tools
2
25 August 2015Veton Këpuska2 Goals Introduction to Visual DSP++ and Tools Specific to Blackfin Information on how to analyze applications and fine tune them.
3
25 August 2015Veton Këpuska3 Outline The VisualDSP++ Tools Creating a Project Plotting Performance improvement using chip features Cache L1 Memory Voltage Regulator
4
25 August 2015Veton Këpuska4 Blackfin CROSSCORE Product Line VisualDSP++ development suite Performance-tuned C/C++ compiler Source language debugger RTOS kernel (VDK) Device drivers and system services Ethernet and USB 2.0 libraries Tuned DSP libraries Visual linker Code wizards Flash programmer Multicore code generation and debugging Plotting and other advanced code generation and debugging tools Automation API EZ-KIT Lite and Daughter cards ADSP-BF533 ADSP-BF535 ADSP-BF537 ADSP-BF561 A-V EZ-Extender Audio EZ-Extender USB-LAN EZ-Extender FPGA EZ-Extender JTAG Emulators USB 2.0 USB 1.1 PCI Background Telemetry
5
25 August 2015Veton Këpuska5 Additional Information ADSP-BF533 EZ-KIT Lite Manual Tools manuals provided in the On-line help Analog Devices web site: www.analog.comwww.analog.com Email Support: For tools questions: Processor.tools.support@analog.com Processor.tools.support@analog.com For processor questions: Processor.support@analog.com Processor.support@analog.com Licensing and Registration questions: Processor.tools.registration@analog.com Processor.tools.registration@analog.com Or click the “Ask A Question” button
6
25 August 2015Veton Këpuska6 DSP Project Development Stages Simulation Evaluation Emulation
7
25 August 2015Veton Këpuska7 Simulation Development Cycle begins in simulation environment VisualDSP++ with simulation target enables: Building Debugging
8
25 August 2015Veton Këpuska8 Evaluation EZ-KIT Lite evaluation system in the lab can be used to: Determine Processor Capabilities that best fit target application EZ-KIT Lite Board connected to the PC Development System via USB Port or JTAG interface This connection can be used for Evaluation as well as Emulation purposes (see next slide). Code download via USB Port is significantly slower than JTAG interface used for emulation.
9
25 August 2015Veton Këpuska9 Emulation Actual hardware (can be EZ-KIT Lite board) is connected via JTAG (Joint Test Action Group) emulator We have only 1 JTAG obtained from our entry to UML-ADI competition Emulator enables application software to be downloaded and debugged from within VisualDSP++ Emulation Software performs the communications that enables measurement of DSP performance and how current implementation affects it.
10
25 August 2015Veton Këpuska10 Development Tools VisualDSP++ version 4.5 (from Analog Devices) – version 5.0 will be installed soon. Vendors other than Analog Dev.: MULTI from Green Hills Software Open Source GCC tool chain and Clinux
11
25 August 2015Veton Këpuska11 VisualDSP++ Project Development and Debugging is integrated (IDDE). C/C++ Native Compiler Graphical Plotting Tools Statistical Profiling Cache Visualization Pipeline Viewer VisualDSP++ Kernel (VDK)
12
25 August 2015Veton Këpuska12 ADSP-BF533 EZ-KIT Lite Evaluation System Board
13
25 August 2015Veton Këpuska13 Evaluation Board EZ-KIT LITE Analog Devices ADSP-BF533 processor Performance up to 600 MHz 160-pin mini-BGA package The Ball Grid Array (BGA) is descended from the pin grid array (PGA), which is a package with one face covered (or partly covered) with pins in a grid pattern.pin grid arraygrid pattern 27 MHz CLKIN oscillator
14
25 August 2015Veton Këpuska14 Evaluation Board EZ-KIT LITE Synchronous dynamic random access memory (SDRAM) MT48LC32M16 - 64 MB (32M x 16 bits) Flash memories 2 MB (512K x 16 x 2chips) Analog audio interface AD1836 – Analog Devices 96 kHz 24-bit audio codec 4 input RCA phono jacks (2 channels) 6 output RCA phono jacks (3 channels) 2 MB (512K x 16 bits x 2chips) FLASH memory
15
25 August 2015Veton Këpuska15 Evaluation Board EZ-KIT LITE Analog video interface ADV7183 video decoder w/ 3 input RCA phono jacks ADV7171 video encoder w/ 3 output RCA phono jacks Universal asynchronous receiver/transmitter (UART) ADM3202 RS-232 line driver/receiver DB9 male connector LEDs 10 LEDs: 1 power (green), 1 board reset (red), 1 USB (red), 6 general purpose (amber), and 1 USB monitor (amber) Push buttons 5 push buttons with debounce logic: 1 reset, 4 programmable flags
16
25 August 2015Veton Këpuska16 Interfaces Expansion interface PPI, SPI, EBIU, Timers2-0, UART, programmable flags, SPORT0, SPORT1 Other features JTAG ICE 14-pin header USB-based debugger interface SPORT0 connector Evaluation suite of VisualDSP++
17
25 August 2015Veton Këpuska17 Evaluation Board (cont.) 10 LED’s: Power Board Reset USB Reset USB Monitor 6 general-purpose (programmable) 5 Push buttons 1 reset 4 programmable 3 90-pin connectors providing: Parallel Peripheral Interface (PPI) Synchronous Serial Port Interface (SPI) External Bus Interface Unit (EBIU) Timers 0-2 Universal Asynchronous Receiver-Transmitter (UART) Programmable Flags, High Speed Serial Ports (SPORT0 & 1)
18
Development Process on DSP VisualDSP++ Integrated Development & Debugging Environment
19
25 August 2015Veton Këpuska19 Development Process Source Files (.c &.asm) Compiler & Assembler Object Files (.doj) C Run-Time Header (basiccrt.s) Linker Description File (.ldf) Linker Executable File (.dxe) Debugger (In-Circuit Emulator, Simulator, or EX-KIT Lite)
20
25 August 2015Veton Këpuska20 Bootable Image Executable File (.dxe) Loader / Splitter Boot Code (.dxe) Boot Image (.ldr) Loader/ Writer Loader/ Writer EPROM Programmable Memory
21
25 August 2015Veton Këpuska21 Integrated Development & Debugging Environment of VisualDSP++
22
25 August 2015Veton Këpuska22 Code Development Tools C/C++ compiler Run-time library with over 100 math, DSP, and C run-time library routines Assembler Linker Splitter Loader Simulator Emulator (EZ-Kit Lite or custom hardware)
23
25 August 2015Veton Këpuska23 Connecting to Debugging Session Start -> All Programs -> … -> VisualDSP++ VisalDSP++ when launches for the first time it does not connect to any session (see next slide) Visual DSP++ can connect to a number of different debugging sessions:
24
25 August 2015Veton Këpuska24 Connecting to Debugging Session EZ-KIT Lite: Dedicated USB connection between the PC and EZ-KIT Lite. Simulator: Software model of the processor. No external hardware is required. Customized to the selected DSP processor: Pipelines Caches Several order of magnitude slower than actual hardware execution. Cycle-accurate simulation (detailed view of processor operations) Functional simulator (quick simulation at the expense of detail).
25
25 August 2015Veton Këpuska25 Connecting to Debugging Session Emulator: JTAG emulator ideal for connecting to hardware Maximal performance Maximal flexibility Emulator is required to connect to any non-EZ-KIT Lite hardware.
26
25 August 2015Veton Këpuska26 VisualDSP++ Startup Screen
27
25 August 2015Veton Këpuska27 Using VisualDSP++ VisualDSP++ includes basic Linker Description File (.ldf) for each processor type. For Blackfin Processors the default installation path is: Program Files\Analog Devices\VisualDSP 4.5\Blackfin\ldf The four Tutorial exercises will be covered in more detail in the LAB.
28
Exercise 1. Building and Running a C Program
29
25 August 2015Veton Këpuska29 Goals of this Exercise: Learn to: Start up the VisualDSP++ environment Open and build an existing project Examine windows and dialog boxes Run the program
30
25 August 2015Veton Këpuska30 Additional Information The source files for this exercise are in the dot_product_c folder. Default installation path: Program Files\Analog Devices\VisualDSP 4.5\Blackfin\Examples\Tutorial\dot_prod uct_c
31
25 August 2015Veton Këpuska31 Step 1: Start VisualDSP++ and Open a Project 1.Click the Windows Start button and select: Programs, Analog Devices, VisualDSP++ 4.5, and VisualDSP++ Environment. When you need to connect to a debug session, click the Connect to Target toolbar button or choose from the available sessions listed under Select Session in the Session menu. To create a debug session, select New Session from the Session menu. This will launch the Session Wizard, which is covered in more detail later. If you have already run VisualDSP++ and the Reload last project at startup option is selected on the Project page under Settings and Preferences, VisualDSP++ opens the last project that you worked on. To close this project, choose Close and then Project from the File menu, and then click No when prompted to save the project.
32
25 August 2015Veton Këpuska32 Step 1: Start VisualDSP++ and Open a Project 2.From the File menu, choose Open and then Project. VisualDSP++ displays the Open Project dialog box. 3.Copy content of dotprodc folder: Program Files\Analog Devices\VisualDSP4.5\Blackfin\Examples\ Tutorial\dotprodc This path is based on the default installation. To: u:\ece3551\lab1\ 4.In the Look in box, open the folder u:\ece3551\lab1\
33
25 August 2015Veton Këpuska33 Step 1: Start VisualDSP++ and Open a Project 5.Double-click the dotprodc project (.dpj ) file. VisualDSP++ loads the project in the Project window, as shown
34
25 August 2015Veton Këpuska34 Step 1: Start VisualDSP++ and Open a Project 6.From the Settings menu, choose Preferences to open the Preferences dialog box, as shown
35
25 August 2015Veton Këpuska35 Step 1: Start VisualDSP++ and Open a Project 7.On the General page, under General Preferences, ensure that the following options are selected. Run to main after load Load executable after build 8.Click OK to close the Preferences dialog box. The VisualDSP++ main window appears. You are now ready to build the project.
36
25 August 2015Veton Këpuska36 dot_prod_c Project The dotprodc project comprises two C language source files: dotprod.c and dotprod_main.c, which define the arrays and calculates their dot products.
37
25 August 2015Veton Këpuska37 Step 2: Building the dotprodc Project Source Files (.c &.asm) Compiler & Assembler Object Files (.doj) C Run-Time Header (basiccrt.s) Linker Description File (.ldf) Linker Executable File (.dxe) Debugger (In-Circuit Emulator, Simulator, or EX-KIT Lite) 1.Running the Compiler
38
25 August 2015Veton Këpuska38 Step 2: Building the dotprodc Project 2.Linking Source Files (.c &.asm) Compiler & Assembler Object Files (.doj) C Run-Time Header (basiccrt.s) Linker Description File (.ldf) Linker Executable File (.dxe) Debugger (In-Circuit Emulator, Simulator, or EX-KIT Lite)
39
25 August 2015Veton Këpuska39 Step 2: Building the dotprodc Project 1.From the Project menu, choose Build Project. VisualDSP++ first checks and updates the project dependencies and then Builds the project by using the project source files. Output window displays status messages.
40
25 August 2015Veton Këpuska40 Step 2: Building the dotprodc Project
41
25 August 2015Veton Këpuska41 Step 2: Building the dotprodc Project Upon successful build (compile and link steps) example program can be run.
42
25 August 2015Veton Këpuska42 Step 3: Configuring the Session to Run the Program Before running the program: Set up the debug session. View debugger windows and dialog boxes. Note: In Preferences dialog box of the General page: Load executable after build is checked ⇒ automatic loading of dotprodc.dxe on to the target (EZ- LIT Lite). If not connected to a debug target, VisualDSP++ will prompt to connect to one using an existing debug session or creating a new debug session as shown in the next slide:
43
25 August 2015Veton Këpuska43 Step 3: Configuring the Session to Run the Program Clicking OK will launch the Session Wizard as shown in the next slide.
44
25 August 2015Veton Këpuska44 Step 3: Configuring the Session to Run the Program
45
25 August 2015Veton Këpuska45 Step 3: Configuring the Session to Run the Program Setting up debug session: 1.On the Select Processor page, select the ADSP- BF533 processor from the Blackfin family. Click Next to continue. 2.On the Select Connection Type page, select Simulator, and click Next to continue. 3.On the Select Platform page, select ADSP-BF5xx Single Processor Simulator. You can either use the default Session name, or give it a more meaningful name of your choosing. Click Next to review your choices, then click Finish. VisualDSP++ closes the Session Wizard dialog box, automatically loads your project’s executable file (dotprodc.dxe), and advances to the main function of your code.
46
25 August 2015Veton Këpuska46 Step 3: Configuring the Session to Run the Program
47
25 August 2015Veton Këpuska47 Step 3: Configuring the Session to Run the Program 4.Look at the information in the open windows. The Output window’s Console page contains messages about the status of the debug session. In this case, VisualDSP++ reports that the dotprodc.dxe load is complete. The Disassembly window displays the assembly code for the executable. Use the scroll bars to move around the Disassembly window. Note that a solid red circle and a yellow arrow appear at the start of the program labeled “main”. The solid red circle ( ● ) indicates that a breakpoint is set on that instruction, and the yellow arrow ( ➨ ) indicates that the processor is currently halted at that instruction. When VisualDSP++ loads your C program, it automatically sets several breakpoints. Most of the breakpoints set are used as part of advanced features of VisualDSP++. There are two breakpoints of interest for this tutorial, one at the beginning and one at the end of code execution.
48
25 August 2015Veton Këpuska48 Step 3: Configuring the Session to Run the Program From the Settings menu, choose Breakpoints to view the breakpoints set in your program. VisualDSP++ displays the Breakpoints dialog box, as shown. The two breakpoints of interest are set at these C program locations: at main + 0x04 at __lib_prog_term
49
25 August 2015Veton Këpuska49 Step 4: Run dotprodc To run dotprodc.dxe: Click Run button: Select Run from Debug Menu. VisualDSP++ computes the dot products and displays the following results on the Console view of the Output window.
50
Exercise 2: Modifying a C Program Code to Call an Assembly Routine
51
25 August 2015Veton Këpuska51 Goals of this Exercise Learn to: Modify the C program to call an assembly language routine Create a Linker Description File (.ldf) to link with the assembly routine Rebuild the project.
52
25 August 2015Veton Këpuska52 Additional Information Ensure that the previous project and its files are closed: From File menu, choose Close and then Project dotprodc. Click Yes when prompted to close all open source windows. Important Note: If you have modified your project during the first exercise you will be prompted to save the project. Click No.
53
25 August 2015Veton Këpuska53 Step 1: Creating a New Project 1.From the File menu, choose New and then Project to open the Project Wizard:
54
25 August 2015Veton Këpuska54 Step 1: Creating a New Project 2.In the Name field, type dot_product.asm 3.Click the browse button to the right of the Directory field to open the Browse For Folder dialog box. Locate the dot_product_asm tutorial folder and click OK. By default this directory is in the following location. Program Files\Analog Devices\VisualDSP 4.5\Blackfin\ Examples\Tutorial\dot_product_asm 4.Click Next to bring up the Output Type page. 5.Verify that the Processor type is ADSP-BF533, the Silicon Revision is Automatic, and the Project output file is Executable file. Click Next to display the Add Startup Code/LDF page.
55
25 August 2015Veton Këpuska55 Step 1: Creating a New Project 6.Read the displayed text, and scroll down to the bottom of the page. Select the Add an LDF and startup code option. When this project is created: Startup code that initializes and configures the processor will be added to the project, as well as a Linker Description File that defines the target memory map and the placement of program sections within processor memory. The options available to configure the startup code and LDF are beyond the scope of this tutorial. Make sure the Add an LDF and startup code option is selected, and click Finish. The new project is created and is shown in the Project window of the IDDE.
56
25 August 2015Veton Këpuska56 Step 1: Creating a New Project 7.From the Project menu click the Project Options command to display the Project Options dialog box
57
25 August 2015Veton Këpuska57 Step 1: Creating a New Project 8.On the Project page (see previous slide) verify that the values shown in the following table (or image of the previous slide) are entered. FieldValue ProcessorADSP-BF533 RevisionAutomatic TypeExecutable file Namedot_product_asm Settings for ConfigurationDebug
58
25 August 2015Veton Këpuska58 Step 1: Creating a New Project 9.Take a moment to view the various pages in the Project Options dialog box by selecting them from the tree on the left: Project, General, Compile, Assemble, Link, Load, Pre-Build, and Post-Build. On each page, you specify the tool options used to build the project.
59
25 August 2015Veton Këpuska59 Step 1: Creating a New Project 10.Click the Compile tab to display the General page, shown:
60
25 August 2015Veton Këpuska60 Step 1: Creating a New Project 11.Specify these settings in the Code Generation group box: a.Select the Enable optimization check box to enable optimization. b.Select the Generate debug information check box, if it is not already selected, to enable debug information for the C source. 12.Click OK to apply changes to the project options and to close the Project Options dialog box. Note: These settings direct the C compiler to optimize code for the ADSP-BF533 processor. Because the optimization takes advantage of DSP architecture and assembly language features, some of the C debug information is not saved. Therefore, debugging is performed through debug information at the assembly language level.
61
25 August 2015Veton Këpuska61 Step 2: Adding Source Files to dot_product_asm 1.To add the source file to the new project: Click the Add File button, or from the Project menu, choose Add to Project, and then choose File(s). The Add Files dialog box appears.
62
25 August 2015Veton Këpuska62 Step 2: Adding Source Files to dot_product_asm
63
25 August 2015Veton Këpuska63 Step 2: Adding Source Files to dot_product_asm 2.In the Look in box, locate the project folder, dot_product_asm. 3.In the Files of type box, select All Source Files from the drop-down list. 4.Hold down the Ctrl key and click dotprod.c and dotprod_main.c. Then click Add. To display the files that you added in step 4, open the Source Files folder in the Project window. 5.Click the Rebuild All button ( ) to build the project. The C source file opens in an editor window, and execution halts.
64
25 August 2015Veton Këpuska64 Step 2: Modifying the Project Source Files In this procedure we will: 1.Modify dotprod_main.c to call a_dot_asm instead of a_dot_c 2.Save the modified file
65
25 August 2015Veton Këpuska65 Step 2: Modifying the Project Source Files To modify dotprod_main.c to call assembly function a_dot_asm do the following: 1.Resize or maximize the editor window for better viewing 2.From the Edit menu, choose Find to open the Find dialog box as shown in the figure.
66
25 August 2015Veton Këpuska66 Step 2: Modifying the Project Source Files 3.In the Find What box, 1.type “/*”, and then 2.click Mark All. The editor bookmarks all lines containing “/*” and positions the cursor at the first instance of “/*” in the extern int a_dot_c_asm declaration. 4.Select the comment characters “/*” and 1.Use the Ctrl+X key combination to cut the comment characters from the beginning of the a_dot_c_asm declaration. 2.Then move the cursor up one line and use the Ctrl+V key combination to paste the comment characters at the beginning of the a_dot_c declaration. Because syntax coloring is turned on, the code changes color as you cut and paste the comment characters. Repeat this step for the end-of-comment characters “*/” at the end of the a_dot_c_asm declaration. The a_dot_c declaration is now fully commented out, and the a_dot_c_asm declaration is no longer commented.
67
25 August 2015Veton Këpuska67 Step 2: Modifying the Project Source Files 5.Press F2 to move to the next bookmark. The editor positions the cursor on the “/*” in the function call to a_dot_c_asm, which is currently commented out. Note that the previous line is the function call to the a_dot_c routine. 6.Press Ctrl+X to cut the comment characters from the beginning of the function call to a_dot_c_asm. Then move the cursor up one line and press Ctrl+V to paste the comment characters at the beginning of the call to a_dot_c. Repeat this step for the end-of-comment characters “*/”. The main() function is now calling the a_dot_c_asm routine instead of the a_dot_c function (previously called in Exercise One). Note: The next image displays the changes made in the step 6.
68
25 August 2015Veton Këpuska68 Step 2: Modifying the Project Source Files
69
25 August 2015Veton Këpuska69 Step 2: Modifying the Project Source Files 7.From the File menu, choose Save and then File dotprod_main.c to save the changes to the file. 8.Place the cursor in the editor window. Then, from the File menu, choose Close and then File dotprod_main.c to close the dotprod_main.c file.
70
25 August 2015Veton Këpuska70 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf In this procedure we will: View the Expert Linker representation of the.ldf file that is created. Modify.ldf file to map in the section for the a_dor_c_asm assembly routine.
71
25 August 2015Veton Këpuska71 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf To examine and then modify dot_prod_asm.ldf to link eith the assembly function do the following: 1.Click the Ad File button. 2.Select dotprod_func.asm and click Add. 3.Build the project by performing one of these actions: Click the Build Project button. From the Project menu, choose Build Project. 4.Notice the error in the Output window.
72
25 August 2015Veton Këpuska72 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf Output Window: Linker Error To correct this error the do the following:
73
25 August 2015Veton Këpuska73 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf In the Project window, double-click in the dot_prod_asm.ldf file. The Expert Linker window (see Figure in the next slide) opens with a graphical representation of your file. Resize the window to expand the view and change the view mode. To display the tree view shown in next slide, right-click in the right pane, choose View Mode, and then choose Memory Map Tree. The left pane (Input Sections) contains a list of the input sections that are in your project or are mapped in the.LDF file. A red X is over the icon in front of the section named “my_asm_section” because Expert Linker has determined that the section is not mapped by the.LDF file. The right pane (Memory Map) contains a representation of the memory segments that Expert Linker defined when it created the.LDF file. Expert Linker Window depicts the procedure followed in this step.
74
25 August 2015Veton Këpuska74 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf
75
25 August 2015Veton Këpuska75 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf 6.Map my_asm_section into the memory segment named MEM_PROGRAM as follows. In the Input Sections pane, open my_asm_section by clicking on the plus sign in front of it. The input section expands to show that the linker macros: $COMMAND_LINE_OBJECTS and $OBJECTS and the object file dotprod_func.doj have a section that has not been mapped. In the Memory Map pane, expand MEM_L1_CODE and drag the icon in front of $OBJECTS onto the program_ram output section under MEM_L1_CODE. As shown in Figure in the next slide, the red X should no longer appear because the section my_asm_section has been mapped.
76
25 August 2015Veton Këpuska76 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf
77
25 August 2015Veton Këpuska77 Step 3: Use the Expert Linker to Modify dot_prod_asm.ldf 7.From the Tools menu, choose Expert Linker and Save to save the modified file. Then close the Expert Linker window. If you forget to save the file and then rebuild the project, VisualDSP++ will see that you modified the file and will automatically save it.
78
25 August 2015Veton Këpuska78 Step 4: Rebuild and Run dot_prod_asm Build the project by: 1.Click the Build Project button, or 2.From the Project menu, choose Build Project. At the end of the build, the Output window should display this message in the Build view: “Build completed successfully” VisualDSP++ loads the program Runs to main, and Displays the Output, Disassembly, and editor windows (as seen in the next slide)
79
25 August 2015Veton Këpuska79 Step 4: Rebuild and Run dot_prod_asm
80
25 August 2015Veton Këpuska80 Step 4: Rebuild and Run dot_prod_asm Click the Run button to run dot_product_asm. The program calculates the three dot products and displays the results in the Console view of the Output window. When the program stops running, the message “Halted” appears in the status bar at the bottom of the VisualDSP++ main window. The results, shown below, are identical to the results obtained in Exercise One. Dot product [0] = 13273595 Dot product [1] = –49956078 Dot product [2] = 35872518
81
Exercise 3 Plotting Data
82
25 August 2015Veton Këpuska82 Goals of this Exercise Learn to: Load and debug a prebuilt program that applies a simple Finite Impulse Response (FIR) filter to a buffer of data Use VisualDSP++’s plotting engine to view the different data arrays graphically, both before and after running the program.
83
25 August 2015Veton Këpuska83 Digression: What is an FIR Filter Digital Filtering, in general, is one of the most powerful tools of Digital Signal Processing. In general any Digital Signal Processing of a Linear Time Invariant (LTI) system can be expressed with a difference equation (more on this latter)
84
25 August 2015Veton Këpuska84 Linear Constant-Coefficient Difference Equations Nth-order linear constant-coefficient difference equation is of the form: Accumulator Example
85
25 August 2015Veton Këpuska85 Linear Constant-Coefficient Difference Equations (cont.) One-sample delay x[n]y[n]
86
25 August 2015Veton Këpuska86 General Formulation of Difference Equation Equation: Along with initial conditions: y[-1], y[-2], …, y[-N] Uniquely specifies the LTI system. General equation must be computed using recursive procedure.
87
25 August 2015Veton Këpuska87 Example Recursive Computation of Difference Equations: y[n] = ay[n-1]+x[n] Initial condition is given by y[-1] = c; Input x[n] = K[n] Solution n≥0: y[0] = ac+K y[1] = y[0]+0 = a(ac+K) = a 2 c+aK … y[n] = a n+1 c+a n K, n≥0
88
25 August 2015Veton Këpuska88 Example (cont.) Solution n<0: y[n] = ay[n-1]+x[n] ➲ y[n-1] = a -1 (y[n]-x[n]) y[-1] = c y[-2] = a -1 (y[-1]-x[-1]) = a -1 (c+0) = a -1 c … y[n] = a n+1 c, n<0 Overall solution y[n] = a n+1 c+Ka n u[n], n
89
25 August 2015Veton Këpuska89 Z -Transform Interesting specific class of rational functions of the form: Roots of the polynomial P(z) define the zeros, and Roots of the polynomial Q(z) define the poles of the z-transform. Partial fraction expansion method can be used for rational functions.
90
25 August 2015Veton Këpuska90 Difference Equation & Z -Transform By definition variable Z is equal to unit delay. There is direct relationship between difference equation and Z -Transform:
91
25 August 2015Veton Këpuska91 Property of Z -Transform
92
25 August 2015Veton Këpuska92 Difference Equation & Z -Transform Last expression is a rational function with numerator and denominator that are polynomials of z -1.
93
25 August 2015Veton Këpuska93 Filters Any Linear Time Invariant digital filter is expressed by its difference equation. There are two classes of digital filters: Finite Impulse Response (FIR), and Infinite Impulse Response (IIR).
94
25 August 2015Veton Këpuska94 FIR Filters The impulse response of an FIR filter has finite duration and corresponds to having no denominator in the rational function H(z): ➨ There is no feedback in the difference Equation. This results in the reduced form difference equation: Impulse sample response (input x[0]=1; x[n]=0 elsewhere for n≠0) of FIR filter is:
95
25 August 2015Veton Këpuska95 Step 1: Loading the FIR Program 1.Keep the Disassembly window and Console page (of the Output window) open, but close all other windows. 2.From the File menu, choose Load Program or click The Open a Processor Program dialog box appears. 3.Select the FIR program to load as follows. a.Open the Analog Devices folder and double-click: VisualDSP 4.5\Blackfin\Examples\Tutorial\fir b.Double-click the Debug subfolder. c.Double-click FIR.DXE to load the program. If VisualDSP++ does not open an editor window (shown in Figure in the next slide), right-click in the Disassembly window and select View Source.
96
25 August 2015Veton Këpuska96 Step 1: Loading the FIR Program
97
25 August 2015Veton Këpuska97 Step 1: Loading the FIR Program 4.Look at the source code of the FIR program. You can see two global data arrays: IN OUT You can also see one function, _fir, that operates on these arrays.
98
25 August 2015Veton Këpuska98 Step 2: Opening a Plot Window 1.From the View menu, choose Debug Windows and Plot. Then choose New to open the Plot Configuration dialog box, shown in the next slide Figure. Here you add the data sets that you want to view in a plot window. 2.In the Plot group box, specify the following values. In the Type box, select Line Plot from the drop- down list. In the Title box, type fir. 3.Enter two data sets to plot by using the values in Table in the slide after next.
99
25 August 2015Veton Këpuska99 Step 2: Opening a Plot Window
100
25 August 2015Veton Këpuska100 Step 2: Table Specifying 2 Data sets: Input & Output BoxInput Data SetOutput Data Set Description NameInputOutputData set MemoryBLACKFIN Memory Data memory AddressINOUTThe address of this data set is that of the Input or Output array. Click Browse to select the value from the list of loaded symbols Count128 The array is 260 elements long, but you are plotting the first 128 elements Stride11The data is contiguous in memory Datashort Input & Output are arrays of int values After entering each data set, click Add to add the data set to the Data sets list on the left of the dialog box. The Plot Configuration dialog box should now look like the one in the Figure presented in the next slide.
101
25 August 2015Veton Këpuska101 Step 2: Opening a Plot Window Plot Configuration Dialog Box with Input/Output Data Sets
102
25 August 2015Veton Këpuska102 Step 2: Opening a Plot Window 4.Click OK to apply the changes and to open a plot window with these data sets. The plot window now displays the two arrays. By default, the simulator initializes memory to zero, so the Output data set appears as one horizontal line, shown in Figure below.
103
25 August 2015Veton Këpuska103 Step 2: Opening a Plot Window 5.Right-click in the plot window and choose Modify Settings. On the General page, in the Options group box, select Legend and click OK to display the legend box.
104
25 August 2015Veton Këpuska104 Step 3: Run the FIR Program and View the Data Press F5 or click the Run button to run to the end of the program. When the program halts, you see the results of the FIR filter in the Output array. The two data sets are visible in the plot window, as shown in Figure below:
105
25 August 2015Veton Këpuska105 Step 3: Run the FIR Program and View the Data 2.Additional Features of the Plotting interface allows you to select the region and to zoom in.
106
25 August 2015Veton Këpuska106 Step 3: Run the FIR Program and View the Data
107
25 August 2015Veton Këpuska107 Step 3: Run the FIR Program and View the Data To return to the view before magnification, right-click in the plot window and choose Reset Zoom from the pop-up menu. Individual data points can be viewed as described in the following procedure: 3.Right-click inside the plot window and choose Data Cursor from the pop-up menu. Move to each data point in the current data set by pressing and holding the Left ( ← ) or Right ( → ) arrow key on the keyboard. To switch data sets, press the Up ( ↑ ) or Down ( ↓ ) arrow key. The value of the current data point appears in the lower-left corner of the plot window, as shown in Figure in the next slide.
108
25 August 2015Veton Këpuska108 Step 3: Run the FIR Program and View the Data
109
25 August 2015Veton Këpuska109 Step 3: Run the FIR Program and View the Data 4.Right-click in the plot window and choose Data Cursor from the pop- up menu. Next you will look at data sets in the frequency domain. 5.Right-click in the plot window and choose Modify Settings to open the Plot Settings dialog box. 6.Complete these steps: a.Click the Data Processing tab to display the Data Processing page, shown in next Figure. b.In the Data Sets box, ensure that Input (the default) is selected. In the Data Process box, choose FFT Magnitude. c.In the Sample rate (Hz) box, type 10000. d.In the Data Sets box, select Output. In the Data Process box, choose FFT Magnitude e.Click OK to exit the Plot Settings dialog box. VisualDSP++ performs a Fast Fourier Transform (FFT) on the selected data set before it is plotted. The FFT enables you to view the signal in the frequency domain, as shown in Figure after next.
110
25 August 2015Veton Këpuska110 Step 3: Run the FIR Program and View the Data Data Processing Page
111
25 August 2015Veton Këpuska111 Step 3: Run the FIR Program and View the Data FFT Performed on a Selected Data Set
112
25 August 2015Veton Këpuska112 Step 4: Analysis of the Data FIR filter’s response in the frequency domain 1.From the View menu, choose Debug Windows and Plot. Then choose New to open the Plot Configuration dialog box. 2.Set up the Filter Frequency Response plot by completing the Plot and Data Setting group boxes as shown in Figure in the next slide.
113
25 August 2015Veton Këpuska113 Step 4: Analysis of the Data
114
25 August 2015Veton Këpuska114 Step 4: Analysis of the Data 3.Click Add to add the data set to the Data sets box. 4.Click OK to apply the changes and to open the plot window with this data set. 5.Right-click in the plot window and choose Modify Settings to open the Plot Settings dialog box. 6.Click the Data Processing tab to display the Data Processing page. Complete this page as follows. a.In the Data Sets box, select h. b.In the Data Process box, choose FFT Magnitude. c.In the Sample rate (Hz) box, type 10000. d.Click OK to exit the Data Processing page. VisualDSP++ performs a Fast Fourier Transform (FFT) on the selected data set, and enables you to view the filters frequency response plot in the frequency domain, as shown in Figure in the next slide.
115
25 August 2015Veton Këpuska115 Step 4: Analysis of the Data Filter’s Frequency Response Plot
116
25 August 2015Veton Këpuska116 Step 4: Analysis of the Data This plot shows that the low-pass FIR filter cuts off all frequency components above 4,000 Hz. When you apply this low-pass filter to the input signal, the resulting signal has no output above 4,000 Hz. On the importance of filtering more later: Telephony toll-quality signal requires that signal has no frequency components above 4000 Hz to avoid aliasing. The effect of aliasing is depicted as a low frequency noise “reflected” from the components above 4000 Hz.
117
Exercise 4 Linear Profiling
118
25 August 2015Veton Këpuska118 Goals of this Exercise Learn to: Load and debug the FIR program from the previous exercise 3 Use linear profiling to evaluate the program’s efficiency and to determine where the application is spending the majority of its execution time in the code
119
25 August 2015Veton Këpuska119 VisualDSP++ Profiling VisualDSP++ supports two types of profiling: linear and statistical. Linear Profiling: You use linear profiling with a simulator. The count in the Linear Profiling Results window is incremented every time an assembly instruction is executed. Statistical Profiling: You use statistical profiling with a JTAG emulator connected to a processor target. The count in the Statistical Profiling Results window is based on random sampling of the program counter.
120
25 August 2015Veton Këpuska120 Step 1: Loading the FIR Program 1.Close all open windows except the Disassembly window and the Output window. 2.Keep the Disassembly window and Console page (of the Output window) open, but close all other windows. 3.From the File menu, choose Load Program or click The Open a Processor Program dialog box appears. 4.Select the FIR program to load as follows. a.Open the Analog Devices folder and double-click: VisualDSP 4.5\Blackfin\Examples\Tutorial\fir b.Double-click the Debug subfolder. c.Double-click FIR.DXE to load and run the FIR program. If VisualDSP++ does not open an editor window, right-click in the Disassembly window and select View Source.
121
25 August 2015Veton Këpuska121 Step 2: Opening the Profiling Window 1.From the Tools menu, choose Linear Profiling and then choose New Profile. The Linear Profiling Results window opens without any data. 2.Click in the profiling window’s title bar and then drag and drop the window to the top of the VisualDSP++ main window, as shown in Figure in the next slide. You will have a better view of the profile data.
122
25 August 2015Veton Këpuska122 Step 2: Opening the Profiling Window
123
25 August 2015Veton Këpuska123 Step 2: Opening the Profiling Window The Linear Profiling Results window is initially empty. Linear profiling is performed when you run the FIR program. After you run the program and collect data, this window displays the results of the profiling session.
124
25 August 2015Veton Këpuska124 Step 3: Collecting & Examining the Linear Profiling Data 1.Press F5 or click to run to the end of the program. When the program halts, the results of the linear profile appear in the Linear Profiling Results window. 2.Examine the results of your linear profiling session. The Linear Profiling Results window is divided into two three-column panes. The left pane shows the results of the profile data. You can see the percentages of total execution time consumed, by function and by address. Double-clicking a line with a function enables you to display the source file that contains that function. For example, double-click the fir function to display the assembly source file (fir.asm) in the right pane, as shown in Figure in the next slide.
125
25 August 2015Veton Këpuska125 Step 3: Collecting & Examining the Linear Profiling Data Linear Profiling Results, FIR Program Performance Analysis. Note: your results may be slightly different.
126
25 August 2015Veton Këpuska126 Interpreting Collected Data Histogram A graphical representation of the percentage of time spent in a particular execution unit. This percentage is based on the total time that the program spent running, so longer bars denote more time spent in a particular execution unit. The Linear Profiling Results window always sorts the data with the most time-consuming (expensive) execution units at the top. % The numerical percent of the same data found in the Histogram column. You can view this value as an absolute number of samples by right-clicking in the Linear Profiling Results window and by selecting View Sample Count from the pop-up menu. Execution Unit The program location to which the samples belong. If the instructions are inside a C function or a C++ method, the execution unit is the name of the function or method. For instructions that have no corresponding symbolic names, such as hand-coded assembly or source files compiled without debugging information, this value is an address in the form of PC[xxx], where xxx is the address of the instruction. If the instructions are part of an assembly file, the execution unit is either an assembly function or the assembly file followed by the line number in parentheses.
127
25 August 2015Veton Këpuska127 Interpreting Collected Data In previous Figure, the left pane shows that the fir function consumes over 96% of total execution time. The right (source) pane, shown in next Figure, displays the percentage that each line in the fir function consumes.
128
25 August 2015Veton Këpuska128 Linear Profile Data for fir.asm
129
End of Tutorial
130
25 August 2015Veton Këpuska130 Compiler Command Line Interface ccblkfn [-switch [-switch …] sourcefile [sourcefile …]] Command line syntax ParameterDescription ccblkfnName of the compiler program for Blackfin processors. -switchSwitch (or switches) to process. The compiler has many switches. These switches select the operations and modes for the compiler and other tools. Command-line switches are case-sensitive. For example, -O is not the same as -o. sourcefileName of the file to be preprocessed, compiled, assembled, and/or linked
131
25 August 2015Veton Këpuska131 Example ccblkfn -proc ADSP-BF535 -O -Wremarks -o program.dxe source.c runs ccblkfn with -proc ADSP-BF535 Specifies compiler instructions unique to the ADSP-BF535 processor -O Specifies optimization for the compiler -Wremarks Selects extra diagnostic remarks in addition to warning and error messages -o program.dxe Selects a name for the compiled, linked output source.c Specifies the C language source file to be compiled
132
25 August 2015Veton Këpuska132 Accepted File Extensions ExtensionAction.c.C.cpp.cxx.cc.c++ Source file is compiled, assembled, and linked..asm,.dsp, or.sAssembly language source file is assembled and linked..dojObject file (from previous assembly) is linked. If multiple files are specified: Each is processed to produce an object file All object files are presented to the linker This sequence can be stopped at various points using: Compiler Switches (-E,-P,-M,-H,-S, and –c) VisualDSP++ IDDE
133
25 August 2015Veton Këpuska133 Input and Output File Extensions File ExtensionFile Extension Description.c.C C source file.cpp.cxx.cc.c++ C++ source file.h Header file (referenced by an #include statement).hpp.hh.hxx.h++ C++ header file (referenced by a #include statement).ii,.ti Template instantiation files – used internally by the compiler when instantiating templates.ipa,.opa Interprocedural analysis files – used internally by the compiler when performing interprocedural analysis..pgo Execution profile generated by a simulation run. For more information, see “Using Profile-Guided Optimization” in Chapter 2, Achieving Optimal Performance from C/C++ Source Code..i Preprocessed source file — created when preprocess only is specified.s,.asm Assembly language source files
134
25 August 2015Veton Këpuska134 Input and Output File Extensions (cont.) File ExtensionFile Extension Description.isPreprocessed assembly language source — retained when -save-temps is specified.ldfLinker Description File.pchPrecompiled header file..doj.oObject file to be linked.dlb.aLibrary of object files to be linked as needed.dxeExecutable file produced by compiler.xmlProcessor memory map file output.symProcessor symbol map file output
135
25 August 2015Veton Këpuska135 Compiler Command-Line Switches C or C++ Mode Selection Switches Switch NameDescription -c89 Supports programs that conform to the ISO/IEC 9899:1990 standard -c++ Supports ANSI/ISO standard C++ with Analog Devices Extensions
136
25 August 2015Veton Këpuska136 C/C++ Compiler Common Switches Switch NameDescription sourcefile Specifies the file to be compiled -@ filename Reads command-line input from the file -A symbol (tokens) Assert the specified name as a predicate -add-debug- libpaths Link against debug-specific variant of system libraries, where available -alttok Allow alternative keywords and sequences in sources -always-inline Treats inline keywords as a requirement rather than a suggestion. -auto-attr Directs the compiler to emit automatic attributes based on the files it compiles. Enabled by default. -bss Causes the compiler to put global zero-initialized data into a separate BSS-style section. Set by defaults. -build-lib Directs the librarian to build a library file
137
25 August 2015Veton Këpuska137 C/C++ Compiler Common Switches (cont.) Switch NameDescription -C Retains preprocessor comments in the output file -c Compiles and/or assembles only, but does not link -const-read-write Specifies that data accessed via a pointer to const data may be modified elsewhere -cplbs Instructs the compiler to assume that CPLBs are active -D macro [=def] Defines macro -debug-types Supports building a *.h file directly and writing a complete set of debugging information in the header file -decls- Determines whether uninitialized global variables should be treated as definitions or declarations. -double-size-any Indicates that the resulting object can be linked with objects built with any double size. -souble-size-{32|64} Selects 32- or 64-bit IEEE format for double. -double-size-32 is the default mode.
138
25 August 2015Veton Këpuska138 C/C++ Compiler Common Switches (cont.) Switch NameDescription -dry Displays, but does not perform, main driver actions (verbose dry run) -dryrun Displays, but does not perform, top-level driver actions (terse dry run) -E Preprocesses, but does not compile, the source file. -ED Preprocesses and sends all output to a file. -EE Preprocesses and compiles the source file. -enum-is-int By default enums can have a type larger than int. This option ensures that enum type is int. -extra-keywords Recognizes Blackfin processor extensions to ANIS/ISO standard for C (default mode) -extra-loop-loads Allows the compiler to read off the start or end of memory areas, within lops, to aid performance. -fast-fp Links with the high-speed floating-point emulation library
139
25 August 2015Veton Këpuska139 C/C++ Compiler Common Switches (cont.) Switch NameDescription -file-attr name Adds the specified attribute name/value pair to the file(s) being compiled -flags-tool flag Passes command-line switches through the compiler to other build tools -force-cricbuf Treats array references of the form array[i%n] as circular buffer operations -force-link Forces stac frame creation for leaf functions. (defualts to ON with –g option set, enforced for the –p option) -fp-associative Treats floating-point multiplication and addition as associative operations -full-io Links with a third party, proprietary I/O library -full-version Displays the version number of the driver and processes invoked by the driver -g Generates DWARF-2 debug information
140
25 August 2015Veton Këpuska140 C/C++ Compiler Common Switches (cont.) Switch NameDescription -glite Generates light-weight DWARF-2 debug information -guard-vol-loads Disables interrupts during volatile loads -H Outputs a list of included header files, but does not compile -HH Outputs a list of included header files and compilers. -h[elp] Outputs a list of command-line switches with brief syntax descriptions -I directory Appends directory to the standard search path -I - Specifies the point in the include directory list where the search for header files enclosed in angle brackets should begin -i Outputs only header details or makefile dependencies for include files specified in double quotes. -ieee-fp Links with the fully-compliant floating-point emulation library.
141
25 August 2015Veton Këpuska141 C/C++ Compiler Common Switches (cont.) Switch NameDescription
142
25 August 2015Veton Këpuska142 C/C++ Compiler Language Extensions Compiler Supports extensions to ANSI/ISO standard for C & C++. Extensions designed to Support DSP hardware Permit C++ Programming features when compiling in C mode.
143
END 25 August 2015Veton Këpuska143
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.