Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: Аппаратный умножитель
Форум разработчиков электроники ELECTRONIX.ru > Микроконтроллеры (MCs) > MSP430
condor
Почему поведение умножителя не соответсвует документации?
Из ЮзерМануала:

An overflow occurs when the sum of two negative numbers yields a result that is in the range for a positive number.
An underflow occurs when the sum of two positive numbers yields a result that is in the range for a negative number.
In both of these cases, the SUMEXT register contains the correct sign of the result, 0FFFFh for overflow and 0000h for underflow.

Но у меня получается по другому:
Код
    //RESHI=0; RESLO=0; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0x3FFF; RESLO=0x0001; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0x7FFE; RESLO=0x0002; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0xBFFD; RESLO=0x0003; SUMEXT=0xFFFF;


Т. е. при underflow SUMEXT=0xFFFF хотя должно быть SUMEXT=0.
Или я не правильно понимаю?
emark
Цитата(condor @ May 7 2006, 18:30) *
Почему поведение умножителя не соответсвует документации?
Из ЮзерМануала:

An overflow occurs when the sum of two negative numbers yields a result that is in the range for a positive number.
An underflow occurs when the sum of two positive numbers yields a result that is in the range for a negative number.
In both of these cases, the SUMEXT register contains the correct sign of the result, 0FFFFh for overflow and 0000h for underflow.

Но у меня получается по другому:
Код
    //RESHI=0; RESLO=0; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0x3FFF; RESLO=0x0001; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0x7FFE; RESLO=0x0002; SUMEXT=0;
    MACS = 0x7FFF;
    OP2 = 0x7FFF;
    //RESHI=0xBFFD; RESLO=0x0003; SUMEXT=0xFFFF;


Т. е. при underflow SUMEXT=0xFFFF хотя должно быть SUMEXT=0.
Или я не правильно понимаю?


Дык вроде в полном соответствии с Slau049a.pdf
стр 6-4

Note: The following two overflow conditions may occur when using the MACS function and should be handled by software or avoided.
1) The result of a MACS operation is positive and larger than 07FFF FFFFh. In this case, the SumExt register contains 0FFFFh and the ACC register contains a negative number (8000 0000h .... 0FFFF FFFFh).
2) The result of a MACS operation is negative and less than or equal to 07FFF FFFFh. In this case, the SumExt register contains 0000h and the ACC register contains a positive number (0000 0000h ... 07FFF FFFFh).


стр. 6-12


6.5.3 Hardware Multiplier Software Restrictions--MACS
The multiplier does not automatically detect underflow or overflow in the
MACS mode. An overflow occurs when the sum of the accumulator register
and the result of the signed multiplication exceed the maximum binary range.
The binary range of the accumulator for positive numbers is 0 to 231­1
(7FFF FFFFh) and for negative numbers is ­1 (0FFFF FFFFh) to ­231
(8000 0000h). An overflow occurs when the sum of two negative numbers
yields a result that is in the range given above for a positive number. An
underflow occurs when the sum of two positive numbers yields a result that is
in the range for a negative number.
The maximum number of successive MACS instructions without underflow or
overflow is limited by the individual application and should be determined
using a worst-case calculation. Care should then be exercised to not exceed
the maximum number or to handle the conditions accordingly.
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Invision Power Board © 2001-2025 Invision Power Services, Inc.