beautypg.com

Motorola ColdFire MCF5281 User Manual

Page 96

background image

Enhanced Multiply-Accumulate Unit (EMAC)

3-18

Freescale Semiconductor

then operandX[31:0] = {0x0000, Rx[31:16]}

else operandX[31:0] = {0x0000, Rx[15:0]}

}

else {operandY[31:0] = Ry[31:0]

operandX[31:0] = Rx[31:0]

}

/* perform the multiply */

product[63:0] = operandY[31:0] * operandX[31:0]

/* check for product overflow */

if (product[63:40] != 0x0000_00)

then {

/* product overflow */

MACSR.PAVn = 1

MACSR.V = 1

if (inst == MSAC and and MACSR.OMC == 1)

then result[47:0] = 0x0000_0000_0000

else if (MACSR.OMC == 1)

then /* overflowed MAC,

saturationMode enabled */

result[47:0] = 0xffff_ffff_ffff

}

/* zero-fill to 48 bits before performing any scaling */

product[47:40] = 0

/* zero-fill upper byte */

/* scale product before combining with accumulator */

switch (SF)

/* 2-bit scale factor */

{

case 0:

/* no scaling specified */

break;

case 1:

/* SF = “<< 1” */

product[40:0] = {product[39:0], 0}

break;

case 2:

/* reserved encoding */

break;

case 3:

/* SF = “>> 1” */

product[39:0] = {0, product[39:1]}

break;

}

/* combine with accumulator */

if (MACSR.PAVn == 0)

then {if (inst == MSAC)

then result[47:0] = ACCx[47:0] - product[47:0]

else result[47:0] = ACCx[47:0] + product[47:0]

}

/* check for accumulation overflow */

if (accumulationOverflow == 1)

then {MACSR.PAVn = 1

MACSR.V = 1

if (inst == MSAC and and MACSR.OMC == 1)

then result[47:0] = 0x0000_0000_0000

else if (MACSR.OMC == 1)

then /* overflowed MAC,

saturationMode enabled */

MCF5282 and MCF5216 ColdFire Microcontroller User’s Manual, Rev. 3

This manual is related to the following products: