Está en la página 1de 16

Notas

Esquema

Lenguajes y arquitecturas para el procesado digital de seales


Prof. Dr. Alberto Izquierdo
Universidad de Valladolid

ndice
0. Objetivos
1. Modelado y simulacin mediante las herramientas software Matlab y Simulink: Caso Practico FPB
2. Arquitecturas de procesado
3. Herramientas software
4. Caso practico I: FPB ensamblador
5. Caso practico II: FPB lenguaje C
0.Objetivos
Ejemplos de Modelado y Simulacin
Arquitecturas DSP ( Familia Texas Instruments)
Herramientas de trabajo con DSP
Ejemplos en tiempo real
1. Caso Practico: Filtro Paso-bajo
1.1 Matlab
memulafpb1.m

1.2 Simulink
emulafpb1.mdl

1.1 FPB Matlab


1.1 FPB Matlab
1.1 FPB Matlab
1.1 FPB Matlab
1.2 FPB Simulink

1.2 FPB Simulink


1.2 FPB Simulink
2. Arquitecturas de procesado
2.1 Tipos de procesadores
2.2 Criterios de seleccin
2.3 Clasificacin DSP
2.4 Familias Texas Instruments
2.5 TMS320C31 DSP Starter Kit (DSK)

2.1 Tipos de procesadores


Microprocesador de propsito general
Z80, 80386, 80486, 68030, etc..
Procesador de seal de propsito general(DSP)
56000, 96000, TMS 320C30, TMS 320C40, etc..
Procesador especifico
LSI + MSI , FPGA, ASIC, etc.
N procesadores

2.2 Criterios de Seleccin


Tiempo real -> Potencia de calculo (MFLOPS / GFLOPS)
Tiempo de procesado < Ts (periodo de muestreo de la seal)
Ciclo de instruccin << Ts
Ancho de banda seal y complejidad algoritmo
Tiempo de diseo
Coste de produccin
DSP
Potencia de calculo alta
Tiempo de diseo bajo
Coste de produccin medio

2.3 Clasificacin DSP

PROCESADORES DE PUNTO FIJO


Representacin de los datos en punto fijo
Arquitecturas muy rpidas
Bajo coste
Margen dinmico reducido
Programacin con Tcnicas de escalado (overflow)
PROCESADORES EN PUNTO FLOTANTE
Representacin de los datos en punto flotante
Arquitecturas de velocidad media
Alto coste
Alto margen dinmico
Programacin sencilla

2.4 Familia Texas Instruments


Diapositiva 17
TMS320C20X (C2000)
Punto fijo. Arquitectura 16 bit
Hasta 4.5 Kwords RAM (D+P) on chip
ALU 32 bits
Multiplicador 16 x 16
Direccionamiento externo: 64K + 64K
Puerto serie (1020 Mbps)
20 40 MIPS
5$ 17$

Diapositiva 19
TMS320C3X
Punto flotante. Arquitectura 32 bits
Hasta 2 Kwords RAM (D+P) on chip
ALU 40 bits, 2 ARAU 24 bits (dir)
Multiplicador 32x32 (40)
Direccionamiento externo: 16M

2 Puerto serie (10 20 Mbps), DMA


60 MFLOPS ( 33ns - 60 ns). 10$

Diapositiva 21
Diapositiva 22
TMS320C4X
Punto flotante. Arquitectura 32 bits
2 Kwords RAM (D+P) on chip, 128K cache
ALU 40 bits, 2 ARAU 24 bits (dir)
Multiplicador 32x32 (40)
Direccionamiento externo: 4G
6 Puerto serie (28 Mbyte/s), 6 DMA
80 MFLOPS ( 33ns - 40 ns)
Diapositiva 24
TMS320C5X
Punto fijo. Arquitectura 16 bits. JTAG
32 Kwords RAM (D+P) on chip
ALU 32 bits
Multiplicador 16x16
Direccionamiento externo: 192K
1 Puerto serie (12.5 Mbps)
(20-50 MIPS) ( 20ns-50ns)
Diapositiva 26
TMS320C54X (C5000)
Punto fijo. Arquitectura 16 bits. JTAG
32 Kwords RAM (D+P) on chip
ALU 40 bits, Acelerador viterbi
Multiplicador 17x17, 2 ARAU, 6 DMA
Direccionamiento externo: 4M

(66-100 MIPS) ( 10ns-15ns).


Diapositiva 28
Diapositiva 29
C6201
Punto fijo. Arquitectura VLIW
1Mbit RAM (D+P) on chip
8 Unidades ( 6 ALU 32/40 + 2 MUL 16/32)
8 instrucciones por ciclo
Direccionamiento externo: 32 bit
2 Puerto serie con buffer
(1600 MIPS) ( 5ns).

Diapositiva 31
C6701
Punto flotante. Arquitectura VLIW
1Mbit RAM (D+P) on chip
8 Unidades ( ALU 32/60 + MUL 64/64)
6 instrucciones por ciclo
Direccionamiento externo: 32 bit
2 Puerto serie con buffer, 4 DMA
(1 GFLOPS) ( 6ns).

Diapositiva 33
ltimos avances
C62
300Mhz
2400 MIPS
C64
600-1100 Mhz
4800- 8800 MIPS
2.5 TMS320C31 DSP Starter Kit (DSK)

TM320C31, 40ns, 50MFLOPS, Codec TLC32040 A/D y D/A 14 bits, 20 K (100K). Filtro antiaiasing
y de reconstruccin.
2Kwords (32 bit)
Puerto paralelo. Puerto JTAG (XDS510)
3. Herramientas Software
3.1 Arquitectura funcional
3.2 Compilacin/ enlazado
3.3 Emulacin Software
Code explorer
Code Composer
3.4 Emulacin Hardware (XDS510)
3.5 Simulacin Software
3.6 Code studio / Xexpress
3.1 Arquitectura funcional
3.2 Herramientas T.I.
3.2 Herramientas T.I.
Diapositiva 40
Diapositiva 41
4. Caso practico: FBP ensamblador
4.1 Generacin coeficientes (Matlab)
4.2 Programacin ensamblador
4.3 Ensamblado y enlazado (dsk3a)
4.4 Depuracin (dsk3d, Code explorer)
4.5 Ejecucin
4.1 Generacin de coeficientes
%fdsp.m
%Diseo de un filtro FIR y generacin de coeficientes
%para dsk tms320c31
clear;
N=16;
Wn=0.3;

fs=39062;

h = FIR1(N,Wn,boxcar(N+1));
[H,W] = FREQZ(h,1,1024);
Hlog=10*log10(abs(H)/max(abs(H)));

plot(W*fs/(2*pi),Hlog);
axis([ 0 fs/2 -50 2 ]);
grid;
title('Respuesta en frecuencia');
4.1 Generacin de coeficientes

!del cfir.asm
fid=fopen('cfir.asm','wt');
fprintf(fid,'%s\n\n','FIR_coef');

for i=1:length(h),
fprintf(fid,'%s','

.float ');

fprintf(fid,'%15.14e ;\n',h(i));
end;

fprintf(fid,'%s\n\n','END_coef');
fclose(fid);

4.1 Generacin de coeficientes


FIR_coef

.float 3.76947059814026e-002 ;
.float 1.39974313337898e-002 ;
.float -3.10621459899210e-002 ;
.float -6.34152950291409e-002 ;

.float 3.26606731121761e-002 ;
.float 1.50778823925610e-001 ;
.float 2.56520256909381e-001 ;
.float 2.98837537483168e-001 ;
.float 2.56520256909381e-001 ;
.float 1.50778823925610e-001 ;
.float 3.26606731121761e-002 ;
.float -4.65932189848815e-002 ;
.float -6.34152950291409e-002 ;
.float -3.10621459899210e-002 ;
.float 1.39974313337898e-002 ;
.float 3.76947059814026e-002 ;

4.2 Programacin ensamblador


;--------------------------------------------------------; pFIR.ASM
; Keith Larson, Alberto Izquierdo
;--------------------------------------------------------; Define constants used by program
TA

.set

TB .set 20
RA

; AIC timing register values


;

.set

RB .set 20

GIE

.set

0x2000

; This bit in ST turns on interrupts

.include "C3XMMRS.ASM"

.start "AICTEST",0x809802 ; Start assembling here


.sect
N

"AICTEST"

.set

32

;
; Up to N taps data/coef storage

;-----------------------------------------------------------------------ADC_recv .set
.loop
.float

$-2

N-2

0.0

.endloop
;- - - - - - - - - - - - - - - - - - - - - - - - -

; FIR filter coefficients


;- - - - - - - - - - - - - - - - - - - - - - - - .include "cfir.asm"

4.2 Programacin ensamblador


;------------------------------------SIZE
ADC_first
ADC_end

.word SZ

; Size of filter

.word

ADC_recv

.word ADC_recv+SZ

ADC_last

.word

FIR_coefx .word

ADC_recv

;
;

FIR_coef

;-----------------------------------; Define some constant storage data


;-----------------------------------A_REG

.word (TA<<9)+(RA<<2)+0 ; A registers

B_REG

.word (TB<<9)+(RB<<2)+2 ; B registers

C_REG

.word 00000011b

; control

S0_gctrl_val .word 0x0E970300

; Serial port control register values

S0_xctrl_val .word 0x00000111

S0_rctrl_val .word 0x00000111

;****************************************************
; Begin main code loop here
;****************************************************
main

or

GIE,ST

ldi 0xF4,IE
b

main

; Turn on INTS
; Enable XINT/RINT/INT2
; Do it again!

;------------------------------DAC2

push ST

; DAC Interrupt service routine

push R0

; Save what is to be used

pushf R0

push R2

pushf R2

push AR0

push AR1

ldi @ADC_last,AR1 ; Load pointers and circular access regsiters


ldi @FIR_coefx,AR0 ;
ldi @SIZE,BK

4.2 Programacin ensamblador


FIR

mpyf3 *AR0++,*AR1++(1)%,R0
ldf 0.0,R2
ldi @SIZE,RC
subi 2,RC
rptb FIR2
mpyf3 *AR0++,*AR1++(1)%,R0

FIR2 || addf3 R0,R2,R2


addf R2,R0
fix R0,R0

andn 3,R0

sti R0,@S0_xdata

; Output the new DAC value

pop AR1

; Restore what was used

pop AR0

popf R2

pop R2

popf R0

pop R0

pop ST

reti

;------------------------------4.2 Programacin ensamblador


ADC2

push ST

; Save what is to be used

push R3

pushf R3

push AR0

ldi @S0_rdata,R3 ; Get data from serial port

ash -16,R3

ldi @ADC_last,AR0 ;
float R3,R3

; Convert to float and store for FIR data

stf R3,*AR0++

cmpi @ADC_end,AR0

; If at end of buffer, wrap back to begin

ldige @ADC_first,AR0 ;
sti AR0,@ADC_last ;
pop AR0

; Restore what was used

popf R3

pop R3

pop ST

4.2 Programacin ensamblador


;======================================================;
; This section of code initializes the AIC

;======================================================;
AIC_INIT LDI 0x10,IE
andn 0x34,IF
ldi 0,R0

; Enable only XINT interrupt


;

sti R0,@S0_xdata
RPTS 0x040

LDI 2,IOF
rpts 0x40

; XF0=0 resets AIC


;

LDI 6,IOF

; XF0=1 runs AIC

;--------------------ldi @C_REG,R0

; Setup control register

call prog_AIC
ldi 0xfffc ,R0

;
; Program the AIC to be real slow

call prog_AIC
ldi 0xfffc|2,R0
call prog_AIC
ldi @B_REG,R0
call prog_AIC
ldi @A_REG,R0

;
;
;
; Bump up the Fs to final rate
; (smallest divisor should be last)
;

call prog_AIC
b

main

; the DRR before going to the main loop

4.2 Programacin ensamblador


;------------------------------prog_AIC ldi @S0_xdata,R1 ; Use original DXR data during 2 ndy
sti R1,@S0_xdata

idle
ldi @S0_xdata,R1
or

3,R1

; Request 2 ndy XMIT

sti R1,@S0_xdata
idle

; Use original DXR data during 2 ndy

sti R0,@S0_xdata
idle

; Send register value

andn 3,R1

sti R1,@S0_xdata

; Leave with original safe value in DXR

;--------------------ldi @S0_rdata,R0 ; Fix the receiver underrun by reading


rets
stack

.word $

; Put stack here

4.2 Programacin ensamblador


;****************************************************;
; Install the XINT/RINT ISR handler directly into
; the vector RAM location it will be used for

;****************************************************;
.start "SP0VECTS",0x809FC5
.sect

"SP0VECTS"

DAC2

; XINT0

ADC2

; RINT0

4.3 Ensamblado y enlazado

0x0080983c nocode

;****************************************************

0x0080983c nocode

; Begin main code loop here

0x0080983c nocode

;****************************************************

0x0080983c 0x10752000 main


0x0080983d 0x087600f4
0x0080983e 0x6a00fffd
0x0080983f nocode

or

GIE,ST

; Turn on INTS

ldi 0xF4,IE
b

main

; Enable XINT/RINT/INT2
; Do it again!

;-------------------------------

0x0080983f 0x0f350000 DAC2

push ST

; DAC Interrupt service routine

0x00809840 0x0f200000

push R0

; Save what is to be used

0x00809841 0x0fa00000

pushf R0

0x00809842 0x0f220000

push R2

0x00809843 0x0fa20000

pushf R2

0x00809844 0x0f280000

push AR0

0x00809845 0x0f290000

push AR1

0x00809846 0x08299834

ldi @ADC_last,AR1 ; Load pointers and circular access regsiters

0x00809847 0x08289835

ldi @FIR_coefx,AR0 ;

0x00809849 nocode
0x00809849 0x24e03120 FIR

mpyf3 *AR0++,*AR1++(1)%,R0

0x0080984a 0x07628000

ldf 0.0,R2

0x0080984b 0x083b9831

ldi @SIZE,RC

0x0080984c 0x187b0002

subi 2,RC

0x0080984d 0x6480984e

rptb FIR2

0x0080984e 0x80103120

mpyf3 *AR0++,*AR1++(1)%,R0

0x0080984e parcode

FIR2 || addf3 R0,R2,R2

0x0080984f 0x01800002

addf R2,R0

0x00809850 nocode
0x00809850 0x05000000

fix R0,R0

4.4 depuracin ( TI)


4.4 depuracin (Code Explorer)
5. Caso practico: FPB en Lenguaje C
5.1 Generacin coeficientes (Matlab)
5.2 Programacin C
5.3 Compilacin (cl30)

5.4 Linkado (lnk30)


5.5 Depuracin (Code Composer)
5.6 Ejecucin
5.1 Generacin coeficientes
Fs=10416.33;
orden=16;
fc=input('Frecuencia de corte ( <Fs/2) :');
Wn=2*fc/Fs;
h=fir1(orden,Wn,hamming(orden+1));

h1=h(1:orden);
h2=h(orden+1);
fid=fopen('c:\dsk\ejemplos_c\fir1\coef1.c','wt');
fprintf(fid,'%s\n','float coef[17] = { ');
fprintf(fid,'%15.14e,\n',h1);
fprintf(fid,'%15.14e};\n\n',h2);
fclose(fid);
5.1 Modulo respuesta: fc=2500 Hz
5.2 Coef1.c
5.2 Filtro1_16.c (1)
5.2 Filtro1_16.c (2)
5.2 Filtro1_16.c (3)
5.2 Filtro1_16.c (4)
5.2 Filtro1_16.c (5)
5.2 Filtro1_16.c (6)
5.2 filtro1_16.c (7)
void main(void)
{
float f;
int i;

/* Inicializacin de la memoria interna del filtro */


for (i = 0; i < 17; i++) mem[i] = 0.0;

for(;;)
{
asm(" idle

");

f = Input();

/* Wait for Receive Interrupt

*/

/* Put ADC sample in delay buffer

Output( (1.0) *fir(f));

/* Output result

*/

*/

}
}

5.2 Filtro1_16.c (8)


5.4 Enlazado: fichero de configuracin
MEMORY
{ RAM0 : org=0x00809800, len=0x0400

/* INTERNAL BLK 0 */

RAM1 : org=0x00809C00, len=0x0300

/* INTERNAL BLK 1 */

KERNEL : org=0x00809F00, len=0x00C0


VECTTBL: org=0x00809FC5, len=0x0010 }

/* INTERNAL BLK 1 */
/* INTERNAL BLK 1 */

SECTIONS
{ .text : {} > RAM0
.cinit : {} > RAM1
.data : {} > RAM1
.bss

: {} > RAM1

.sysmem : {} > RAM1


.const : {} > RAM1
.stack : {} > RAM1
SP0VECTS: {} > VECTTBL}

5.5 Depuracin (Code Composer)


Mapa de memoria
*********************************************************
TMS320C3x/4x COFF Linker

Version 5.11

*********************************************************

ENTRY POINT SYMBOL: "_c_int00" address: 008098db


MEMORY CONFIGURATION
name

origin

length

used

-------- -------- --------- -------RAM0

00809800 000000400 0000011a

RAM1

00809c00 000000300 00000152

KERNEL 00809f00 0000000c0 00000000

También podría gustarte