1 / 17

DSP: Digital Signal Processors

DSP: Digital Signal Processors. Definition. RT development 4 steps. Matlab/C Simulation. RT like Matlab/C Simulation. Real Time. RT like DSP Simulation. RT application. Clock levels. At Home. Definition. Definition. RT development 4 steps.

luke
Télécharger la présentation

DSP: Digital Signal Processors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DSP: Digital Signal Processors Definition RT development 4 steps Matlab/C Simulation RT like Matlab/C Simulation Real Time RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  2. Definition Definition RT development 4 steps The term “real time” is used to describe a number of different computer features. However, the following definition warrants adoption for this course: Real time is a realization method, in which every specific task is tied to a specific time within the system clock cycle. Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  3. Real-time vs. Off-line Definition RT development 4 steps • Q: What is the difference between a Real-time (RT) algorithm and an Off-line algorithm? • A: The basic idea of a RT algorithm is that only past and present input is available. Namely, we do not have access to future input values. Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  4. RT development 4 steps Definition RT development 4 steps • Matlab/C simulation • RT like Matlab/C simulation • RT like DSP simulation • RT application Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  5. 1. Matlab/C simulation Definition Example: mean calculation RT development 4 steps clear all; N=1000; x=rand(1,N); %---------------------------------------------------------- % Version 1 %---------------------------------------------------------- m1=mean(x); Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels Complex Matlab instructions At Home Alon Slapak, Afeka college

  6. 2. RT like simulation Definition Characteristics: RT development 4 steps • Clock-resembling loop • Access to the “present” value only in the input array. • Updated output in each loop cycle. Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  7. No updated output in each loop cycle. 2.RT like Matlab/C simulation Definition Example: mean calculation RT development 4 steps clear all; N=1000; x=rand(1,N); %---------------------------------------------------------- % Version 2 %---------------------------------------------------------- S=0; for i=1:N, S=S+x(i); end; m2=S/N; Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation This is not RT! – Why? RT application Clock levels At Home Alon Slapak, Afeka college

  8. 1. Clock-resembling loop 2. “present” value only 3. Updated output in each loop cycle 2.RT like Matlab/C simulation Definition Example: mean calculation RT development 4 steps clear all; N=1000; x=rand(1,N); %---------------------------------------------------------- % Version 3 %---------------------------------------------------------- K=50; buf=zeros(1,K); S=0; for i=1:N, S=S-buf(end); buf=[x(i) buf(1:end-1)]; S=S+buf(1); m3(i)=S/K; end; Matlab/C Simulation RT like Matlab/C Simulation RT like simulation characteristics RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  9. 1. Clock-resembling loop 2. “present” value only 3. Updated output in each loop cycle 2.RT like Matlab/C simulation Definition Example: mean calculation – Alpha filter RT development 4 steps clear all; N=1000; x=rand(1,N); %---------------------------------------------------------- % Version 4 %---------------------------------------------------------- S=0; for i=1:N, S=0.99*S+0.01*x(i); m4(i)=S; end; Matlab/C Simulation RT like Matlab/C Simulation RT like simulation characteristics RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  10. Updated output in each loop cycle “present” value only Clock-resembling loop Arrays for input & output samples 3. RT like DSP simulation Definition /////////////////////////////// // void main() /////////////////////////////// void main() { tMaState MaState; MaState.sum = 0; MaState.index = buf; int n; for (n=0; n<N; n++) y[n] = avg_asm(x[n],buf,&MaState); for (n=0; n<N; n++) printf("y[%d] = %d \n",n,y[n]); } RT development 4 steps /************************************* File Name : dsp6_main.c Author : Alon Slapak Date : 13.10.07 **************************************/ #include <stdio.h> #include <stdlib.h> #include <math.h> /////////////////////////////// // Constants /////////////////////////////// #define N 10 #define M 4 /////////////////////////////// // Types /////////////////////////////// typedef struct { int *index; int sum; } tMaState; /////////////////////////////// // Globals /////////////////////////////// int x[N] = {1, 2, 3, -4, -1, -5, 3, 0, 2, -1}; int y[N]; int buf[M] = {0, 0, 0, 0}; /////////////////////////////// // External functions /////////////////////////////// extern int avg_asm(int smp,int *buf, tMaState *t); Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  11. 3. RT like DSP simulationavg_asm function Definition RT development 4 steps /************************************* File Name : DSP6_func.asm Author : Alon Slapak Date : 13.10.07 **************************************/ /////////////////////////////// // Constants /////////////////////////////// #define M 4 .section data1; .section program; .global _avg_asm; _avg_asm: P0 = R2; // State struct pointer L0 = 4*M; // buf length B0 = R1; // buf start address nop; nop; R4 = [P0++]; // buf current index I0 = R4; // Circular buffer nop; nop; R2 = [P0]; // Moving average sum // Moving average R2 = R2 + R0; //sum = sum + new_sample R3 = [I0]; R2 = R2 - R3; //sum = sum - old_sample [I0++] = R0; // Store results [P0--] = R2; // Store the sum R4 = I0; [P0++] = R4; // Store the current index R0 = R2; RTS; _avg_asm.end: Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  12. State structures Definition RT development 4 steps In most RT assembler functions, a state structures maintaining values likebuffers pointers, buffer lengths and updated circular pointers are used: Example 1: Moving Avereage typedef struct { int *index; int sum; } tMaState; Example 2: FIR fract16 typedef struct {    fract16 *h,          /* filter coefficients               */    fract16 *d,          /* start of delay line               */    fract16 *p,          /* read/write pointer                */    int k;                /* number of coefficients            */    int l;                /* interpolation/decimation index*/ } fir_state_fr16; Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  13. 4. RT application Definition RT development 4 steps • Copy the instructions within the clock-resembling loop into the appropriate ISR function. • Copy the initialization instructions into the appropriate initialization function. • Make the required adjustments. Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  14. Core clock (CCLK) • System clock (SCLK) • Application clock (ACLK) • Also: Data clock (DCLK), Input clock (CLKIN) SCLK n+2 n n+1 CCLK App CLK Clock levels Example: CCLK = 400 MHz SCLK = 133 MHz ACLK = 48 kHz Definition RT development 4 steps Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application t[Sec] Clock levels At Home Alon Slapak, Afeka college

  15. n+2 n n+1 t[Sec] Tasks and system clock ticks Definition Example: Moving Average calculation RT development 4 steps Sampling: ADC x S  S +x Matlab/C Simulation S  S – Cyclic_buffer[last] RT like Matlab/C Simulation Cyclic_buffer[first]  x m  S/k RT like DSP Simulation DAC  m RT application Clock levels At Home Spare system clock tick Alon Slapak, Afeka college

  16. Basic mechanisms for RT Definition RT development 4 steps • Interrupts Clock-dependent interrupt is the only option for hard RT applications. • Polling Better fit for RT applications. Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

  17. After the lecture… Definition RT development 4 steps • Run the moving average example • Add the moving buffer length (currently 4) to the state structure, and omit the #define M 4 instruction in the DSP6_func.asm file Matlab/C Simulation RT like Matlab/C Simulation RT like DSP Simulation RT application Clock levels At Home Alon Slapak, Afeka college

More Related