DSPRelated.com
Forums

Setting up circular buffers

Started by male_uk00 June 20, 2004


I have set up circular buffers for both the left and right channels
for a simple band pass FIR filter i get an error when i uses the
parralell multiply and accumalate instruction in my code

undefined or invalid op code code is below any idears whats wrong??

.include "c3xmmrs.asm" ;include memory map
.start ".data",0x809800 ;start address of data

.data
HN .float -0.000705659
.float -0.003488302
.float -0.008788407
.float -0.014505267
.float -0.015254676
.float -0.006203771
.float 0.011028171 S0_run .word 0xEBC0000 ;Set global control register
for 32bit
LRCIN .set 0x80A000 ;LRCIN holds the address of
the CPLD
HN_ADDR .word HN ;starting address of HN array
XN_ADDR_L .word XN_L ;starting address of XN_L
buffer
XN_ADDR_R .word XN_R ;starting address of XN_R
buffer
XB_ADDR_L .word XN_L+LENGTH-1 ;last (bottom) address of XN_L
XB_ADDR_R .word XN_R+LENGTH-1 ;last (bottom) address of XN_R
LENGTH .set 32 ;size of circular buffer

.brstart "XN_BUFFER_L",32 ;align a buffer of size 32
XN_L .sect "XN_BUFFER_L" ;buffer section of XN
.loop LENGTH ;loop length times
.float 0 ;init all XN values to zero
.endloop ;end of loop .brstart "XN_BUFFER_R",32 ;align a buffer of size 32
XN_R .sect "XN_BUFFER_R" ;buffer section of XN
.loop LENGTH ;loop length times
.float 0 ;init all XN values to zero
.endloop .entry BEGIN ; start of code
BEGIN ldp @stack ; Set stack space
ldi @stack,SP ;
ldp T0_ctrl ; Use kernel data page and stack

ldp HN_ADDR ;init to data page 128
ldi @XB_ADDR_L,AR2 ;AR1=bottom address XN_L buffer
ldi @HN_ADDR,AR1 ;AR2=starting address of HN
array
ldi @XB_ADDR_R,AR4 ;AR4=bottom address XN_R buffer
ldi LENGTH,BK ;BK2, size of circular buffer
ldi @S0_rdata,R0 ;load value at address of SP0 receive
data into R1 direct
lsh 12,R0 ;left shift for sign extention
FLOAT R0 ;convert interger to floating point
STF R0,*AR2++% ;store value at bottom of XN_L
buffer
LDF 0,R0 ;init R0=0
LDF 0,R1 ;init R1=0
RPTS LENGTH-1 ;execute next 2 instr 0-31 times
MPYF3 *AR1++,*AR2++%,R0 ;R0=(AR1)*(AR2)
|| ADDF3 R0,R1,R1 ;in parallel with accumulation=>R1
ADDF R0,R1 ;last accumulation => R1
FIX R1,R0
ash -12,R0 ;right shift keeping the sign bit
sti R0,@S0_xdata



Hi

The problem here is that the destination in the ADDF3 part of the instruction is limited to either R2 or R3 (the MPYF3 accepts R0,R1 as destinations). 
 

        MPYF3   *AR1++,*AR2++%,R0  ;R0=(AR1)*(AR2)
||      ADDF3   R0,R2,R2           ;in parallel with accumulation=>R1

Best regards
Keith Larson


male_uk00 wrote:


I have set up circular buffers for both the left and right channels
for a simple band pass FIR filter i get an error when i uses the
parralell multiply and accumalate instruction in my code

undefined or invalid op code code is below any idears whats wrong??

         .include  "c3xmmrs.asm"               ;include memory map 
         .start    ".data",0x809800            ;start address of data
    
           .data
HN         .float      -0.000705659
           .float      -0.003488302
           .float      -0.008788407
           .float      -0.014505267
           .float      -0.015254676
           .float      -0.006203771
           .float      0.011028171 S0_run        .word    0xEBC0000        ;Set global control register
for 32bit
LRCIN         .set     0x80A000         ;LRCIN holds the address of
the CPLD 
HN_ADDR       .word    HN               ;starting address of HN array
XN_ADDR_L     .word    XN_L             ;starting address of XN_L
buffer
XN_ADDR_R     .word    XN_R             ;starting address of XN_R
buffer
XB_ADDR_L     .word    XN_L+LENGTH-1    ;last (bottom) address of XN_L
XB_ADDR_R     .word    XN_R+LENGTH-1    ;last (bottom) address of XN_R
LENGTH        .set     32               ;size of circular buffer
         
              .brstart "XN_BUFFER_L",32   ;align a buffer of size 32
XN_L          .sect    "XN_BUFFER_L"      ;buffer section of XN
              .loop    LENGTH             ;loop length times
              .float   0                  ;init all XN values to zero
              .endloop                    ;end of loop              .brstart "XN_BUFFER_R",32   ;align a buffer of size 32
XN_R         .sect    "XN_BUFFER_R"      ;buffer section of XN
             .loop    LENGTH             ;loop length times
             .float   0                  ;init all XN values to zero
             .endloop             .entry BEGIN                ; start of code   
BEGIN     ldp   @stack                ; Set stack space
          ldi   @stack,SP             ;
          ldp   T0_ctrl               ; Use kernel data page and stack
    
          ldp   HN_ADDR               ;init to data page 128
          ldi   @XB_ADDR_L,AR2        ;AR1=bottom address XN_L buffer
          ldi   @HN_ADDR,AR1          ;AR2=starting address of HN
array
          ldi   @XB_ADDR_R,AR4        ;AR4=bottom address XN_R buffer
          ldi   LENGTH,BK             ;BK2, size of circular buffer
ldi     @S0_rdata,R0       ;load value at address of SP0 receive
data into R1 direct
        lsh     12,R0              ;left shift for sign extention
        FLOAT   R0                 ;convert interger to floating point
        STF     R0,*AR2++%         ;store value at bottom of XN_L
buffer     
        LDF     0,R0               ;init R0=0
        LDF     0,R1               ;init R1=0
        RPTS    LENGTH-1           ;execute next 2 instr 0-31 times
        MPYF3   *AR1++,*AR2++%,R0  ;R0=(AR1)*(AR2)
||      ADDF3   R0,R1,R1           ;in parallel with accumulation=>R1
        ADDF    R0,R1              ;last accumulation => R1
        FIX     R1,R0
        ash    -12,R0              ;right shift keeping the sign bit
        sti     R0,@S0_xdata  



I seem to recall Keith mentioning that there will or might be a new chip coming out in the C3x line.  Any word on that?  Is this in the works, or just in the pre-planning stage...  or just a wish list? 
Rick Collins

r...@arius.com

Arius - A Signal Processing Solutions Company
Specializing in DSP and FPGA design       http://www.arius.com
4 King Ave                                301-682-7772 Voice
Frederick, MD 21701-3110                  301-682-7666 FAX