DSPRelated.com
Forums

BF533 Circular addressing

Started by ashr...@rediffmail.com April 22, 2009
hello friends, I have a problem regarding circular addressing.

My code is

.section data1;
.byte2 buffer[]={0x1234,0xabcd,0x16e6,0x4001,0x5009};

.section program;
.align 4;

i0.h=buffer;
i0.l=buffer; // circular addressing
l0=length(buffer);
b0=i0;

p0; // repeat loop 10 times
loop loop1 lc0=p0;
loop_begin loop1;
r3.l=w[i0++];
loop_end loop1;

rts;

In the memory data is stored as shown below. Assume buffer base addr is at FF900008.

buffer
FF900008:34 12 cd ab e6 16 01 40 09 50
FF900012:

i0 is pointing at FF900008.
l0 will have value 5.

In the loop for the first run i0 will be incremented to FF90000A.
for the second run i0 will be incremented to FF90000C.
for the third run i0 will be incremented to FF900009. because length 5 is reached and so it will go back to start point.
I'll never be able to access 3rd value at all.
I want to avoid this. Please let me know solution for this.
Howdy Ashritha,

You've got modular arithmetic here. If your buffer size is
10, and your step size is 5, you can only hit 2 cells from a given
starting point. Nothing else can happen! If your buffer size is 9 or 11,
then it is a different story. 11 is a better choice because it is prime
as is the step size. That implies you have a better chance of hitting
every cell, but you might have a generator position which does not.

The math behind modular arithmetic is really interesting. But you can try
things by brute force for small field sizes and check that your circular
buffer hits all cells.

Another choice is to go 2 cells, then increment your pointer by 1. Do
that 10 times, then reset it to the beginning. (or 5 times I guess will
work too)

To get into the math, look up "number theory". It's fun!

Patience, persistence, truth,
Dr. mike

On Wed, 22 Apr 2009, a...@rediffmail.com wrote:

> hello friends, I have a problem regarding circular addressing.
>
> My code is
>
> .section data1;
> .byte2 buffer[]={0x1234,0xabcd,0x16e6,0x4001,0x5009};
>
> .section program;
> .align 4;
>
> i0.h=buffer;
> i0.l=buffer; // circular addressing
> l0=length(buffer);
> b0=i0;
>
> p0; // repeat loop 10 times
> loop loop1 lc0=p0;
> loop_begin loop1;
> r3.l=w[i0++];
> loop_end loop1;
>
> rts;
>
> In the memory data is stored as shown below. Assume buffer base addr is at FF900008.
>
> buffer
> FF900008:34 12 cd ab e6 16 01 40 09 50
> FF900012:
>
> i0 is pointing at FF900008.
> l0 will have value 5.
>
> In the loop for the first run i0 will be incremented to FF90000A.
> for the second run i0 will be incremented to FF90000C.
> for the third run i0 will be incremented to FF900009. because length 5 is reached and so it will go back to start point.
> I'll never be able to access 3rd value at all.
> I want to avoid this. Please let me know solution for this.
>