ECE 2560 The Hardware Multiplier Department of Electrical

  • Slides: 16
Download presentation
ECE 2560 The Hardware Multiplier Department of Electrical and Computer Engineering The Ohio State

ECE 2560 The Hardware Multiplier Department of Electrical and Computer Engineering The Ohio State University ECE 3561 - Lecture 1 1

HLL to Assembler l The multiply routine l The hardware multiplier Details on it

HLL to Assembler l The multiply routine l The hardware multiplier Details on it l How to use it l Speed l ECE 3561 - Lecture 1 2

Had done a multiply routine Dumb – recursive add to multiply l Better –

Had done a multiply routine Dumb – recursive add to multiply l Better – Shift and add – finite fixed time l Even better – l l 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 also peripheral devices, one of which is a multiplier and available on some versions. (reference documentation) ECE 3561 - Lecture 1 3

The hardware multiplier l Supports Unsigned multiply l Signed multiply l Unsigned multiply accumulate

The hardware multiplier l Supports Unsigned multiply l Signed multiply l Unsigned multiply accumulate l Signed multiply accumulate l l How l is operation determined? The type of operation is selected by the address the first operand is written to. ECE 3561 - Lecture 1 4

The operands l The first operand written to the multiplier periperal. l Determines the

The operands l The first operand written to the multiplier periperal. l Determines the operation l l l The second operand OP 2 l l 0130 h – multiply (unsigned) (MPY) 0132 h – signed multiply (MPYS) 0134 h – multiply accumulate (unsigned) (MAC) 0136 h – signed multiply accumulate (MACS) Written to address 0138 h All are words (16 bits) and are read/write locations. ECE 3561 - Lecture 1 5

The results l When using indirect or indirect autoincrement addressing mode to access the

The results l When using indirect or indirect autoincrement addressing mode to access the result (32 bits), at least one instruction is needed between loading of OP 2 and accessing one of the result registers, RESLO, RESHI RESLO – address 013 Ah l RESHI – address 013 Ch l ECE 3561 - Lecture 1 6

Accessing result example l Accessing results with indirect addressing l l l mov mov

Accessing result example l Accessing results with indirect addressing l l l mov mov nop mov #RESLO, R 5 &oper 1, &MPY &oper 2, &OP 2 @R 5+, &svreslo @R 5, &svreshi ECE 3561 - Lecture 1 7

The overall architecture l Figure 7 -1 from manual ECE 3561 - Lecture 1

The overall architecture l Figure 7 -1 from manual ECE 3561 - Lecture 1 8

Other concerns l Interrupts l l The multiplier does not use interrupts However –

Other concerns l Interrupts l l 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? l Disable interrupts before use if there is an interrupt service routine that uses the multiplier. ECE 3561 - Lecture 1 9

Other concerns (2) l The SUMEXT register contents – l l at address 013

Other concerns (2) l The SUMEXT register contents – l l at address 013 Eh SUMEXT contains for l l l l MPY – always 0000 h MPYS – result positive or zero – 0000 h result negative – FFFFh MAC – no carry for result – 0000 h result has carry – 0001 h MACS - result positive or zero – 0000 h result negative – FFFFh ECE 3561 - Lecture 1 10

Execution time l If interrupts are disabled (DINT) – 1 cycle l Set up

Execution time l If interrupts are disabled (DINT) – 1 cycle l Set up Rx for results addr – 2 cycles l Move operands to hw multipler l - 6 each – 12 cycles total l The NOP – 1 cycle l Retrieve results – 12 cycles l Re-enable interrupt (EINT) – 1 cycle l TOTAL TIME = 29 cycles ECE 3561 - Lecture 1 11

Comparison l Hardware multiplier – 29 cycles l Shift and multiply routine – 83

Comparison l Hardware multiplier – 29 cycles l Shift and multiply routine – 83 cycles l As is typical of such operations, dedicated hardware support can improve performance. ECE 3561 - Lecture 1 12

Demonstration of use l. A short program can be written to demonstrate use. -

Demonstration of use l. A short program can be written to demonstrate use. - DEMO l This also demonstrates the use of I/O ports as the hardware multiplier is a peripheral. ECE 3561 - Lecture 1 13

The program l l l mov mov nop mov #0 x 013 A, R

The program l l l mov mov nop mov #0 x 013 A, R 5 #3, &0 x 0130 #3, &0 x 0138 @R 5+, R 6 @R 5, R 7 ECE 3561 - Lecture 1 14

What happened l It does not seem to work. What to do? l Look

What happened l It does not seem to work. What to do? l Look at the documentation. l msp 430 g 2553 Data Sheet ECE 3561 - Lecture 1 15

Summary - Assignment l When encountering issues look to documentation on the specific chip.

Summary - Assignment l When encountering issues look to documentation on the specific chip. l Manual are for the family typically. ECE 3561 - Lecture 1 16