4 Data Transfer
4 – 8
It is also possible to initialize a complete array/buffer from a data file,
using the .INIT directive:
.INIT coefficients: <filename.dat>;
This assembler directive reads the values from the file filename.dat into the
array at link time. This feature is supported only in the simulator — data
cannot be loaded directly into on-chip data memory by the hardware
booting sequence.
An array or data buffer with a length of one is a simple single-word
variable, and is declared in this way:
.VAR/DM coefficient;
4.3.2
Circular Buffers
A common requirement in DSP is the circular buffer. This is directly
implemented by the processors’ data address generators (DAGs), using
the L (length) registers. First, you must declare the buffer as circular:
.VAR/DM/CIRC coefficients[128];
This identifies it to the linker for placement on the proper address
boundary. Next, you must initialize the L register, typically using the
assemblers’s % operator (or a constant) and, in the example below, the I
register and M register:
L0=%coefficients;
{length of circular buffer}
I0=^coefficients;
{point to first address of buffer}
M0=1;
{increment by 1 location each time}
Now a statement like
MX0=DM(I0,M0);
{load MX0 from buffer}
placed in a loop, cycles continuously through coefficients and wraps
around automatically.