DOC

DSP

By Craig Martinez,2014-07-05 09:29
7 views 0
DSP

传统上;GPP使用冯.诺依曼存储器结构。 两种广泛应用的特殊寻址方式——循环寻址存储器映像寄存器MMR

    大多数DSP采用了哈佛结构;将存储器空间 ? CPU寄存器——特殊功能寄存器: 和位倒序寻址。

    划分成两个;分别存储程序和数据。 ? 片内外设寄存器: 2000 5000 6000

     ? 暂存器SPRAM C54x的总线结构,八组16-bitTMS320C54x的组成 总线( TMS320C54x的寻址方式

    一组程序总线,PB(传送从程序存储器来的立即寻址 LD #2ARP 中央处理器CPU 指令代码和立即数。 绝对寻址MVKD SAMPLE*AR5 I/O功能扩展接口

    三组数据总线,CBDBEB(连接各种元PORT FIFO*AR5 内部总线控制

    器件;如CPU、数据地址产生逻辑、程序地累加器寻址READA Smem WRITA 串行口

    址产生逻辑;片内外设和数据存储器。CBSmem 特殊功能寄存器

    DB总线传送从数据存储器读出的操作数。EB直接寻址 LD 1A 主机通信接口HPI 总线传送写入到存储器中的数据。 间接寻址 LD *AR1+T 数据存储器RAM 四组地址总线,PABCABDABEAB(存储器映射寄存器寻址,只有8条指令能使定时系统

    传送执行指令所需要的地址。 用存储器映射寄存器寻址( 程序存储器ROM

    LDM MMR dst 中断系统 中央处理单元(CPU)

    40-bit的算术逻辑单元(ALU) MVDM dmad, MMR

    两个40-bit的累加器(ACCA ACCB) MVMD MMR, dmad 直方图统计void Histogram 桶形移位寄存器 MVMM MMRx, MMRy 图像增强void Enhance 乘法器/累加器单元 POPM MMR 边缘检测void Sobel 16位移位寄存器(TRN) PSHM MMR

    16位暂存器(T) STLM src, MMR

    比较、选择和存储单元,CSSU( STM #lk, MMR

    指数编码器 堆栈寻址 PSHD PSHM POPD

    CPU状态和控制寄存器。 POPM

     RPTB next-1 end: B end RPT #7 对数组x[5]的每个元素

     ADD *AR4,16,B,A .end MVPD table,*AR1+ 1

     .title "test.asm" STH A,*AR4+ STM #a,AR1 x1——x5 中找出

     .mmregs next: LD #0,B STM #x,AR2 ai*xi最大值;并存放在

    STACK .usect "STARCK",10h end: B end STM #2,AR3 累加器A

     .bss x,5 .end .title "test2.asm" LD *AR1+,T

     .def start .mmregs MPY *AR2+,A 数组初始化

     .data STACK: .usect "STACK",100 loop1 LD *AR1+,T x[5]={0,0,0,0,0}

    table: .word 1, 2, 3, 4, 5 .title "test1.asm" .bss x,4 MPY *AR2+,B

     .text .mmregs .bss a,4 MAX A start: STM #STACK+10h,SP .bss x,5 .bss y,1 BANZ loop1,*AR3-

     STM #x,AR1 .def start .def start STL A,@y

     RPT #4 .text table: .word 1, 2, 3, 4 end: B end

     MVPD table,*AR1+ start: STM #x,AR1 .word 8, 6, 8, 2 .end

     STM #x,AR4 LD #0,A .text

     LD #1,16,B RPT #4 start: STM #STACK+100,SP

     STM #4,BRC STL A,*AR1+ STM #x,AR1

     MVPD table,*AR1+ .bss x,5 LD #0,A y= a1*x1+a2*x2

     .title "test3.asm" LD @x1,T .bss a,5

     .mmregs LD #0,B .bss y,1 STM #0,SWWSR STACK: .usect "STACK",100 MAC @a1,B .def start loop: LD *AR1+,A

     .bss x1,1 LD @x2,T .data STL A,*AR2+

     .bss a1,1 MAC @a2,B table:.word BANZ loop,*AR0-

     .bss x2,1 STL B,@y 1*32768/10,2*32768/10,3*32768/ SSBX FRCT

     .bss a2,1 STH B,@y+1 10,4*32768/10,5*32768/10 CALL SUM

     .bss y,1 end: B end .word end: B end

     .def start .end 1*32768/10,2*32768/10,3*32768/SUM: STM #a,AR3 table: .word 1, 2 10,4*32768/10,5*32768/10 STM #x,AR4 y=a1*x1+a2*x2+a3*x3+

     .word 3, 4 .text RPTZ A,#4 a4*x4+a5*x5

     .text .title "lab5a.asm" start: STM #STACK+10h,SP MAC *AR3+,*AR4+,A start: STM #STACK+100,SP .mmregs STM #table,AR1 STH A,@y

     STM #x1,AR1 .def start STM #x,AR2 RET

     RPT #3 STACK: .usect "STACK",10h STM #9,AR0 .end

     ADD *AR4,16,B,A start: STM #STACK+100,SP .bss z,1 对数组x[5]的每个元素

     STH A, *AR4+ STM #m,AR1 .def start 1

    .title "lab5b.asm" end: B end RPT #2 table: .word 1

     .mmregs .end MVPD table,*AR1+ .word 2

     .bss x,5 LD @m,T .word 3 计算y =mx+b

     .def start .title "test4.asm" MPY @x,A .text

     .data .mmregs ADD @b,A start: STM #STACK+100,SP table: .word STACK: .usect "STACK",100 STL A,@y STM #x,AR1 1000h,2000h,3000h,4000h,5000h .bss m,1 end: B end RPT #2

     .text .bss x,1 .end MVPD table,*AR1+ start: STM #x,AR2 .bss b,1 计算z=x+y-w

     RPT #4 .bss y,1 .title "test5.asm" LD @x,A

     MVPD table,*AR2+ .def start .mmregs ADD @y,A next: LD #1,16,B table: .word 4 STACK: .usect "STACK",100 SUB @w,A

     STM #4,BRC .word 2 .bss x,1 STL A,@z

     STM #x,AR4 .word 3 .bss y,1 end: B end

     RPTB end-1 .text .bss w,1 .end

    y=x1+x2+ x3+x4+ x5 y=1+2+3+4+5+6+7+8+9+10

     .title "test6.asm" #include

     .mmregs #nclude

    STACK: .usect "STACK",100 int i;

     .bss x,5 void main()

     .bss y,1 {

     .def start int y=0;

    table: .word 1,2,3,4,5 for(i=0;i<11;i++)

     .text {

    start: STM #STACK+100,SP y=y+i;

     STM #x,AR1 }

     RPT #4 while(1);

     MVPD table,*AR1+ }

     STM #x,AR1

     STM #4,AR2

     LD #0,A

    loop: ADD *AR1+,A

     BANZ loop,*AR2-

     STL A,y

    end: B end

     .end

直方图统计子 }

    #define IMAGEWIDTH 80 //图像的宽度 /*以下是直方图统计子程序*/ #define IMAGEHEIGHT 80 //图像的高度 void Histogram(unsigned char *pImage,int nWidth,int nHeight,float

    #define MODEPHOTO1 1 fHisto[256])

    #define MODEPHOTO2 2 {

    void InitImage(unsigned int nMode,unsigned char *pImage,int nWidth,int int i,j;

    nHeight); unsigned int uWork; void Histogram(unsigned char *pImage,int nWidth,int nHeight,float unsigned char *pWork; fHisto[256]); for(i=0;i<256;i++) fHisto[i]=0.0f;

    unsigned char dbImage[IMAGEWIDTH*IMAGEHEIGHT]; pWork=pImage; float fHistogram[256]; for(i=0;iint main() {

    { for(j=0;j

     {

    InitImage(MODEPHOTO1,dbImage,IMAGEWIDTH,IMAGEHEIGHT); uWork=(unsigned int)(*pWork);

    //断点 fHisto[uWork]++;

     Histogram(dbImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram); }

     }

    InitImage(MODEPHOTO2,dbImage,IMAGEWIDTH,IMAGEHEIGHT); uWork=nWidth*nHeight; //断点 for(i=0;i<256;i++)

     Histogram(dbImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram); {

     while(1); fHisto[i]/= uWork; //断点 fHisto[i]*=100;

     } fHisto[256])

    } {

     int i,j;

     unsigned int uWork;

    图像增强子程序 unsigned char *pWork; #define IMAGEWIDTH 80 //图像的宽度 for(i=0;i<256;i++) fHisto[i]=0.0f; #define IMAGEHEIGHT 80 //图像的高度 pWork=pImage;

    #define MODEPHOTO1 1 for(i=0;i#define MODEPHOTO2 2 {

    void InitImage(unsigned int nMode,unsigned char *pImage,int nWidth,int for(j=0;jnHeight); {

    void Histogram(unsigned char *pImage,int nWidth,int nHeight,float uWork=(unsigned int)(*pWork); fHisto[256]); fHisto[uWork]++; void Enhance(unsigned char *pImage, unsigned char *pImage1, int }

    nWidth,int nHeight,float fHisto[256], float fHisto1[256]); }

    unsigned char dbImage[IMAGEWIDTH*IMAGEHEIGHT]; uWork=nWidth* nHeight;

    unsigned char dbTargetImage[IMAGEWIDTH*IMAGEHEIGHT]; for(i=0;i<256;i++)

    float fHistogram[256],fHistogram1[256]; {

    unsigned char lut[256]; fHisto[i]/= uWork; //直方图统计实验程序 fHisto[i]*=100;

    int main() }

    { }

     InitImage(MODEPHOTO1,dbImage,IMAGEWIDTH, //图像增强子程序

    IMAGEHEIGHT); //断点 void Enhance(unsigned char *pImage,unsigned char *pImage1,int

     Histogram(dbImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram); nWidth,int nHeight,float fHisto[256], float fHisto1[256])

     {

    Enhance(dbImage,dbTargetImage,IMAGEWIDTH,IMAGEHEIGHT,fHist int i,j;

    ogram,fHistogram1); unsigned char *pWork,*pWork1;

     for(i=0;i<256;i++)

    Histogram(dbTargetImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram1) fHisto1[i]= fHisto[i]/100; ; for(i=1;i<256;i++)

     fHisto1[i]+= fHisto1[i-1]; InitImage(MODEPHOTO2,dbImage,IMAGEWIDTH,IMAGEHEIGHT); for(i=0;i<256;i++)

    //断点 lut[i]= fHisto1[i]*256;

     Histogram(dbImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram); for(i=0;i<256;i++)

     if(lut[i]>=256)lut[i]=255; Enhance(dbImage,dbTargetImage,IMAGEWIDTH,IMAGEHEIGHT,fHist pWork=pImage; pWork1=pImage1; ogram,fHistogram1); for(i=0;i< nHeight;i++)

     for(j=0; j< nWidth;j++, pWork++, pWork1++) Histogram(dbTargetImage,IMAGEWIDTH,IMAGEHEIGHT,fHistogram1) (*pWork1)=lut[(*pWork)]; ; }

     while(1);

    //断点

    } #define IMAGEWIDTH 80 /*直方图统计子程序*/ #define IMAGEHEIGHT 80 void Histogram(unsigned char *pImage,int nWidth,int nHeight,float extern unsigned char dbImage[IMAGEWIDTH*IMAGEHEIGHT];

    extern unsigned char dbTargetImage[IMAGEWIDTH*IMAGEHEIGHT]; else if(m_nWork2<0) m_nWork2=0; int mi,mj,m_nWork1, m_nWork2; (*pImg)=m_nWork2;

    unsigned int m_nWork,*pWork; x1=x2;x2=x3;

    unsigned char *pImg1, *pImg2, *pImg3, *pImg; x4=x5;x5=x6;

    unsigned int x1,x2,x3,x4,x5,x6,x7,x8,x9; x7=x8;x8=x9;

    //边缘检测子程序 }

    void Sobel(int nWidth,int nHeight) (*pImg)=0; pImg++;

    { }

     int i; }

     pImg= dbTargetImage;

     for(i=0;i< IMAGEWIDTH;i++, pImg++) #define IMAGEWIDTH 80 //图像的宽度

     (*pImg)=0; #define IMAGEHEIGHT 80 //图像的高度

     (*pImg)=0; #define MODEPHOTO1 1

    pImg1= dbImage; #define MODEPHOTO2 2

    pImg2= pImg1+IMAGEWIDTH; void InitImage(unsigned int nMode,unsigned char *pImage,int nWidth,int

    pImg3= pImg2+IMAGEWIDTH; nHeight);

    for(i=2;iunsigned char dbImage[IMAGEWIDTH*IMAGEHEIGHT]; { unsigned char dbTargetImage[IMAGEWIDTH*IMAGEHEIGHT];

     pImg++; int main()

     x1=(*pImg1); pImg1++;x2=(*pImg1); pImg1++; {

     x4=(*pImg2); pImg2++;x5=(*pImg2); pImg2++;

     x7=(*pImg3); pImg3++;x8=(*pImg3); pImg3++; InitImage(MODEPHOTO1,dbImage,IMAGEWIDTH,IMAGEHEIGHT);

     for(mi=2;mi//断点

     { Sobel(IMAGEWIDTH,IMAGEHEIGHT);

     x3=(*pImg1);x6=(*pImg2);x9=(*pImg3);

     m_nWork1=x7+x8+x8-x2-x2-x3; InitImage(MODEPHOTO2,dbImage,IMAGEWIDTH,IMAGEHEIGHT);

     m_nWork2=x3+x6+x6-x4-x4-x7; //断点

     if(m_nWork1< m_nWork2) Sobel(IMAGEWIDTH,IMAGEHEIGHT);

     m_nWork1= m_nWork2; while(1);

     m_nWork2= m_nWork1+x9-x1; //断点

     if(m_nWork2>255) m_nWork2=255; }

Report this document

For any questions or suggestions please email
cust-service@docsford.com