IP Library Granted Patent US 6,889,242
Granted Patent B1
US 6,889,242 · App. 09/895,272 · Granted May 3, 2005

Rounding operations in computer processor

Assignee: Koninklijke Philips Electronics N.V.
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 6,889,242
App. No.
09/895,272
Granted
May 3, 2005
Kind
B1
Abstract

Various methods for performing rounding operations in a computer processor are described. A machine instruction sets the rounding mode, which is automatically applied to subsequent machine instructions. Using machine instructions to round results according to the selected rounding mode has several advantages over software-implemented rounding techniques, such as faster execution and concise code. A variety of rounding modes can be specified. Depending in part on the specified rounding mode and on the sign of the value to be rounded, a rounding term is added to the value to be rounded. Adding this rounding term ensures that the desired result is obtained. The value thus obtained is then right-shifted.

Claims (183)

1. A method comprising:

executing two separate instructions in a programmable processor, comprising:

executing a first instruction in the programmable processor to set a rounding mode; and

executing a second instruction within the programmable processor to generate an integer result rounded according to the rounding mode, wherein the second instruction does not designate the rounding mode.

2. The method of claim 1 , wherein executing the second instruction comprises executing an instruction that performs a rounded averaging operation.

3. The method of claim 1 , wherein executing the second instruction comprises executing an instruction that performs a non-saturating, fixed-point fractional multiplication operation with rounding.

4. The method of claim 1 , wherein executing the second instruction comprises executing an instruction that performs a right-shift operation with rounding.

5. The method of claim 1 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from a group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

6. The method of claim 1 , wherein the second instruction includes an arithmetic right-shift operation on a vector operand by an immediate shift amount with rounding, and wherein the vector operand comprises a signed byte vector, an unsigned byte vector, a signed double word or an unsigned double word.

7. A method comprising:

executing a first instruction to set a rounding mode;

performing an operation within a programmable processor to produce a result according to a second instruction, wherein the second instruction does not designate the rounding mode;

adding a rounding term to the result to obtain an intermediate result, the rounding term determined at least in part as a function of the rounding mode and a shift amount; and

right-shifting the intermediate result by the shift amount.

8. The method of claim 7 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

9. The method of claim 7 , wherein the operation is a rounded averaging operation of two or four unsigned byte vectors.

10. The method of claim 7 , wherein the operation is a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

11. A method of compiling a processor-readable software program comprising parsing a software program to produce instructions executable by a programmable processor, wherein the instructions include two separate instructions, comprising a first instruction that sets a rounding mode, and a second instruction that performs an arithmetic operation yielding an integer result rounded according to the rounding mode, wherein the second instruction does not designate the rounding mode.

12. The method of claim 11 , wherein the second instruction performs a rounded averaging operation.

13. The method of claim 11 , wherein the second instruction performs a non-saturating fixed-point fractional multiplication operation with rounding.

14. The method of claim 11 , wherein the second instruction performs a right-shift operation with rounding.

15. The method of claim 11 , wherein the first instruction sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

16. The method of claim 11 , wherein the arithmetic operation is an arithmetic right-shift operation on a vector operand by an immediate shift amount with rounding, wherein the vector operand comprises a signed byte vector, an unsigned byte vector, a signed double word or an unsigned double word.

17. A method of compiling a processor-readable software program comprising parsing a software program to produce instructions executable by a programmable processor, wherein the instructions cause the programmable processor to:

execute a first instruction to set a rounding mode;

perform an arithmetic operation according to a second instruction, wherein the second instruction does not designate the rounding mode;

add a rounding term to a result of the arithmetic operation to obtain an intermediate result, the rounding term determined at least in part as a function of the rounding mode and a shift amount; and

right-shift the intermediate result by the shift amount.

18. The method of claim 17 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

19. The method of claim 17 , wherein the arithmetic operation is a rounded averaging operation of two or four unsigned byte vectors.

20. The method of claim 17 , wherein the arithmetic operation is a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

21. A processor-readable medium having processor-executable instructions for:

executing two separate instructions in a programmable processor, comprising:

executing a first instruction in the programmable processor to set a rounding mode; and

executing a second instruction within the programmable processor to generate an integer result rounded according to the rounding mode, wherein the second instruction does not designate the rounding mode.

22. The processor-readable medium of claim 21 , wherein executing the second instruction comprises executing an instruction that performs a rounded averaging operation.

23. The processor-readable medium of claim 21 , wherein executing the second instruction comprises executing an instruction that performs a non-saturating fixed-point fractional multiplication operation with rounding.

24. The processor-readable medium of claim 21 , wherein executing the second instruction comprises executing an instruction that performs a right-shift operation with rounding.

25. The processor-readable medium of claim 21 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

26. The processor-readable medium of claim 21 , wherein the second instruction includes an arithmetic right-shift operation on a vector operand by an immediate shift amount with rounding, wherein the vector operand comprises a signed byte vector, an unsigned byte vector, a signed double word or an unsigned double word.

27. A processor-readable medium having processor-executable instructions for:

executing a first instruction to set a rounding mode;

performing an arithmetic operation according to a second instruction, wherein the second instruction does not designate the rounding mode;

adding a rounding term to a result of the arithmetic operation to obtain an intermediate result, the rounding term determined at least in part as a function of the rounding mode and a shift amount; and

right-shifting the intermediate result by the shift amount.

28. The processor-readable medium of claim 27 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

29. The processor-readable medium of claim 27 , wherein the arithmetic operation is a rounded averaging operation of two or four unsigned byte vectors.

30. The processor-readable medium of claim 27 , wherein the arithmetic operation is a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

31. A processor, comprising:

a control register to store a rounding mode of a first instruction;

a functional unit; and

a control unit to direct the functional unit to perform an arithmetic function according to the rounding mode in response to a second instruction, wherein the second instruction does not designate the rounding mode.

32. The processor of claim 31 , wherein the second instruction comprises a rounded averaging operation.

33. The processor of claim 31 , wherein the second instruction comprises a non-saturating fixed-point fractional multiplication operation with rounding.

34. The processor of claim 31 , wherein the second instruction comprises a right-shift operation with rounding.

35. The processor of claim 31 , further comprising:

a fetch unit configured to receive an instruction from an instruction stream;

a decode unit configured to decode the received instruction; and

a register file coupled to the plurality of functional units and configured to store an result.

36. The processor of claim 31 , wherein the first instruction sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

37. The processor of claim 31 , wherein the arithmetic operation is an arithmetic right-shift operation on a vector operand by an immediate shift amount with rounding, wherein the vector operand comprises a signed byte vector, an unsigned byte vector, a signed double word or an unsigned double word.

38. A processor, comprising:

a control unit comprising a control register configured to store a representation of a selected rounding mode designated by a first instruction;

at least one functional unit coupled to the control register;

a fetch unit configured to receive a second instruction from an instruction stream;

a decode unit configured to decode the second instruction; and

a register file coupled to the plurality of functional units,

the control unit configured to

perform an arithmetic operation according to the second instruction, wherein the second instruction does not designate the rounding mode,

add a rounding term to a result of the arithmetic operation to obtain an intermediate result, the rounding term determined at least in part as a function of the selected rounding mode and a shift amount,

right-shift the intermediate result by the shift amount to generate a rounded result, and

store the rounded result in the register file.

39. The processor of claim 38 , wherein the control unit is further configured to execute the first instruction to set the rounding mode.

40. The processor of claim 39 , wherein the first instruction sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

41. The processor of claim 38 , wherein the arithmetic operation is a rounded averaging operation of two or four unsigned byte vectors.

42. The processor of claim 38 , wherein the arithmetic operation comprises performing a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

43. A system comprising:

a memory; and

a processor comprising

a control register to store a rounding mode of a first instruction,

a functional unit, and

a control unit to direct the functional unit to perform an arithmetic function according to the rounding mode in response to a second instruction, wherein the second instruction does not designate the rounding mode.

44. The system of claim 43 , wherein the second instruction comprises a rounded averaging operation.

45. The system of claim 43 , wherein the second instruction comprises a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

46. The system of claim 43 , wherein the second instruction comprises a right-shift operation with rounding.

47. The system of claim 43 , wherein the rounding mode is selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

48. The system of claim 43 , wherein the second instruction includes an arithmetic right-shift operation on a vector operand by an immediate shift amount with rounding, wherein the vector operand comprises a signed byte vector, an unsigned byte vector, a signed double word or an unsigned double word.

49. A system, comprising:

a memory; and

a control unit comprising a control register configured to store a representation of a selected rounding mode designated by a first instruction;

at least one functional unit coupled to the control register;

a fetch unit configured to receive a second instruction from an instruction stream;

a decode unit configured to decode the second instruction; and

a register file coupled to the plurality of functional units,

the control unit configured to

perform an arithmetic operation according to the second instruction, wherein the second instruction does not designate the rounding mode,

add a rounding term to a result of the arithmetic operation to obtain an intermediate result, the rounding term determined at least in part as a function of the selected rounding mode and a shift amount,

right-shift the intermediate result by the shift amount to generate a rounded result, and

store the rounded result in the register file.

50. The system of claim 49 , wherein the processor is further configured to execute the first instruction to set the rounding mode.

51. The system of claim 50 , wherein executing the first instruction comprises executing an instruction that sets a rounding mode selected from the group of rounding modes comprising:

rounding toward negative infinity;

rounding toward infinity;

rounding toward zero;

rounding away from zero;

rounding to a nearest integer, with a value of one-half being rounded toward negative infinity;

rounding to a nearest integer, with a value of one-half being rounded toward infinity;

rounding to a nearest integer, with a value of one-half being rounded toward zero; and

rounding to a nearest integer, with a value of one-half being rounded away from zero.

52. The system of claim 49 , wherein the arithmetic operation is a rounded averaging operation of two or four unsigned byte vectors.

53. The system of claim 49 , wherein the arithmetic operation is a non-saturating fixed-point fractional multiplication operation with rounding of a set of vector operands selected from signed half-word vectors, unsigned half-word vectors, signed word vectors and unsigned word vectors.

Assignments (6)
INTELLECTUAL PROPERTY TRANSFER & LICENSE AGREEMENT Recorded Jun 16, 2017
From: KONINKLIJKE PHILIPS ELECTRONICS N.V.
To: PHILIPS SEMICONDUCTORS INTERNATIONAL B.V.
Reel/Frame 042859/0973 →
CHANGE OF NAME Recorded Jun 16, 2017
From: PHILIPS SEMICONDUCTORS INTERNATIONAL B.V.
To: NXP B.V.
Reel/Frame 042878/0051 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 31, 2017
From: NXP B.V.
To: III HOLDINGS 12, LLC
Reel/Frame 042127/0159 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 13, 2008
From: KONINKLIJKE PHILIPS ELECTRONICS N.V.
To: NXP B.V.
Reel/Frame 021085/0959 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 24, 2005
From: TRIMEDIA TECHNOLOGIES, INC.
To: KONINKLIJKE PHILIPS ELECTRONICS N.V.
Reel/Frame 016028/0765 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 15, 2002
From: SIJSTERMANS, FRANS W.; VAN EIJNDHOVEN, JOS
To: TRIMEDIA TECHNOLOGIES, INC.
Reel/Frame 012480/0415 →