Digital Signal Processing Reference
In-Depth Information
reaches the end or “bottom” location of a circular buffer that contains the last
element in the buffer, and is then incremented, the pointer is automatically wrapped
around or points to the beginning or “top” location of the buffer that contains the
first element.
Two independent circular buffers are available using BK0 and BK1 within
the AMR. The eight registers A4 through A7 and B4 through B7, in conjunction
with the two .D units, can be used as pointers (all registers can be used for
linear addressing). The following code segment illustrates the use of a circular buffer
using register B2 (only side B can be used) to set the appropriate values within
AMR:
;lower 16 bits to B2. Select A5 as pointer
MVKL .S2 0x0004,B2
;upper 16 bits to B2. Select BK0, set N
=
5
MVKH .S2 0x0005,B2
;move 32 bits of B2 to AMR
MVC
.S2 B2,AMR
The two move instructions MVKL and MVKH (using the .S unit) move 0x0004
into the 16 LSBs of register B2 and 0x0005 into the 16 most significant bits (MSBs)
of B2. The MVC (move constant) instruction is the only instruction that can access
the AMR and the other control registers (shown in Appendix B) and executes only
on the B side in conjunction with the functional units and registers on side B. A 32-
bit value is created in B2, which is then transferred to AMR with the instruction
MVC to access AMR [6].
The value 0x0004 = (0100) b into the 16 LSBs of AMR sets bit 2 (the third
bit) to 1 and all other bits to 0. This sets the mode to 01 and selects register A5 as
the pointer to a circular buffer using block BK0 (see Figure B.1).
Table 3.4 shows the modes associated with registers A4 through A7 and B4
through B7. The value 0x0005 = (0101) b into the 16 MSBs of AMR sets bits 16
and 18 to 1 (other bits to 0). This corresponds to the value of N used to select the
size of the buffer as 2 N +1
64 bytes using BK0. For example, if a buffer size of 128
is desired using BK0, the upper 16 bits of AMR are set to (0110) b = 0x0006 .If
assembly code is used for the circular buffer, as execution returns to a calling C
function, AMR needs to be reinitialized to the default linear mode. Hence the
pointer's address must be saved.
=
TABLE 3.4
AMR Mode and Description
Mode
Description
0 0
For linear addressing (default on reset)
0 1
For circular addressing using BK0
1 0
For circular addressing using BK1
1 1
Reserved
Search WWH ::




Custom Search