beautypg.com

Motorola ColdFire MCF5281 User Manual

Page 94

background image

Enhanced Multiply-Accumulate Unit (EMAC)

3-16

Freescale Semiconductor

/* sign-extend to 48 bits before performing any scaling */

product[47:40] = {8{product[39]}}

/* sign-extend */

/* 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] = {product[39], product[39:1]}

break;

}

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 (MACSR.OMC == 1)

then /* accumulation overflow,

saturationMode enabled */

if (result[47] == 1)

then result[47:0] = 0x0000_7fff_ffff

else result[47:0] = 0xffff_8000_0000

}

/* transfer the result to the accumulator */

ACCx[47:0] = result[47:0]

}

MACSR.V = MACSR.PAVn

MACSR.N = ACCx[47]

if (ACCx[47:0] == 0x0000_0000_0000)

then MACSR.Z = 1

else MACSR.Z = 0

if ((ACCx[47:31] == 0x0000_0) || (ACCx[47:31] == 0xffff_1))

then MACSR.EV = 0

else MACSR.EV = 1

break;

case 1,3:

/* signed fractionals */

if (MACSR.OMC == 0 || MACSR.PAVn == 0)

then {

MACSR.PAVn = 0

if (sz == word)

then {if (U/Ly == 1)

then operandY[31:0] = {Ry[31:16], 0x0000}

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

0x0000}

if (U/Lx == 1)

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

This manual is related to the following products: