21 Multiplier/Divider (COPRO)
21-4
Seiko epson Corporation
S1C17F13 TeChniCal Manual
(Rev. 1.0)
Example:
ld.cw %r0,0x8
;
Sets the mode (unsigned division mode and 16 low-order bits output mode).
ld.ca %r0,%r1
;
Performs “res = %r0
÷
%r1” and loads the 16 low-order bits of the result (quotient) to %r0.
ld.cw %r0,0x13
;
Sets the mode (operation result read mode and 16 high-order bits output mode).
ld.ca %r1,%r0
;
Loads the 16 high-order bits of the result (residue) to %r1.
MAC
21.5
The MAC (multiplication and accumulation) function performs “A (32 bits) = B (16 bits)
×
C (16 bits) + A (32
bits).”
The following shows a procedure to perform a MAC operation:
1. Set the initial value (A) to the operation result register.
• To clear the operation result register (A = 0):
Set the mode to 0x00 (initialize mode 0). (It is not necessary to send 0x00 to COPRO with another instruc-
tion.)
• To load a 16-bit value to the operation result register:
Set the operation mode to 0x01 (initialize mode 1) and then send the initial value (16 bits) to COPRO using
a “
ld.cf
” instruction.
• To load a 32-bit value to the operation result register:
Set the operation mode to 0x02 (initialize mode 2) and then send the initial value (32 bits) to COPRO using
a “
ld.cf
” instruction.
2. Set the mode to 0x07 (signed MAC, 16 low-order bits output mode).
3. Repeat sending the 16-bit multiplicand (B) and 16-bit multiplier (C) to COPRO the number of times required
using a “
ld.ca
” instruction.
4. Read the one-half result (16 low-order bits = A[15:0]) and the flag status.
5. Set the mode to 0x13 (operation result read, 16 high-order bits output mode).
6. Read another one-half result (16 high-order bits = A[31:16]).
Operation result
register
Selector
S1C17 Core
COPRO
Argument 2
Argument 1
16 bits
32 bits
Coprocessor
output (16 bits)
Flag output
5.1 Data Path in Initialize Mode
Figure 21.