A data processing apparatus and method for generating constant values is provided. The data processing apparatus comprises a data processing unit operable in response to an instruction to perform a data processing operation on one or more data values. shift logic is operable to selectively apply a shift operation to data to produce one of the data values for the data processing operation. Further, a plurality of registers are provided for storing data. The instruction has a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of the data values for the data processing operation. The register specifier field is allocatable a distinguished value, and if the register specifier field has that distinguished value, the shift logic is provided with a predetermined value and generates therefrom one of a plurality of constant values dependent on the shift specified by the shift specifier field, the generated constant value then being used as one of the data values for the data processing operation.
|
1. A data processing apparatus comprising:
a data processing unit operable in response to an instruction to perform a data processing operation on one or more data values;
shift logic operable to selectively apply a shift operation to data to produce one of said one or more data values for said data processing operation;
a plurality of registers for storing data;
the instruction having a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of said one or more data values for the data processing operation;
the register specifier field being allocatable a distinguished value, if the register specifier field has that distinguished value, the shift logic being provided with a predetermined value and being operable to generate one of a plurality of constant values dependent on the shift specified by the shift specifier field, the generated constant value being used as one of said one or more data values for the data processing operation.
12. A method of operating a data processing apparatus to generate constant values, the data processing apparatus having a data processing unit operable in response to an instruction to perform a data processing operation on one or more data values, shift logic operable to selectively apply a shift operation to data to produce one of said one or more data values for said data processing operation, and a plurality of registers for storing data, the instruction having a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of said one or more data values for the data processing operation, the method comprising the steps of:
(a) determining the value of the register specifier field;
(b) if the register specifier field has a distinguished value, providing a predetermined value to the shift logic;
(c) employing the shift logic to generate from the predetermined value one of a plurality of constant values dependent on the shift specified by the shift specifier field; and
(d) using the generated constant value as one of said one or more data values for the data processing operation.
2. A data processing apparatus as claimed in
3. A data processing apparatus as claimed in
4. A data processing apparatus as claimed in
5. A data processing apparatus as claimed in
6. A data processing apparatus as claimed in
7. A data processing apparatus as claimed in
8. A data processing apparatus as claimed in
9. A data processing apparatus as claimed in
10. A data processing apparatus as claimed in
11. A data processing apparatus as claimed in
selection logic operable, if the register specifier field has said distinguished value, to replace data output from the register file with the predetermined value to be supplied to the shift logic.
13. A method as claimed in
14. A method as claimed in
15. A method as claimed in
if the additional register specifier field has said distinguished value, providing to the data processing unit a data value comprising all zeros.
16. A method as claimed in
if the additional register specifier field has said distinguished value, providing to the data processing unit a data value comprising a program counter value.
17. A method as claimed in
if the register specifier field of the further instruction has said distinguished value, providing to the data processing unit for the further data processing operation a data value comprising all zeros.
18. A method as claimed in
if the register specifier field of the further instruction has said distinguished value, providing to the data processing unit for the further data processing operation a data value comprising a program counter value.
19. A method as claimed in
20. A method as claimed in
21. A method as claimed in
22. A method as claimed in
if the register specifier field has said distinguished value, replacing data output from the register file with the predetermined value to be supplied to the shift logic.
|
1. Field of the Invention
The present invention relates to an apparatus and method for generating constant values.
2. Description of the Prior Art
When performing a data processing operation within a data processing apparatus, it is often the case that a constant value is required as one of the input data values for that data processing operation. One known way to provide such a constant value is to encode within a particular instruction an immediate value which can be used to produce that constant value. For example, a move instruction may have encoded therein an immediate value, and execution of the move instruction will cause the immediate value to be expanded as required to the register size of registers within a register file, and then stored within a particular register identified by the move instruction.
As a particular example, in situations where a 32-bit instruction set is used, a certain number of bits of the encoding space, for example 8 bits or 12 bits of the 32-bit instruction, may be used to specify an immediate value. If the register into which the constant value specified by that immediate value to be placed is a 32-bit register, then the immediate value can be zero extended (in the example of an unsigned constant value) or sign extended (in the example of a signed constant value) to 32-bits and then stored within the specified register.
As a further enhancement to the above approach, ARM Limited have provided in their instruction set, an instruction encoding which allows an 8 bit immediate value to be specified, and then a further 4 bits to be specified to identify a rotation to be applied to the immediate value in order to specify its location within a register (with the remaining bits of the register being filled with a predetermined sequence of ones or zeros).
Hence, from the above discussion, it can be seen that there are a number of ways of using an immediate value specified within an instruction to generate particular constant values. However, since there are only a limited number of bits available for specifying an immediate value from which the constant value is to be determined, it will be appreciated that the number of constant values that can be obtained using the above techniques is limited. It would hence be desirable to provide an improved technique for generating constant values for use within the data processing apparatus.
Instructions typically include register specifier fields for identifying source and destination registers for the instruction, a source register holding a source data value for the instruction, and a destination register being a register into which is stored the result data value produced by performing the associated data processing operation. It is also known for an instruction to include a shift specifier field for specifying a shift to be applied to the data identified by a particular one of the register specifier fields, such that the actual input data value is generated by reading the specified register and applying the specified shift to the value read from that register.
In some instruction set architectures, there is also the concept of a “zero register” i.e. a particular value for a register specifier field that, when used in at least some register specifier positions within at least some instructions, causes a value of zero to be read from the register file.
Viewed from a first aspect the present invention provides a data processing apparatus comprising: a data processing unit operable in response to an instruction to perform a data processing operation on one or more data values; shift logic operable to selectively apply a shift operation to data to produce one of said one or more data values for said data processing operation; a plurality of registers for storing data; the instruction having a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of said one or more data values for the data processing operation; the register specifier field being allocated a distinguished value, if the register specifier field has that distinguished value, the shift logic being provided with a predetermined value and being operable to generate one of a plurality of constant values dependent on the shift specified by the shift specifier field, the generated constant value being used as one of said one or more data values for the data processing operation.
In accordance with the present invention, the data processing unit is operable in response to an instruction to perform a data processing operation on one or more data values. The instruction has a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of the data values for the data processing operation. To enable one of a plurality of constant values to be specified as one of the input data values, the register specifier field can be allocated a distinguished value, such that if the register specifier field has that distinguished value, the shift logic receives a predetermined value and is operable to generate the required constant value by performing a shift of that predetermined value as specified by the shift specifier field. This provides a very flexible technique for generating constant values required when executing an instruction, where that constant value can be generated “on the fly” by triggering the supply of a predetermined value to the shift logic, and specifying a shift to be performed on that predetermined value.
In one particular embodiment, as will be discussed in more detail later, the distinguished value may be that used to identify a zero register. However, the specifying of a zero register in association with a shift specifier field would typically be of no benefit, since shift logic typically has the ability to shift logic zero values in from either end of the data value it receives (or to shift sign bits in from the top in the instance of signed integer values), and accordingly the result of such a shift operation would always result in a final operand value of zero. However, in the above embodiment of the present invention, this encoding redundancy is exploited by enabling the shift logic to produce values other than zero in situations where an instruction specifies a zero register and an associated shift, thereby allowing a variety of useful constant values to be encoded within the instruction.
In one embodiment of the present invention, if the register specifier field has the distinguished value, the predetermined value supplied to the shift logic comprises all ones, and the shift logic is operable to shift in a predetermined bit sequence determined with reference to the shift specifier field.
In one particular embodiment, the register file is arranged in such instances to output an “all ones” data value for input to the shift logic. As a particular example, if the data processing operation is performed on 32-bit data values, this would result in the register file outputting a 32-bit value, where all bits had a logic one value, and the shift logic would then be operable to shift in a predetermined bit sequence determined with reference to the shift specifier field in order to generate the required constant value for the data processing operation.
In one embodiment where the predetermined value supplied to the shift logic comprises all ones, the predetermined bit sequence is all zeros, and the shift specifier field identifies the direction of the shift and the number of bit positions to be shifted.
In one embodiment, the instruction has an additional register specifier field for identifying a register whose data is to be used as a data value for said data processing operation without a shift being applied by the shift logic, and if the additional register specifier field has said distinguished value, the data value provided to the data processing unit comprises all zeros.
Alternatively, in such situations, the data value provided to the data processing unit may comprise a program counter value. Hence, it can be seen that when the distinguished value is specified within the additional register specifier field, then this can be used to specify a zero register, or a program counter value, depending upon the instruction.
In one embodiment, the data processing unit is operable in response to a further instruction to perform a further data processing operation on one or more data values, the further instruction having a register specifier field for identifying a register whose data is to be used as a data value for said further data processing operation without a shift being applied by the shift logic, and if the register specifier field of the further instruction has said distinguished value, the data value provided to the data processing unit for the further data processing operation comprises all zeros. Alternatively, in such situations, the data value provided to the data processing unit for the further data processing operation may comprise a program counter value. Hence, in a similar way to the earlier example of an additional register specifier field, if the distinguished value is used in a register specifier field for a further instruction, this may be used to specify either a zero register or a program counter value, depending upon the instruction.
In one embodiment of the present invention, if the register specifier field has said distinguished value, the predetermined value supplied to the shift logic comprises all zeros, and the shift logic is operable to shift in a predetermined bit sequence determined with reference to the shift specifier field. Hence, in this embodiment the distinguished value specifies a zero register, and hence this shift logic is provided with an input data value comprising all zeros.
In one such embodiment, the predetermined bit sequence is all ones, and the shift specifier field identifies the direction of the shift and the number of bit positions to be shifted.
In one embodiment, the plurality of registers are contained in a register file, and if the register specifier field has said distinguished value, the register file is operable to produce the predetermined value to be supplied to the shift logic. Hence, dependent upon the embodiment, when the distinguished value is allocated to the register specifier field, the register file is operable to produce a predetermined value comprising either all zeros or all ones as an input to the shift logic.
In an alternative embodiment, the data processing apparatus further comprises: selection logic operable, if the register specifier field has said distinguished value, to replace data output from the register file with the predetermined value to be supplied to the shift logic. Hence, in this embodiment, the register file may interpret the distinguished value in one particular way, and hence in a particular example may output a program counter value, but the selection logic is operable to replace that data with the predetermined value to be supplied to the shift logic, for example a value comprising all zeros or a value comprising all ones, dependent upon the embodiment.
Viewed from a second aspect, the present invention provides a method of operating a data processing apparatus to generate constant values, the data processing apparatus having a data processing unit operable in response to an instruction to perform a data processing operation on one or more data values, shift logic operable to selectively apply a shift operation to data to produce one of said one or more data values for said data processing operation, and a plurality of registers for storing data, the instruction having a register specifier field for identifying a register and a shift specifier field for specifying a shift to be applied to that register's data in order to produce one of said one or more data values for the data processing operation, the method comprising the steps of: (a) determining the value of the register specifier field; (b) if the register specifier field has a distinguished value, providing a predetermined value to the shift logic; (c) employing the shift logic to generate from the predetermined value one of a plurality of constant values dependent on the shift specified by the shift specifier field; and (d) using the generated constant value as one of said one or more data values for the data processing operation.
The present invention will be described further, by way of example only, with reference to preferred embodiments thereof as illustrated in the accompanying drawings, in which:
As will be appreciated by those skilled in the art, the logic elements provided within the other processing logic 50 may take a variety of forms. As an example, they may include an Arithmetic Logic Unit (ALU) used to perform various arithmetic operations on the input source operands. The data value produced at the output of the processing logic 50 is output from the data processing unit on path 52 from where it can be returned to the register file 10, and indeed in some embodiments may be routed over forwarding paths back into the data processing unit 20.
The register file 10 has a plurality of registers for storing data values required by the data processing unit 20 when performing data processing operations. The registers of the register file can be referenced within register specifier fields of the instructions to be executed on the data processing apparatus, and in particular may be specified as source registers or destination registers. A register used as the destination register in one instruction may be used as a source register in another instruction.
In the example illustrated in
As shown in
The register file is in this instance arranged to determine from the value of Rm specified in the instruction a particular register whose contents are to be output, and then to output the data in that register. If the register specifier Rm has the earlier mentioned distinguished value, this will cause a particular value to be output from the register file, which in one particular embodiment is the program counter value used to identify a current instruction within an instruction sequence. However, if the zero register detection logic 100 in this instance determines from the instruction opcode that the instruction is of a type where the presence of the distinguished value as the register specifier Rm is to be used to indicate the zero register, then it sends a control signal to the multiplexer 110 to cause the multiplexer to output all zeros, rather than the data it receives from the register file.
Hence, in situations where the zero register detection logic 100 detects the presence of a zero register, the shifter logic 120 will be provided with a data value comprising all zeros. Normally, the shifter logic 120 will be arranged to shift logic zero values in from either end of the data value, or to shift sign bits in from the most significant bit of the data value if the input data value is a signed value, the exact shift required being indicated by shift type data and shift immediate data specified within the instruction. In particular, the shift type field will specify whether the shift is a logical left shift or a logical right shift, whether the shift is an arithmetic shift shifting sign bits in from the most significant bit position, or whether some form of rotation shift is to be performed. The shift immediate value specifies the number of bit positions to be shifted.
In accordance with the embodiment of the invention illustrated with reference to
However, in accordance with this embodiment of the present invention, if the value of the register specifier Rm in the instruction takes the value of R15 in certain instructions (as indicated by the instruction opcode), then this is determined by the zero register detection logic 100 as specifying the zero register, and accordingly a control signal is sent to the multiplexer 210 to cause a logic zero value to be output in that instance rather than the current PC value. Similar control logic to the zero register detection logic 100 is also used to control multiplexer 220, although this logic receives the value of Rn as specified in the instruction rather than the value of Rm. The multiplexer 210 is arranged to output source operand Rm, which is then routed via the shifter 120, whereas the multiplexer 220 is arranged to produce the other source operand Rn which is not routed via the shifter 120. The shifter 120 and extended zero register detection logic 130 act in exactly the same manner as described earlier with reference to
Distinguished value detection logic 300 is provided to generate a control signal for the multiplexer 210 as with the zero register detection logic 100 of
The control logic used to control the second multiplexer 220 may be the same as that used in the
Since the presence of the distinguished value in certain instructions causes a source operand Rm comprising all ones to be produced, the shifter logic 120 can operate in a standard manner, i.e. by shifting logic zero values in from the most significant bit position or the least significant bit position of the data value, under the control of standard shifter control logic 310 which determines the appropriate shift to apply based on the shift immediate and shift type data decoded from the instruction.
As shown in
It should be noted that whilst in
From the above description of embodiments of the present invention, it can be seen that such embodiments take advantage of an encoding redundancy that would otherwise be present in an instruction. In particular, considering the zero register example, if a zero register is specified for a register specifier field with which a shift is associated, this would typically cause a value comprising all zeros to be output from the shifter irrespective of the value of the shift specified. Embodiments of the present invention exploit this by using the multiple combinations of the shift specifier field in combination with the distinguished value identifying the zero register to encode a variety of useful constant values. The alternative embodiment of
Although a particular embodiment of the invention has been described herein, it will be apparent that the invention is not limited thereto, and that many modifications and additions may be made within the scope of the invention. For example, various combinations of the features of the following dependent claims could be made with the features of the independent claims without departing from the scope of the present invention.
Mansell, David Hennah, Seal, David James, Callan, Jonathan Sean, Pedley, Christopher
Patent | Priority | Assignee | Title |
Patent | Priority | Assignee | Title |
4377846, | Oct 08 1979 | Hitachi, Ltd. | Arithmetic unit for generating constants in an electronic computer of the microprogram-controlled type |
5177701, | Nov 07 1990 | Kabushiki Kaisha Toshiba | Computer and method for performing immediate calculation by utilizing the computer |
5301345, | May 03 1991 | Freescale Semiconductor, Inc | Data processing system for performing a shifting operation and a constant generation operation and method therefor |
6209080, | Jul 30 1997 | SOCIONEXT INC | Constant reconstruction processor that supports reductions in code size and processing time |
6834336, | Jun 16 1997 | Godo Kaisha IP Bridge 1 | Processor for executing highly efficient VLIW |
6922773, | Dec 29 2000 | Hewlett Packard Enterprise Development LP | System and method for encoding constant operands in a wide issue processor |
20050125637, |
Executed on | Assignor | Assignee | Conveyance | Frame | Reel | Doc |
Oct 22 2004 | CALLAN, JONATHAN S | ARM Limited | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 016232 | /0620 | |
Oct 22 2004 | MANSELL, DAVID H | ARM Limited | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 016232 | /0620 | |
Oct 22 2004 | PEDLEY, CHRISTOPHER | ARM Limited | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 016232 | /0620 | |
Oct 26 2004 | ARM Limited | (assignment on the face of the patent) | / | |||
Oct 26 2004 | SEAL, DAVID J | ARM Limited | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 016232 | /0620 |
Date | Maintenance Fee Events |
May 21 2010 | M1551: Payment of Maintenance Fee, 4th Year, Large Entity. |
May 07 2014 | M1552: Payment of Maintenance Fee, 8th Year, Large Entity. |
May 24 2018 | M1553: Payment of Maintenance Fee, 12th Year, Large Entity. |
Date | Maintenance Schedule |
Dec 05 2009 | 4 years fee payment window open |
Jun 05 2010 | 6 months grace period start (w surcharge) |
Dec 05 2010 | patent expiry (for year 4) |
Dec 05 2012 | 2 years to revive unintentionally abandoned end. (for year 4) |
Dec 05 2013 | 8 years fee payment window open |
Jun 05 2014 | 6 months grace period start (w surcharge) |
Dec 05 2014 | patent expiry (for year 8) |
Dec 05 2016 | 2 years to revive unintentionally abandoned end. (for year 8) |
Dec 05 2017 | 12 years fee payment window open |
Jun 05 2018 | 6 months grace period start (w surcharge) |
Dec 05 2018 | patent expiry (for year 12) |
Dec 05 2020 | 2 years to revive unintentionally abandoned end. (for year 12) |