The present invention relates to systems and methods in a device such as a processor, including microprocessors and controllers. More particularly, the present invention relates to systems and methods for overflow and saturation processing during accumulator operations.
Processors, including microprocessors, digital signal processors and microcontrollers, typically include an accumulator that stores the results of operations performed by the processor. Common operations performed include addition and subtraction. Addition and subtraction operations may cause the result of the operation to exceed the maximum value of the accumulator.
In an accumulator, the most significant bit of the accumulator can be used to represent the sign of the number stored in the remaining bits of the accumulator. For example, in a 32 bit accumulator the most significant bit, b31 can represent the sign of the number stored in bits b30-b0. Using such an arrangement, the accumulator can store a maximum negative number of 0x80000000, where “0x” denotes hexadecimal. The accumulator can store a maximum positive number of 0x7FFFFFFF. Typical saturation processing in the exemplary 32 bit accumulator sets the 32 bit accumulator to the maximum positive number, 0x7FFFFFFF, or the maximum negative number 0x80000000 as the case may require. To illustrate, suppose the following two numbers are added, 0x007FFFF000 and 0x0000001020. The result is 0x0080000020, with an overflow of the result into the sign bit, b31. Because the result of adding two positive numbers overflowed, the maximum positive number 0x007FFFFFFF is stored in the accumulator.
The above common saturation operation, however, causes the result to be truncated. That is, the actual result of the operation is lost and an approximate result represented by a selected one of the predetermined constants is stored in the accumulator. Thus, the accumulator value after being set by the saturation processing is erroneous. It is desirable to minimize the error introduced by the saturation processing.
It is an object of the present invention to provide an efficient saturation processing system and method.
It is another object of the present invention to provide a saturation processing system and method that reduces the error introduced by the saturation processing.
It is a further object of the present invention to provide a saturation processing system and method that allows programmers the flexibility of additional accuracy in overflow and saturation processing.
It is still another object of the present invention to provide a saturation processing system and method that provides enhanced computational accuracy in saturation processing of an overflow condition.
It is still a further object of the present invention to provide a saturation processing system and method that can be selectively enabled and disabled.
To achieve the above an other objects, the present invention provides a system for overflow and saturation processing, comprising: an adder, operatively connected to receive first and second operands, and connected to add the operands; an accumulator, operatively connected to store at least a portion of the added operands or at least a portion of a selected one of predetermined constants based on control signals; guard bits, operatively connected to store the remaining portion of the added operands or the remaining portion of the selected one of predetermined constants based on the control signals; overflow logic operatively connected to the accumulator and to the guard bits so as to indicate overflow of the accumulator; and saturation logic, operatively connected to the adder, to the guard bits, and connected to provide the control signals based on at least a portion of the added operands at least a portion of the guard bits.
To achieve the above and other object, the present invention also provides a method for overflow and saturation processing in a processor including guard bits and an accumulator, comprising: adding operands to form a result; comparing a portion of the result with a portion of the guard bits; storing either a portion of the result in the accumulator and the remaining portion of the result in the guard bits, or a portion of a selected predetermined constant in the accumulator and the remaining portion of the predetermined constant in the guard bits in accordance with an enable signal and the result of the comparison.
NAND gate 70 and OR gate 75 detect an overflow condition of the accumulator. The output of a multiplexer 80 indicates whether the operation performed by adder 90. The output of multiplexer 80 can be applied to a status register, not shown. The state of the overflow bit in the status register can change for each operation performed by adder 90.
In addition, together gates 100-145 function as a logic means that is responsive to the comparison of the guard bits 65 and the result of the operation performed by the adder 90 so as to selectively provide the control signals so that the accumulator stores at least a portion of the added operands and the guard bits store the remaining portion of the added operands, or the accumulator stores at least a portion of a predetermined constant (e.g., 0x7FFFFFFFFF) and the guard bits store the remaining portion of the predetermined constant (e.g., 0x7FFFFFFFFF). Table 1 illustrates the logic conditions that give rise to a saturation condition in the illustrative embodiment shown in
output of an OR gate 150 indicates if saturation condition has occurred. Typically, the output of the OR gate 150 is applied to a saturation bit in a status register (not shown). It is common that the saturation bit of the status register be set on the occurrence of saturation and remain set until reset by an instruction executed by the processor. Table 2 below represents logical operation of the multiplexer 95.
The output of the multiplexer 95 is stored in the guard bits 65 and the accumulator 60.
While specific embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that changes may be made to those embodiments without departing from the spirit and scope of the invention that is defined by the following claims.
| Number | Name | Date | Kind |
|---|---|---|---|
| 3771146 | Cotton et al. | Nov 1973 | A |
| 3781810 | Downing | Dec 1973 | A |
| 3886524 | Appelt | May 1975 | A |
| 3930253 | Maida | Dec 1975 | A |
| 4025771 | Lynch et al. | May 1977 | A |
| 4074353 | Woods et al. | Feb 1978 | A |
| 4090250 | Carlson et al. | May 1978 | A |
| 4323981 | Nakamura | Apr 1982 | A |
| 4379338 | Nishitani et al. | Apr 1983 | A |
| 4398244 | Chu et al. | Aug 1983 | A |
| 4408274 | Wheatley et al. | Oct 1983 | A |
| 4451885 | Gerson et al. | May 1984 | A |
| 4472788 | Yamazaki | Sep 1984 | A |
| 4481576 | Bicknell | Nov 1984 | A |
| 4488252 | Vassar | Dec 1984 | A |
| 4511990 | Hagiwara et al. | Apr 1985 | A |
| 4556938 | Parker et al. | Dec 1985 | A |
| 4615005 | Maejima et al. | Sep 1986 | A |
| 4626988 | George | Dec 1986 | A |
| 4709324 | Kloker | Nov 1987 | A |
| 4730248 | Watanabe et al. | Mar 1988 | A |
| 4742479 | Kloker et al. | May 1988 | A |
| 4768149 | Konopik et al. | Aug 1988 | A |
| 4779191 | Greenblatt | Oct 1988 | A |
| 4782457 | Cline | Nov 1988 | A |
| 4800524 | Roesgen | Jan 1989 | A |
| 4807172 | Nukiyama | Feb 1989 | A |
| 4829420 | Stahle | May 1989 | A |
| 4829460 | Ito | May 1989 | A |
| 4839846 | Hirose et al. | Jun 1989 | A |
| 4841468 | Miller et al. | Jun 1989 | A |
| 4872128 | Shimizu | Oct 1989 | A |
| 4882701 | Ishii | Nov 1989 | A |
| 4926371 | Vassilliadis et al. | May 1990 | A |
| 4941120 | Brown et al. | Jul 1990 | A |
| 4943940 | New | Jul 1990 | A |
| 4945507 | Ishida et al. | Jul 1990 | A |
| 4959776 | Deerfield et al. | Sep 1990 | A |
| 4977533 | Miyabayashi et al. | Dec 1990 | A |
| 4984213 | Abdoo et al. | Jan 1991 | A |
| 5007020 | Inskeep | Apr 1991 | A |
| 5012441 | Retter | Apr 1991 | A |
| 5032986 | Pathak et al. | Jul 1991 | A |
| 5034887 | Yasui et al. | Jul 1991 | A |
| 5038310 | Akagiri et al. | Aug 1991 | A |
| 5040178 | Lindsay et al. | Aug 1991 | A |
| 5056004 | Ohde et al. | Oct 1991 | A |
| 5099445 | Studor et al. | Mar 1992 | A |
| 5101484 | Kohn | Mar 1992 | A |
| 5117498 | Miller et al. | May 1992 | A |
| 5121431 | Wiener | Jun 1992 | A |
| 5122981 | Taniguchi | Jun 1992 | A |
| 5155823 | Tsue | Oct 1992 | A |
| 5177373 | Nakamura | Jan 1993 | A |
| 5197023 | Nakayama | Mar 1993 | A |
| 5197140 | Balmer | Mar 1993 | A |
| 5206940 | Murakami et al. | Apr 1993 | A |
| 5212622 | Cocanougher et al. | May 1993 | A |
| 5212662 | Cocanougher et al. | May 1993 | A |
| 5218239 | Boomer | Jun 1993 | A |
| 5239654 | Ing-Simmons et al. | Aug 1993 | A |
| 5276634 | Suzuki et al. | Jan 1994 | A |
| 5282153 | Bartkowiak et al. | Jan 1994 | A |
| 5327543 | Miura et al. | Jul 1994 | A |
| 5327566 | Forsyth | Jul 1994 | A |
| 5375080 | Davies | Dec 1994 | A |
| 5379240 | Byrne | Jan 1995 | A |
| 5386563 | Thomas | Jan 1995 | A |
| 5392435 | Masui et al. | Feb 1995 | A |
| 5418976 | Iida | May 1995 | A |
| 5422805 | McIntyre et al. | Jun 1995 | A |
| 5432943 | Mitsuishi | Jul 1995 | A |
| 5448703 | Amini et al. | Sep 1995 | A |
| 5448706 | Fleming et al. | Sep 1995 | A |
| 5450027 | Gabara | Sep 1995 | A |
| 5463749 | Wertheizer et al. | Oct 1995 | A |
| 5469377 | Amano | Nov 1995 | A |
| 5471600 | Nakamoto | Nov 1995 | A |
| 5497340 | Uramoto et al. | Mar 1996 | A |
| 5499380 | Iwata et al. | Mar 1996 | A |
| 5504916 | Murakami et al. | Apr 1996 | A |
| 5506484 | Munro et al. | Apr 1996 | A |
| 5517436 | Andreas et al. | May 1996 | A |
| 5525874 | Mallarapu et al. | Jun 1996 | A |
| 5548544 | Matheny et al. | Aug 1996 | A |
| 5561384 | Reents et al. | Oct 1996 | A |
| 5561619 | Watanabe et al. | Oct 1996 | A |
| 5564028 | Swoboda et al. | Oct 1996 | A |
| 5568380 | Broadnax et al. | Oct 1996 | A |
| 5568412 | Han et al. | Oct 1996 | A |
| 5596760 | Ueda | Jan 1997 | A |
| 5600813 | Nakagawa et al. | Feb 1997 | A |
| 5611061 | Yasuda | Mar 1997 | A |
| 5619711 | Anderson | Apr 1997 | A |
| 5623646 | Clarke | Apr 1997 | A |
| 5638524 | Kiuchi et al. | Jun 1997 | A |
| 5642516 | Hedayat et al. | Jun 1997 | A |
| 5649146 | Riou | Jul 1997 | A |
| 5651121 | Davies | Jul 1997 | A |
| 5657484 | Scarrá | Aug 1997 | A |
| 5659700 | Chen et al. | Aug 1997 | A |
| 5682339 | Tam | Oct 1997 | A |
| 5689693 | White | Nov 1997 | A |
| 5694350 | Wolrich et al. | Dec 1997 | A |
| 5696711 | Makineni | Dec 1997 | A |
| 5701493 | Jaggar | Dec 1997 | A |
| 5706460 | Craig et al. | Jan 1998 | A |
| 5706466 | Dockser | Jan 1998 | A |
| 5715470 | Asano et al. | Feb 1998 | A |
| 5737570 | Koch | Apr 1998 | A |
| 5740095 | Parant | Apr 1998 | A |
| 5740419 | Potter | Apr 1998 | A |
| 5740451 | Muraki et al. | Apr 1998 | A |
| 5748516 | Goddard et al. | May 1998 | A |
| 5748970 | Miyaji et al. | May 1998 | A |
| 5764555 | McPherson et al. | Jun 1998 | A |
| 5765216 | Weng et al. | Jun 1998 | A |
| 5765218 | Ozawa et al. | Jun 1998 | A |
| 5774711 | Henry et al. | Jun 1998 | A |
| 5778237 | Yamamoto et al. | Jul 1998 | A |
| 5778416 | Harrison et al. | Jul 1998 | A |
| 5790443 | Shen et al. | Aug 1998 | A |
| 5808926 | Gorshtein et al. | Sep 1998 | A |
| 5812439 | Hansen | Sep 1998 | A |
| 5812868 | Moyer et al. | Sep 1998 | A |
| 5815693 | McDermott et al. | Sep 1998 | A |
| 5825730 | Nishida et al. | Oct 1998 | A |
| 5826072 | Knapp et al. | Oct 1998 | A |
| 5826096 | Baxter | Oct 1998 | A |
| 5828875 | Halvarsson et al. | Oct 1998 | A |
| 5862065 | Muthusamy | Jan 1999 | A |
| 5867726 | Ohsuga et al. | Feb 1999 | A |
| 5875342 | Temple | Feb 1999 | A |
| 5880984 | Burchfiel et al. | Mar 1999 | A |
| 5892697 | Brakefield | Apr 1999 | A |
| 5892699 | Duncan et al. | Apr 1999 | A |
| 5894428 | Harada | Apr 1999 | A |
| 5900683 | Rinehart et al. | May 1999 | A |
| 5909385 | Nishiyama et al. | Jun 1999 | A |
| 5917741 | Ng | Jun 1999 | A |
| 5918252 | Chen et al. | Jun 1999 | A |
| 5930159 | Wong | Jul 1999 | A |
| 5930503 | Drees | Jul 1999 | A |
| 5936870 | Im | Aug 1999 | A |
| 5937199 | Temple | Aug 1999 | A |
| 5938759 | Kamijo | Aug 1999 | A |
| 5941940 | Prasad et al. | Aug 1999 | A |
| 5943249 | Handlogten | Aug 1999 | A |
| 5944816 | Dutton et al. | Aug 1999 | A |
| 5951627 | Kiamilev et al. | Sep 1999 | A |
| 5951679 | Anderson et al. | Sep 1999 | A |
| 5973527 | Schweighofer et al. | Oct 1999 | A |
| 5974549 | Golan | Oct 1999 | A |
| 5978825 | Divine et al. | Nov 1999 | A |
| 5983333 | Kolagotia et al. | Nov 1999 | A |
| 5991787 | Abel et al. | Nov 1999 | A |
| 5991868 | Kamiyama et al. | Nov 1999 | A |
| 5996067 | White | Nov 1999 | A |
| 6002234 | Ohm et al. | Dec 1999 | A |
| 6009454 | Dummermuth | Dec 1999 | A |
| 6014723 | Tremblay et al. | Jan 2000 | A |
| 6018757 | Wong | Jan 2000 | A |
| 6026489 | Wachi et al. | Feb 2000 | A |
| 6044392 | Anderson et al. | Mar 2000 | A |
| 6044434 | Oliver | Mar 2000 | A |
| 6049858 | Kolagotia et al. | Apr 2000 | A |
| 6055619 | North et al. | Apr 2000 | A |
| 6058409 | Kozaki et al. | May 2000 | A |
| 6058410 | Sharangpani | May 2000 | A |
| 6058464 | Taylor | May 2000 | A |
| 6061711 | Song et al. | May 2000 | A |
| 6061780 | Shippey et al. | May 2000 | A |
| 6061783 | Harriman | May 2000 | A |
| 6076154 | Van Eijndhoven et al. | Jun 2000 | A |
| 6084880 | Bailey et al. | Jul 2000 | A |
| 6101521 | Kosiec | Aug 2000 | A |
| 6101599 | Wright et al. | Aug 2000 | A |
| 6115732 | Oberman et al. | Sep 2000 | A |
| 6128728 | Dowling | Oct 2000 | A |
| 6134574 | Oberman et al. | Oct 2000 | A |
| 6144980 | Oberman | Nov 2000 | A |
| 6145049 | Wong | Nov 2000 | A |
| 6181151 | Wasson | Jan 2001 | B1 |
| 6202163 | Gabzdyl et al. | Mar 2001 | B1 |
| 6205467 | Lambrecht et al. | Mar 2001 | B1 |
| 6209086 | Chi et al. | Mar 2001 | B1 |
| 6243786 | Huang et al. | Jun 2001 | B1 |
| 6243804 | Cheng | Jun 2001 | B1 |
| 6260162 | Typaldos et al. | Jul 2001 | B1 |
| 6282637 | Chan et al. | Aug 2001 | B1 |
| 6292866 | Zaiki et al. | Sep 2001 | B1 |
| 6295574 | MacDonald | Sep 2001 | B1 |
| 6300800 | Schmitt et al. | Oct 2001 | B1 |
| 6315200 | Silverbrook et al. | Nov 2001 | B1 |
| 6356970 | Killian et al. | Mar 2002 | B1 |
| 6377619 | Denk et al. | Apr 2002 | B1 |
| 6397318 | Peh | May 2002 | B1 |
| 6412081 | Koscal et al. | Jun 2002 | B1 |
| 6434020 | Lambert et al. | Aug 2002 | B1 |
| 6487654 | Dowling | Nov 2002 | B2 |
| 6523108 | James et al. | Feb 2003 | B1 |
| 6552625 | Bowling | Apr 2003 | B2 |
| 6564238 | Kim et al. | May 2003 | B1 |
| 6633970 | Clift et al. | Oct 2003 | B1 |
| 6643150 | Kawakami | Nov 2003 | B2 |
| 6658578 | Laurenti et al. | Dec 2003 | B1 |
| 6681280 | Miyake et al. | Jan 2004 | B1 |
| 6694398 | Zhao et al. | Feb 2004 | B1 |
| 6724169 | Majumdar et al. | Apr 2004 | B2 |
| 6728856 | Grosbach et al. | Apr 2004 | B2 |
| 6751742 | Duhault et al. | Jun 2004 | B1 |
| 6763478 | Bui | Jul 2004 | B1 |
| 6819971 | Alidina et al. | Nov 2004 | B1 |
| 20020194466 | Catherwood et al. | Dec 2002 | A1 |
| 20030055860 | Giacalone et al. | Mar 2003 | A1 |
| 20030093656 | Masse et al. | May 2003 | A1 |
| 20040150439 | Greenfeld | Aug 2004 | A1 |
| Number | Date | Country |
|---|---|---|
| 0 554 917 | Aug 1993 | EP |
| 0 855 643 | Jul 1998 | EP |
| 0 992 888 | Dec 2000 | EP |
| 0 992 889 | Dec 2000 | EP |
| 01037124 | Feb 1989 | JP |
| 9611443 | Apr 1996 | WO |
| Number | Date | Country | |
|---|---|---|---|
| 20020188640 A1 | Dec 2002 | US |