Rounding operations in computer processor
AssigneeKoninklijke Philips Electronics N.V.
InventorsFrans W. Sijstermans, Jos van Eijndhoven
Life of this patent
Estimating the term…
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.
Claims53
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Dependencies are inferred from the claim text.