5 Multiply accumulate
The data items from each vector are read from memory in turn and the products
formed between corresponding pairs from the two vectors. Each of these products is
added into the running accumulator value. The instruction completes with 3 values in
the stack - the final accum ulator value and the two updated data pointers.
Four control values are held in the status register, as shown in Table 5.2.
Field
mac_count
mac_buffer
mac_scale
mac_mode
Size
Meaning
8 bits The number of steps (from 1 to 256 items).
3 bits The size code for the data buffer within which the data vector lies.
2 bits Shift control for scaling coefficient v alues.
1 bit Accumulator format - 0 indicates 16-bit (short) and 1 indicates 32-bit (long) value.
Table 5.2 smacloop status register fields
These values are initialized by the smacinit instruction. The smacinit instruction takes
a packed control word in Areg, extracts the control fields and loads these into the
status register. For smacinit, Areg is organized as shown in Table 5.3.
Field
mac_count
mac_buffer
mac_scale
mac_mode
Size
8 bits
3 bits
2 bits
1 bit
Least significant
bit
0
8
11
13
Most significant
bit
7
10
12
13
Table 5.3 smacinit Areg format
These status register values are global and are not saved when a process is times-
liced or descheduled. If more than one process is performing short multiply accumu-
late loops then the values should be reloaded by the process code using smacinit
after each timeslice and stop instruction.
5.3.1 X buffer size
The X vector buffer size is determined by the mac_buffer control field, which may take
the values 0 to 7. When mac_buffer is 0, then no address wrapping takes place, i.e.
the buffer is assumed to be of infinite size. Otherwise, the buffer size is 2mac_buffer+2,
as shown in Table 5.3. The X buffer must be aligned to a multiple of its own size, so a
buffer of N bytes must start at an address whose value is a multiple of N bytes.
5.3.2 Number of steps
The mac_count control field in the status register deter mines the number of multiply-
accumulate steps for smacloop. This is an unsigned 8-bit integer. The value zero
signifies 256 steps; otherwise the value of mac_count is the number of steps.
57/205
®