Freescale Semiconductor ColdFire MCF52210 User Manual

Page 87

Advertising
background image

Multiply-Accumulate Unit (MAC)

MCF52211 ColdFire® Integrated Microcontroller Reference Manual, Rev. 2

Freescale Semiconductor

4-11

else result[31:0] = 0x7fff_ffff

}

/* scale product before combining with accumulator */

switch (SF)

/* 2-bit scale factor */

{

case 0:

/* no scaling specified */

break;

case 1:

/* SF = “<< 1” */

if (product[31] ^ product[30])

then {MACSR.V = 1

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

then if (product[63] == 1)

then result[31:0] = 0x7fff_ffff

else result[31:0] = 0x8000_0000

else if (MACSR.OMC == 1)

then /* overflowed MAC,

saturationMode enabled */

if (product[63] == 1)

then result[31:0] = 0x8000_0000

else result[31:0] = 0x7fff_ffff

}

else product[31:0] = {product[30:0], 0}

break;

case 2:

/* reserved encoding */

break;

case 3:

/* SF = “>> 1” */

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

then product[31:0] = {product[31], product[31:1]}

break;

}

/* combine with accumulator */

if (MACSR.V == 0)

then {if (inst == MSAC)

then result[31:0] = acc[31:0] - product[31:0]

else result[31:0] = acc[31:0] + product[31:0]

}

/* check for accumulation overflow */

if (accumulationOverflow == 1)

then {MACSR.V = 1

if (MACSR.OMC == 1)

then /* accumulation overflow,

saturationMode enabled */

if (result[31] == 1)

then result[31:0] = 0x7fff_ffff

else result[31:0] = 0x8000_0000

}

/* transfer the result to the accumulator */

acc[31:0] = result[31:0]

MACSR.N = result[31]

if (result[31:0] == 0x0000_0000)

then MACSR.Z = 1

else MACSR.Z = 0

}

Advertising
This manual is related to the following products: