This invention relates to a technique for providing configurable instruction sequence generation, and more particularly to a technique for using virtual instructions to generate a sequence of instructions to be executed by a processor.
Reduced instruction set computer (RISC) architectures were developed as industry trends tended towards larger, more complex instruction sets. By simplifying instruction set designs, RISC architectures make it easier to use techniques such as pipelining and caching, thus increasing system performance. By focusing on speed and simplicity of design, rather than instruction semantics, RISC architectures often result in larger executable code size than comparable complex instruction set computer (CISC) architecture machines. For example, a task that may be represented as one complex instruction in a CISC architecture may take two or more instructions in a RISC architecture. However, the performance gains resulting from increased clock speeds and increased pipelining that may be attained with a RISC architecture usually outweigh any increase in executable code size.
RISC architectures usually have fixed-length instructions (e.g., 16-bit, 32-bit, or 64-bit), with few variations in instruction format. For example, each instruction in an instruction set architecture (ISA) may have the source registers in the same location. For example, a 32-bit ISA may have source registers specified always by bits 16-20 and 21-25. This allows the specified registers to be fetched for every instruction without requiring any complex instruction decoding
In one general aspect, an instruction set architecture includes a virtual instruction for generating a sequence of underlying machine instructions. A virtual instruction includes an opcode that identifies the instruction as a virtual instruction. The virtual instruction, having zero or more virtual parameters, is associated with a sequence of instructions.
Implementations may include a virtual instruction index within a virtual instruction code. The index may identify one virtual instruction from multiple available virtual instructions. Some implementations may provide virtual parameters, each of which includes a predetermined number of bits; or each of which includes either a first predetermined number of bits or a second predetermined number of bits. For example, one implementation may provide three-bit and five-bit virtual parameters.
Each virtual instruction is associated with a sequence of instructions to execute.
Each instruction in the sequence may include an instruction template identifying an instruction to be performed, a parameter selector identifying a dynamic parameter substitution, and other control information relating to the execution of that instruction within the sequence. Implementations may include one or more of the following substitutions: a parameter field, such as a register specifier, may be replaced by a virtual parameter; an opcode field may be replaced by a virtual parameter; an immediate field may be replaced by a virtual parameter; an immediate field may be replaced with a sign-extension of a virtual parameter; and an immediate field may be replaced with sign-extended or unextended concatenations of one or more virtual parameters.
The details of one or more implementations are set forth in the accompanying drawings and the description below. Other features and advantages will be apparent from the description and drawings, and from the claims.
A virtual instruction is an instruction that is not executed directly by a processor. Rather, a virtual instruction causes a sequence of one or more instructions to be generated. The generated instructions then are executed by the processor. Virtual instructions may be used to provide more complex instructions in an ISA.
For example, a standard ISA may not have an operation for adding three numbers together and storing the result in a register. A particular application using the ISA may repeatedly add three numbers. The developers of a processor for the particular application may not wish to modify the processor entirely, yet significant code compaction may be obtained by providing an instruction for adding three numbers. A virtual instruction called “ADD3” that adds three numbers may be provided. Whenever the “ADD3” instruction is fetched, the system identifies the instruction as a virtual instruction and generates a corresponding sequence of instructions to add three numbers.
Virtual instructions provide a mechanism to implement a configurable instruction set architecture so that application-specific instructions or other specialized instructions may be added to an instruction set without redesigning or modifying a processor core.
Referring to
Because some operations, such as floating point calculations and integer multiply/divide, cannot be performed in a single clock cycle, some instructions merely begin execution of an operation. After sufficient clock cycles have passed, another instruction may be used to retrieve a result. For example, an integer multiply instruction may take, for example, five clock cycles. One instruction may initiate the multiplication calculation, and another instruction may load the results of the multiplication into a register.
Virtual instructions help to offset costs that may be associated with the simplicity, elegance, and adherence to design principles provided by RISC architectures. Because multiple RISC instructions often are used instead of a single complex instruction, the overall size of executables is larger for RISC architectures than for others. Because computer storage is usually inexpensive, the increased storage costs are rarely a factor. However, in some applications, such as smart cards and application specific integrated circuits (ASICs), the available memory may be limited. In applications such as these, virtual instructions provide a mechanism for reducing the size of executables without significantly reducing pipeline efficiency.
Virtual instructions also offer benefits in consumer electronics, such as wireless telephones, global positioning system receivers, electronic games, and personal digital assistants, which have contributed to the growth of the embedded CPU market. Instead of building devices from commercially available, general-purpose components, manufacturers have increasingly turned to designs based on application-specific integrated circuits (ASICs). When CPU cores are embedded on chips complete with on-board caches and memory, the amount of storage space may be limited. Virtual instructions help to decrease the size of executables by adding the capability of executing complex instructions.
For example, a developer may need a compact code solution for embedded control applications. Some CISC products may include 32-bit instructions capable of setting, clearing, or testing a single bit in memory or input/output (I/O) space. While it generally may not be desirable to include such operations within a RISC processor core, virtual instructions provide a general mechanism in a RISC ISA that allows developers to add complex instructions appropriate to specific applications.
Referring to
In
Instruction expansion store 220 may be implemented as a data structure containing one or more rows of data. Each row within the data structure may include an instruction to be executed as well as a dynamic parameter selector and other control information. For example, the exemplary instruction expansion store 220 shown in
A virtual program counter (PC) 230 stores the address or offset of the current instruction within the instruction expansion store 220. For example, when a virtual instruction begins execution, the start address for the corresponding instruction sequence is loaded into the virtual PC 230. As each instruction is executed, virtual PC 230 may be updated to step through the instruction expansion store 220 until the last instruction within a sequence is generated.
The last instruction within a virtual instruction expansion may be indicated in many ways. For example, information stored along with the dynamic parameter selector may be used to indicate the end of an instruction sequence. For example, if a 32-bit word is used to direct dynamic parameter substitution, one or more bits may be used to indicate that the instruction is the last within an expansion. Additionally, a new instruction may be used to indicate that the last instruction has been reached.
Substitution logic 240 is used to substitute parameters from virtual instruction 200 into instruction templates from instruction expansion store 220. The resulting instruction then may be passed on to the decode stage 250 of the processor.
Additional implementations may not use a virtual start table 210. If only a single virtual instruction is provided, or if virtual instruction expansion information is stored in a fixed or known location, then the extra level of indexing provided by virtual start table 210 may be unnecessary. In such implementations, index 201 also may not be needed, and an opcode may be sufficient to identify a particular virtual instruction and to locate the beginning of corresponding instructions within instruction expansion store 220.
Referring to
During execution of a virtual instruction, the virtual instruction is held in the instruction fetch stage of the pipeline, and the PC, as opposed to the virtual PC, remains fixed at the address of the virtual instruction, while the fetch logic passes a fixed sequence of instructions to the decode stage of the pipe. When the last instruction has been issued, the PC can advance. As the entire sequence takes place at the same PC, conventional branches which manipulate the PC may not take place internal to the virtual instruction sequence—though a virtual instruction sequence could conceivably terminate with a control transfer. Conditional execution within a virtual instruction may be handled in terms of conditional moves or other predicated execution mechanisms. In the simplest implementation, any exceptions taken during the execution of the virtual instruction sequence use the address of the virtual instruction as the value of the exception return address (EPC) register or error PC, and restart the virtual instruction sequence from the beginning after completion of any exception handling. For this reason, it may be desirable to use virtual instructions that are fully restartable at any point in their execution.
Additional implementations may allow branching within a virtual instruction expansion. For example, one virtual instruction implementation may provide specific instructions for branching within a virtual instruction sequence, allowing branching within the expansion of a virtual instruction. Another implementation may redefine the semantics of branch instructions so that when conventional branch instructions are encoded within a virtual instruction expansion they exhibit different behavior. Other virtual instruction branching schemes will be apparent.
In the following discussion, “VINSTR” is used as the name for application-specific virtual instructions. Generic compiler tools may assemble and disassemble the instruction by that name, but tools also may give application-specific names to various VINSTR instantiations. For example, the generic VINSTR instruction includes the parameters as shown in
Additional implementations may encode a virtual instruction using a code to specify the virtual instruction expansion to be performed, and one or more parameters. As will be discussed below with reference to parameter selection, there is a trade-off between compactness, complexity, and flexibility of parameter substitutions.
Referring to
Next, the system uses the start address referenced by virtual PC 230 to lookup an instruction within instruction expansion store 220 (step 4006). For example, the virtual PC 230 shown in
In some implementations, the parameter selector may support predicated execution of instructions within a virtual instruction expansion. Predicated execution may be implemented by using a parameter selector to indicate whether an instruction should be suppressed based on, for example, one or more virtual instruction parameters. In such an implementation, an instruction template, such as the “ADDI $7, 0” shown in
The resulting instruction is returned as the result of IF stage 1001. The processor then executes this instruction (step 4009). Finally, the system determines if this was the last instruction within a virtual instruction sequence (step 4010). If there are additional instructions, the virtual PC is updated (step 4011) and the next instruction is loaded (step 4006). If there are no additional instructions, then the PC is updated (step 4012). In this implementation, the PC is not updated until the entire virtual instruction sequence is complete.
To support dynamic parameter substitution, the virtual instruction expansion store may contain more than just the sequence of 32-bit instructions to be presented to the pipeline. Additional information may be provided to indicate when, and how, parameters should be substituted for the literal content of fields within each 32-bit instruction.
Implementations may support any combination of the following dynamic parameter substitutions: (1) replacement of a parameter field with a translated or untranslated VINSTR parameter field; (2) replacement of an immediate field with a sign-extension of a VINSTR parameter field; (3) replacement of a portion of an immediate field with a VINSTR parameter field; (4) replacement of an immediate field with sign-extended or unextended concatenations of parameter fields; and/or (5) replacement of an instruction opcode or subopcode with a translated or untranslated VINSTR parameter.
One dynamic parameter substitution that may be provided is to replace a selected register field with a virtual instruction parameter. For example, an “ADD” instruction may have three parameters: “RS”, “RT”, and “RD”. The instruction causes the contents of the register specified by RS to be added to the contents of the register specified by RT and then stored in the register specified by RD. In virtual instruction 200, two parameters are specified, one parameter 202 having 3 bits and one parameter 203 having 5 bits. One implementation provides 32 registers, each register specified by 5 bits. In this example, parameter 202 may be translated to a 5-bit register specification. For example, one translation may be to append “00” to the beginning of the three-bit value, allowing only registers 0 to 8 to be specified.
Additional translations may be used. However, it may be necessary to limit certain expansions to certain parameter fields in order to reduce the combinatorial explosion of specifier data. There is a trade off between the increase in virtual instruction size and the decrease in virtual instruction capability that results from more restricted substitution.
Another dynamic parameter substitution that may be performed is the replacement of an immediate field with a sign-extension of a VINSTR parameter field. For example, the “ADDI” instruction allows an immediate value to be added to the contents of a register. This substitution allows the immediate value field to be specified by one of the virtual instruction parameter fields. The immediate field may be 16 bits, while the virtual instruction parameter may be only five bits. However, the 5-bit value may be sign extended to 16 bits. Sign extension may not be needed if the instructions are stored initially with zeros in the immediate field.
Another dynamic parameter substitution includes the replacement of immediate fields with sign-extended or unextended concatenations of parameter fields. For example, 8-bit immediate values may be created by concatenating 3-bit and 5-bit virtual instruction parameter fields. Additionally, dynamic parameter substitution may include the replacement of an instruction opcode or sub-opcode with a translated or untranslated VINSTR parameter field. This allows, for example, one or more instructions in a virtual instruction sequence to be selected by one or more VINSTR parameter.
In addition to virtual instruction implementations using hardware, (e.g., within a microprocessor or microcontroller) implementations also may be embodied in software disposed, for example, in a computer usable (e.g., readable) medium configured to store the software (i.e., a computer readable program code). The program code causes the enablement of the functions or fabrication, or both, of the systems and techniques disclosed herein. For example, this can be accomplished through the use of general programming languages (e.g., C, C++), hardware description languages (HDL) including Verilog HDL, VHDL, AHDL (Altera HDL) and so on, or other available programming and/or circuit (i.e., schematic) capture tools. The program code can be disposed in any known computer usable medium including semiconductor, magnetic disk, optical disk (e.g., CD-ROM, DVD-ROM) and as a computer data signal embodied in a computer usable (e.g., readable) transmission medium (e.g., carrier wave or any other medium including digital, optical, or analog-based medium). As such, the code can be transmitted over communication networks including the Internet and intranets.
It is understood that the functions accomplished and/or structure provided by the systems and techniques described above can be represented in a core (e.g., a microprocessor core) that is embodied in program code and may be transformed to hardware as part of the production of integrated circuits. Also, the systems and techniques may be embodied as a combination of hardware and software. Accordingly, other implementations are within the scope of the following claims.
This application is a continuation of U.S. patent application Ser. No. 09/788,682, filed Feb. 21, 2001, which is incorporated herein by reference in its entirety. This application is related to the following commonly owned applications, each of which is incorporated herein by reference in its entirety: U.S. application Ser. No. 09/788,683, filed Feb. 21, 2001; U.S. application Ser. No. 09/788,670, filed Feb. 21, 2001; U.S. application Ser. No. 09/788,684, filed Feb. 21, 2001; and U.S. application Ser. No. 09/788,685, filed Feb. 21, 2001.
Number | Date | Country | |
---|---|---|---|
Parent | 09788682 | Feb 2001 | US |
Child | 11644001 | Dec 2006 | US |