Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 345S Real-Time Digital Signal Processing Lab Spring 2009

Similar presentations


Presentation on theme: "EE 345S Real-Time Digital Signal Processing Lab Spring 2009"— Presentation transcript:

1 EE 345S Real-Time Digital Signal Processing Lab Spring 2009
Lab #3.2 & 3.3 Digital Filters Akshaya Srivatsa

2 Outline More About Circular Buffers C Code v/s Assembly
How Function Makes Call Using Assembly in C Linear Assembly Code How To Read Assembly Files IIR Filters DF-I and Implementation IIR Filter DF-II and Implementation Task List for Lab #3.2 Task List for Lab #3.3

3 More About Circular Buffers
8 registers: A4-A7 and B4-B7 can be used as circular buffers. Number of words in the buffer = Block Size 2 bits BK0 and BK1 (each 5 bit fields) of AMR (Address Mode register) BUF_LEN = 2NBlock+1 where BUF_LEN is total no. of bytes.

4 More About Circular Buffers
Buffer must be aligned to byte boundaries i.e. multiples of block size Implementation: #define Nblock 6 #define BUF_LEN_WORD 1<<(Nbloack-1) # define BUF_LEN 1<<(Nblock+1) #pragma DATA_ALIGN(x, BUF_LEN) x[] should be global. This prevents carries and borrows in address calculation between blocks to access data.

5 C Code v/s Assembly We use C coding over Assembly for the following reasons Rapid Software development Applications can be easily ported to DSP’s Assembly Code is tough to write because Multiple levels of pipelining. Multiple Execution Units Different instructions take different execution times

6 How Function Makes Call
In function call, first argument is the left most one. Registers A0-A9 and B0-B9 are saved on the stack. The first 10 arguments are saved in registers A and B. Other ones are saved on stack. The caller branches to the function. Returned values are stored in B3. Upon returning, the stack is popped and loaded back into the register.

7 Using Assembly in C Every variable in C is prefixed with an underscore in assembly. (x in C is _x in assembly) B3 (Return value) and A3 (Structure Register) must not be used freely. Objects or functions declared in assembly that is called by C needs to be declared with .def or .global. Must start with .cproc and end with .endproc to mark the start and end points for optimization.

8 Linear Assembly Code Has the extension .sa
No information about parallel instructions, latencies or register usage. An assembly optimizer- Find instructions that can operate in parallel Assign register usage Handle pipeline latencies Optimize execution time

9 How To Read Assembly Files
_<tag> is entry point .cproc are the arguments for the function .reg are the registers declared that are used. .return is the return value stored in B3. .endproc is end of procedure

10 IIR Filters IIR Filters can be represented as
Its time domain equivalent is This is called “Direct Form” since co-efficients directly appear in the difference equation. Filter requires N+M+1 storage elements for all the x[n] and y[n] values.

11 IIR Filters DF-I Implementation

12 IIR Filters DF-I Implementation
Compute v[n] Compute y[n] Update state variables

13 IIR Filters DF-I Implementation
The FDA tool on Matlab breaks the IIR filter into biquads or IIR filters with order 2. Same co-efficients are used for DF-I and DF-II The co-efficients are in this order [b1 b2 b3 … bN (a1=1) a2 a3 … aN] For M biquads, you get M+1 scaling factors. Typically scaleM+1 = 1 Implementation is scale1 – biquad1 – scale2 – biquad scaleM – biquadM – scaleM+1

14 IIR Filters DF-II Implementation
Let us rewrite the IIR filter difference equation:

15 IIR Filters DF-II Implementation
Step 1: Step 2:

16 Common Mistakes Each biquad is an IIR filter. If you working with biquads, treat each one independently. Each biquad has its own state variabled. DO NOT MIX THE STATE VARIABLES OF BIQUADS. Always first evaluate output for a biquad before you do any operations on the next biquad.

17 Task List Tasks for Lab 3.1 are FIR Filter Profiling IIR Filter Design
IIR DF-I Implementation and profiling Important Points DO NOT OVERWRITE older C files. The task list can be found at the following link

18 Task List Tasks for Lab 3.1 are
IIF Filter DF-II Implementation and Profiling LabVIEW VI for Magnitude & Phase Response Answer all Questions Important Points DO NOT OVERWRITE DF-I code Create a new labmain.c The task list can be found at the following link


Download ppt "EE 345S Real-Time Digital Signal Processing Lab Spring 2009"

Similar presentations


Ads by Google