160 likes | 278 Views
ECE 2560. The Hardware Multiplier. Department of Electrical and Computer Engineering The Ohio State University. HLL to Assembler. The multiply routine The hardware multiplier Details on it How to use it Speed. Had done a multiply routine.
E N D
ECE 2560 The Hardware Multiplier Department of Electrical and Computer Engineering The Ohio State University ECE 3561 - Lecture 1
HLL to Assembler • The multiply routine • The hardware multiplier • Details on it • How to use it • Speed ECE 3561 - Lecture 1
Had done a multiply routine • Dumb – recursive add to multiply • Better – Shift and add – finite fixed time • Even better – • a dedicated hardware multiplier • MSP 430 does not have a multiplier or multiply instruction • MSP 430 chip has more than a small processor on it. There are also peripheral devices, one of which is a multiplier and available on some versions. (reference documentation) ECE 3561 - Lecture 1
The hardware multiplier • Supports • Unsigned multiply • Signed multiply • Unsigned multiply accumulate • Signed multiply accumulate • How is operation determined? • The type of operation is selected by the address the first operand is written to. ECE 3561 - Lecture 1
The operands • The first operand written to the multiplier periperal. • Determines the operation • 0130h – multiply (unsigned) (MPY) • 0132h – signed multiply (MPYS) • 0134h – multiply accumulate (unsigned) (MAC) • 0136h – signed multiply accumulate (MACS) • The second operand OP2 • Written to address 0138h • All are words (16 bits) and are read/write locations. ECE 3561 - Lecture 1
The results • When using indirect or indirect autoincrement addressing mode to access the result (32 bits), at least one instruction is needed between loading of OP2 and accessing one of the result registers, RESLO, RESHI • RESLO – address 013Ah • RESHI – address 013Ch ECE 3561 - Lecture 1
Accessing result example • Accessing results with indirect addressing • mov #RESLO,R5 • mov &oper1,&MPY • mov &oper2,&OP2 • nop • mov @R5+,&svreslo • mov @R5,&svreshi ECE 3561 - Lecture 1
The overall architecture • Figure 7-1 from manual ECE 3561 - Lecture 1
Other concerns • Interrupts • The multiplier does not use interrupts • However – Using the hardware multiplier requires several instruction to set up the multiplier and get results. • If an interrupt occurs during this period and interrupt routine uses multiplier then results will be invalid. • SOLUTION? • Disable interrupts before use if there is an interrupt service routine that uses the multiplier. ECE 3561 - Lecture 1
Other concerns (2) • The SUMEXT register contents – • at address 013Eh • SUMEXT contains for • MPY – always 0000h • MPYS – result positive or zero – 0000h • result negative – FFFFh • MAC – no carry for result – 0000h • result has carry – 0001h • MACS - result positive or zero – 0000h • result negative – FFFFh ECE 3561 - Lecture 1
Execution time • If interrupts are disabled (DINT) – 1 cycle • Set up Rx for results addr – 2 cycles • Move operands to hwmultipler • - 6 each – 12 cycles total • The NOP – 1 cycle • Retrieve results – 12 cycles • Re-enable interrupt (EINT) – 1 cycle • TOTAL TIME = 29 cycles ECE 3561 - Lecture 1
Comparison • Hardware multiplier – 29 cycles • Shift and multiply routine – 83 cycles • As is typical of such operations, dedicated hardware support can improve performance. ECE 3561 - Lecture 1
Demonstration of use • A short program can be written to demonstrate use. - DEMO • This also demonstrates the use of I/O ports as the hardware multiplier is a peripheral. ECE 3561 - Lecture 1
The program • mov #0x013A,R5 • mov #3,&0x0130 • mov #3,&0x0138 • nop • mov @R5+,R6 • mov @R5,R7 ECE 3561 - Lecture 1
What happened • It does not seem to work. What to do? • Look at the documentation. • msp430g2553 Data Sheet ECE 3561 - Lecture 1
Summary - Assignment • When encountering issues look to documentation on the specific chip. • Manual are for the family typically. ECE 3561 - Lecture 1