Title of Invention

"APPARATUS FOR DECODING AN INSTRUCTION CODE ISSUED FROM AN INSTRUCTION BUFFER"

Abstract The present invention discloses a method and apparatus for encoding an instruction in an instruction set which uses a prefix code to qualify an existing opcode of an existing instruction. An opcode and an escape code are selected. The escape code is selected such that it is different from the prefix code and the existing opcode. The opcode, the escape code, and the prefix code are combined to generate an instruction code which uniquely represents the operation performed by the instruction.
Full Text The present invention relates to an apparatus for decoding an

instruction code issed from an instruction buffer
1- Field of the Invention
This invention relates to microprocessor systems. In particular, the invention relates to instruction set extension using prefixes.
2- Description of Related Art
Microprocessor technology lias evolved over the years at a fast rate. Advances in computer architecture and semiconductor technology have created many opportunities to design new processors. There are typically two options for designing new processors; (1) defining a completely new architecture, and (2) extending the current architecture to accommodate new features. Each option lias both advantages and disadvantages. However, when a processor has captured a significant market segment, option (2) offers many attractive advantages. The main advantage of extending the current architecture is the compatibility with current and earlier models. The disadvantages include the problems of getting out of the constraints imposed by the earlier designs.
New processors involve new features in both hardware and software. A new processor based on existing design typically has an additional set of instructions that can take advantage of the new hardware design. However, extending an instruction set by adding a new set of instructions is a challenging problem because of the constraints in the encoding of the instructions.
When an instruction set is originally developed, the typical approach is to encode the instructions with a minimum number of bits to leave room for

future expansion. However, as the architecture evolves and becomes more and more mature, more and more instructions are defined. Eventually, there will be a point where there is no more space for encoding the instructions.
One solution to the problem is to eliminate some of the older instructions. However, this solution reduces the compatibility to the earlier processors. Software written for the earlier processors may not work for the new design. Another solution is to narrow the new instruction set to only a group of selective instructions to accommodate the little room left in the available opcode table. The solution results in poorer performance because it sacrifices many advanced features offered by the new design. Yet, another solution is to define a set of new opcodes which is different than the existing opcodes. The problems with this solution include the complexity of the decoding circuitry which occupies a large chip area and may not scale well with the processor frequency.
Therefore there is a need in the technology to provide an efficient method for extending an instruction set without increasing hardware complexity.
SUMMARY OF THE INVENTION
The present invention discloses a method and apparatus for decoding an instruction in an instruction set which uses a prefix code to quantify an existing opcode of an existing instruction. An opcode and an escape code are selected. The escape code is selected such that it is different from the prefix code arid the existing opcode. The opcode, the escape code, and the prefix code are combined to generate an instruction code which uniquely represents the operation performed by the instruction.
Accordingly, there is provided an apparatus for decoding an instruction code issued from an instruction buffer, the instruction code having a plurality of fields, the apparatus comprising:
a prefix detector coupled to the instruction buffer to receive the instruction code and to detect if a first field of the instruction code matches a prefix code;
an escape detector coupled to the instruction buffer to receive the instruction code and to detect if a second field of the instruction code matches an escape code; and
an opcode decoder coupled to the instruction buffer to receive the instruction code and to translate one of the first field, the second field, and a third field of the instruction code into a decoded instruction code.
BRIEF DESCRIPTION OF THE ACCOMPANYING DRAWINGS
The features and advantages of the invention will become apparent from the following detailed description of the invention in which:
Figure 1 is a diagram illustrating one embodiment of a computer system in accordance with the teachings of the present invention.
Figure 2 is a diagram illustrating a format of an instruction 200 in according to one embodiment of the invention.
Figure 3 is a diagram illustrating a circuit 300 to decode the instruction according to one embodiment of the invention.
Figure 4 is a diagram illustrating the prefix and escape detector 320, the decoder enable circuit 330, and the opcode decoder 340 according to one embodiment of the invention.
Figure 5 is a flowchart illustrating a process P500 to perform instruction decoding using prefixes according to one embodiment of the invention.

DESCRIPTION OF THE PRESENT INVENTION
A method and apparatus for extending an instruction set using prefixes is disclosed. The method uses a set of existing prefix codes to define a new set of instructions. The method provides a fast and efficient mechanism to decode the new instruction set.
In the following description, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that these specific details are not required in order to practice the present invention. In other instances, well known electrical structures and circuits are shown in block diagram form in order not to obscure the present invention. In the following description, the notation Ox indicates the number that follows is in hexadecimal format.
Figure 1 is a diagram illustrating one embodiment of a processor 110 in accordance with the teachings of the present invention.
The processor 110 represents a central processing unit of any type of architecture, such as complex instruction set computers (CISC), reduced instruction set computers (RISC), very long instruction word (VLIW), multi¬threaded or hybrid architecture.
Figure 1 illustrates that the processor 110 includes a decode unit 116, a set of registers 114, an execution unit 112, and an internal bus 111 for executing instructions. Of course, the processor 110 contains additional circuitry, which is not necessary to understanding the invention.- The decode unit 116, registers 114 and execution unit 112 are coupled together by the

internal bus 111. The decode unit 116 is used for decoding instructions received by processor 110 into control signals and/or microcode entry points. In response to these control signals and/or microcode entry points, the execution unit 112 performs the appropriate operations. The decode unit 116 may be implemented using any number of different mechanisms (e.g., a look¬up table, a hardware implementation, a PLA, etc.).
The decode unit 116 is shown including an instruction set 118 for performing operations on scalar and packed data. The number format for these operations can be any convenient format, including single-precision, double-precision, and extended floating-point numbers, signed and unsigned integers, and non-numeric data. The instruction set 118 includes an existing instruction set 118a, a new instruction set 118b. In particular, the instruction format of the instruction set includes a prefix 118c.
INSTRUCTION FORMAT
Figure 2 is a diagram illustrating a format of an instruction 200 according to one embodiment of the invention. The instruction 200 includes a prefix field 210, an opcode field 220, and operand specifier fields (e.g., modR/M, scale-index-base, displacement, immediate, etc.). The operand specifier fields are optional and include a modR/M field 230, an SIB field 240, a displacement field 250, and an immediate field 260.
The prefix field 210 includes a number of prefixes. In one embodiment, the prefix field 210 includes up to four prefixes, each prefix is one byte. The prefix field 210 is optional. For the extended new instruction set, however, the prefix field is required to encode the new instructions.

The opcode field 220 specifies the operation. For the extended new instruction set, the opcode field 220 is combined with the prefix field 210 to define an operation. In one embodiment, the opcode field 220 may include one or two bytes.
The combination of the prefix field 210 and the opcode field 220 creates a number of different types of instruction set. For illustrative purposes, Figure 2 shows only five types of instructions: a regular one-byte instruction 212, a regular instruction with prefix as qualifier 214, a regular escape instruction 216, a first new instruction type 222, and a second new instruction type 224. As is known by one skilled in the art, other types of instruction can be similarly defined.
The regular one-byte instruction 212 includes regular instructions with one-byte opcodes. The regular instruction with prefix as qualifier 214 includes regular instructions which use the prefix as a qualifier for the opcode. For example, a string instruction may use a REPEAT prefix to repeat the string instruction by a number of times specified in the count register or until a certain condition is met. The prefix used in instruction 214 does not add a completely new meaning to the opcode that follows. Rather, the prefix is merely used as a qualifier to qualify the opcode with additional conditions. As will be explained later, the use of the prefix in the instruction 214 is markedly different from that in the instruction 224. The regular escape instruction 216 is a regular instruction that escapes to other types of instruction. For example, in one embodiment, a floating-point coprocessor escape code OxD8 through OxDF indicates that the opcode that follows should be interpreted as coprocessor instructions.

The first new instruction type 222 (or the new instruction type 0) is a new instruction that is part of the new instruction set to be added to the existing regular instruction set. The new instruction type 0 uses a special escape code, called a two-byte escape code. In one embodiment, the two-byte escape code is OxOF. For the instruction 222, the opcode that follows the 2-bye escape code should be decoded as a new instruction. The second new instruction type 224 (or the new instruction type 1) uses the prefix as part of the opcode. Unlike the instruction 214 where the prefix merely qualifies the opcode that follows, the instruction 224 uses the prefix to define a completely new instruction. The use of the prefix together with the escape code enlarges the instruction opcode table without significant changes in the decoding circuitry. In addition, no new opcodes are used so that there is room for new instructions in the future. Examples of these instructions will be given later.
EXAMPLES OF INSTRUCTION PREFIXES AND ESCAPE CODES
Instruction prefixes are originally developed to enhance a set of instructions. For example, the repeat prefix is developed to repeat a string instruction. The repeat prefix codes are OxF3 (REP, REPE) and OxF2 (REPNE). The prefix does not define a new meaning for the opcode that follows. It merely defines additional operational conditions for the opcode.
The escape code provides an extension to the instruction set. For example, the escape codes OxD8 through OxDF are used to indicate that the opcode that follows belongs to the floating-point unit. The decoder will pass the opcode to the floating-point decoder. In one embodiment, a two-byte escape code, OxOF, indicates that the opcode that follows defines a new

instruction set. Although the escape code allows enlargement of the instruction set further, the additional number of opcodes is still limited.
The combination of the prefix and the escape code provides a significant enlargement of the opcode table to allow additional new instruction sets. This combination uses the existing prefix codes to define a completely new set of instructions, in addition to the instruction set created by the escape code. By using the existing prefix codes, the decoding circuitry for the existing instruction set remains essentially the same. Although the decoding circuitry will have to be modified to accommodate this combination, the modification is merely a modular add-on with minimal changes to existing design.
The opcodes of some or all of the new instructions may be the same as the opcodes of the existing instructions. By using the same opcodes with the prefix and escape codes to define a brand new set of instructions, the decoding circuitry is much less complex than having a completely new set of opcodes for the new instruction set.
In one embodiment, the repeat prefix OxF3 is used to define a new instruction set. Other prefixes can be similarly used. Furthermore, prefixes can still be used in the traditional role of enhancing the opcode or qualifying the opcode under some operational condition. For example, the address size prefix can still be used to affect the new instruction with memory operand.
The following are examples of the new instruction set using prefixes and escape codes.
Instruction Opcode (in Hex) Definition

ADDPS OF, 58 Packed single FP add
ADDSS F3, OF, 58 Scalar single FP add
CMPPS OF, C2 Packed single FP compare
CMPSS F3, OF, C2 Scalar single FP compare
DIVPS OF, 5E Packed single FP divide
DIVSS F3, OF, 5E Scalar single FP divide
MAXPS OF, 5F Packed single FP maximum
MAXSS F3, OF, 5F Scalar single FP maximum
MINPS OF, 5D Packed single FP minimum
MINSS ,F3, OF, 5D Scalar single FP minimum
MOVUPS OF, 10/11 Move unaligned Packed single FP
MOVSS F3, OF, 10/11 Move scalar single FP
MULPS OF, 59 Packed single FP multiply
MULSS F3, OF, 59 Scalar single FP multiply
SUBPS OF,5C Packed single FP subtract
SUBSS F3, OF, 5C Scalar single FP subtract
In the above examples, the instruction set without the prefix OxF3 relates to operations on packed data, while the instruction set with the prefix OxF3 relates to operations on scalar data.
In one embodiment, the set of prefix codes are: an address size prefix code (0x67), an operand size prefix code (0x66), a segment override prefix code (Ox2E, 0x36, Ox3E, 0x26,0x64,0x65), a repeat prefix code (OxF3), a repeat while equal prefix code (OxF3), a repeat while not equal code (OxF2), and a lock prefix code (OxFO). As is known by one skilled in the art, the exact codes for these prefixes are implementation-dependent, the above prefix codes are merely for

illustrative purposes. Furthermore, not all the prefix codes are available for encoding the new instruction set. Some prefixes may result in illegal mode or may not be recognized.
INSTRUCTION DECODING USING PREFIXES
Figure 3 is a diagram illustrating a circuit 300 to decode the instruction. The circuit 300 includes an instruction buffer 310, a prefix and escape detector 320, a decoder enable circuit 330, and an opcode decoder 340. The prefix and escape detector 320, the decoder enable circuit 330, and the opcode decoder 340 form a portion of the decode unit 116 in Figure 1.
The instruction buffer 310 stores the instructions fetched from the external memory. Typically, the instruction buffer 310 is implemented as an instruction cache. For illustrative purposes, an instruction is assumed to comprise three bytes: The first byte corresponds to IN to IN+7 the second byte corresponds to IK to IK+7, and the third byte corresponds to IM to IM+?/ where IN to IN+7, IK to IK+7, and IM to IM+7refer to the bit positions of the instruction word.
The prefix and escape detector 320 receives the instruction bits IN to IN+7 IK to lK+7, and detects a set of predefined prefixes and/or escape codes used as part of the new instruction set. The values of these prefixes are selected so that they are the same as those prefixes that are used for the regular instruction set. The decoder enable circuit 330 combines the results of the prefix and escape detector 320 to generate enable or select signals to the individual opcode decoder. The opcode decoder 340 receives the instruction bits IN to IN+7 IK to IK+7, and IM to IM+7 and performs the decoding function for the individual types of instructions.

Figure 4 is a diagram illustrating the prefix and escape detector 320, the decoder enable circuit 330, and the opcode decoder 340. For illustrative purposes, it is assumed that there is one OxF3 prefix, and two escape codes, the OxD8-OxDF and OxOF.
The prefix and escape detector 320 includes 4 AND gates 410, 412,414, and 416. The AND gates 410,412, and 414 match the instruction bits IN to IN+? with the corresponding prefix code and escape code. The AND gate 410 matches the instruction bits IN to IN+7 with the prefix code, OxF3, and generates a signal PRFX. The signal PRFX is asserted if the instruction bits IN to IN+7 represent the prefix OxF3. The AND gate 412 matches the instruction bits IN to lN+7 with the escape code, OxD8-OxDF, and generates a signal ESC1. The signal ESC1 is asserted if the instruction bits IN to IN+7 represent the escape code OxD8 to OxDF. The AND gate 414 matches the instruction bits IN to IN+7 with the 2-byte escape code, OxOF, and generates a signal ESC2A. The signal ESC2A is asserted if the instruction bits IN to IN+7 represent the 2-byte escape code OxOF. The AND gate 416 matches the instruction bits IK to IK+? with the 2-byte escape code, OxOF, and generates a signal ESC2B. The signal ESC2B is asserted if the instruction bits IK to IK+7 represent the 2-byte escape code OxOF. As is known by one skilled in the art, other logic gates can be employed to perform the matching or decoding of the instruction bits IN to lN+7 and IK to IK+7-
The decoder enable circuit 330 receives the PRFX, ESC1, ESC2A, and ESC2B signals to generate the enable signals to the individual decoders. The decoder enable circuit 330 includes a NOR gate 420, an AND gate 422, and an AND gate 424.

The NOR gate 420 asserts the EN1 signal when all the PRFX, ESC1, and ESC2A are negated. This condition corresponds to the condition where the instruction bits IN to IN+7 do not match a prefix, a floating-point escape code, and a 2-byte escape code. Therefore, the instruction bits IN to IN+7 correspond to an opcode of a one-byte regular instruction.
The AND gate 422 asserts the EN2 signal when the PRFX signal is asserted and the ESC2B is negated. This condition corresponds to the condition where the instruction bits IN to IN+7 match the prefix code but the instruction bits IK to IK+7 do not match the 2-byte escape code. Therefore this condition corresponds to an opcode using the prefix as a qualifier of a regular instruction.
The ESC1 signal is used as the EN3 signal. This signal is asserted when the instruction bits IN to IN+7 match the floating-point escape code. Therefore this condition corresponds to a floating-point opcode of a regular instruction.
The ESC2A signal is used as the EN4 signal. This signal is asserted when the instruction bits IN to IN+? match the 2-byte escape code. Therefore this condition corresponds to an opcode of a new instruction type 0.
The AND gate 424 asserts the EN5 signal when the PRFX and ESC2B signals are asserted. This condition corresponds to the condition where the instruction bits IN to IN+7 match the prefix code and the instruction bits IK to lK+7 match the 2-byte escape code. Therefore this condition corresponds to an opcode of a new instruction type 1.
The opcode decoder 340 includes a regular one-byte decoder 430, a regular prefix decoder 432, a regular escape decoder 434, a new instruction type

0 decoder 436, and a new instruction type 1 decoder 438. These decoders essentially perform the decoding functions for the instruction as specified by the instruction opcodes in instruction bits IN to IN+7 and IK to IK+7 Although these decoders are shown in separate blocks, in practice the decoding of these instructions are combined.
Figure 5 is a flowchart illustrating a process P500 to perform instruction decoding using prefixes.
At START, the process P500 enters block B510 to decode the first byte, or the instruction bits IN to IN+7- Then the process P500 enters block B515 to determine if the first byte is a valid prefix code (e.g., OxF3). If NO, the process P500 enters block B520. If YES, the process P500 enters block B550.
At block B520, the process P500 determines if the first byte is a 2-byte escape code. If NO, the process P500 enters block B525. If YES, the process P500 enters block B540. At block B525, the process P500 determines if the first byte is other escape code (e.g., floating-point escape code). If NO, the process P500 enters block B530 to decode the first byte as a one-byte regular instruction. If YES, the process P500 enters block B532 to obtain the second byte and then to block B535 to decode the second byte as other regular instructions (e.g., floating-point instructions). The process P500 then terminates.
At block B540, the process P500 obtains the second byte and enters block B545 to decode the second byte as a new instruction type 0 (e.g., packed data instructions). The process P500 then terminates.

At block B550, the process P500 decodes the second byte, or the instruction bits IK to IK+7- The process P500 then enters block B560 to determine if the second byte is a 2-byte escape code. If NO, the process P500 enters block B565 to decode the second byte as an opcode of a regular instruction with the prefix as a qualifier. If YES, the process P500 enters block B570 to obtain the third byte and then block B575 to decode the third byte as a new instruction type 1 (e.g., scalar instructions). The process P500 then terminates.
The present invention provides an efficient method to encode a new instruction set using existing prefixes. The present invention therefore allows the new instruction set to be as large as necessary without complicating the instruction decoder.
While this invention has been described with reference to illustrative embodiments, this description is not intended to be construed in a limiting sense. Various modifications of the illustrative embodiments, as well as other embodiments of the invention, which are apparent to persons skilled in the art to which the invention pertains are deemed to lie within the spirit and scope of the invention.




WE CLAIM;-
1. An apparatus for decoding an instruction code issued from an instruction buffer, the instruction code having a plurality of fields, the apparatus comprising:
a prefix detector (320) coupled to the instruction buffer to receive the instruction code and to detect if a first field of the instruction code matches a prefix code;
an escape detector (320) coupled to the instruction buffer to receive the instruction code and to detect if a second field of the instruction code matches an escape code; and
an opcode decoder (340) coupled to the instruction buffer to receive the instruction code and to translate one of the first field, the second field, and a third field of the instruction code into a decoded instruction code.
2. The apparatus as claimed in claim 1 having a decoder enable circuit
(330) coupled to the prefix detector and the escape detector (320) to generate
enable signals to enable the opcode decoder (340).
3. The apparatus as claimed in claim 1 wherein the prefix code is one of
an address size prefix code (0x67), an operand size prefix code (0x66), a
segment override prefix code (Ox2E, 0x36, Ox3E, 0x26, 0x64, 0x65), a repeat
prefix code (OxF3), a repeat while equal prefix code (OxF3), a repeat while not
equal code (OxF2), and a lock prefix code (OxFO).
4. The apparatus as claimed in claim 1 wherein the escape code is OxOF.
5. An apparatus for decoding an instruction code issued from an
instruction buffer substantially as herein described with reference to the
accompanying drawings.


Documents:

461-del-1999-abstract.pdf

461-del-1999-claims.pdf

461-del-1999-correspondence-others.pdf

461-del-1999-correspondence-po.pdf

461-del-1999-description (complete).pdf

461-del-1999-drawings.pdf

461-del-1999-form-1.pdf

461-del-1999-form-13.pdf

461-del-1999-form-19.pdf

461-del-1999-form-2.pdf

461-del-1999-form-3.pdf

461-del-1999-form-4.pdf

461-del-1999-form-6.pdf

461-del-1999-gpa.pdf

461-del-1999-petition-137.pdf

461-del-1999-petition-138.pdf


Patent Number 216278
Indian Patent Application Number 461/DEL/1999
PG Journal Number 13/2008
Publication Date 28-Mar-2008
Grant Date 11-Mar-2008
Date of Filing 23-Mar-1999
Name of Patentee INTEL CORPORATION
Applicant Address 2200 MISSION COLLEGE BOULVARD,SANTA CLARA,CALIFORNIA 95052, U.S.A.
Inventors:
# Inventor's Name Inventor's Address
1 SURYAKANT THAKKAR 150 SOUTH WEST MOODRIDGE PLACE,PORTLAND,OREGON 97225,U.S.A
2 LANCE HACKING 15739 NORTH WEST RONDOS DRIVE,PORTLAND,OREGON 97229,U.S.A
3 THOMAS HUFF 618 NORTH WEST 12th STREET,PORTLAND,ORGEN 97209,U.S.A
4 PATRICE LOUIS ROUSSEL 2034 NORTH EAST 37th AVENUE PORTLAND,OREGON 97212,U.S.A
5 SRINIVAS CHENNUPATY 15727 NORTH WEST WISMER PORTLAND,OREGON 97229,U.S.A
PCT International Classification Number G06F 9/318
PCT International Application Number N/A
PCT International Filing date
PCT Conventions:
# PCT Application Number Date of Convention Priority Country
1 09/053,391 1998-03-31 U.S.A.