MICROPROCESSOR WITH TIME COUNTER FOR STATICALLY DISPATCHING INSTRUCTIONS WITH PHANTOM REGISTERS
20230273796 · 2023-08-31
Assignee
Inventors
Cpc classification
G06F9/3836
PHYSICS
G06F9/223
PHYSICS
G06F9/3869
PHYSICS
International classification
G06F9/38
PHYSICS
G06F9/30
PHYSICS
Abstract
A processor includes a time counter and provides a method for statically dispatching fused instructions with first operation and second operation with preset execution times for forwarding of result data from the first operation to the second operation without writing to a register, and where the preset execution times are based on a time count from the time counter provided to an execution pipeline.
Claims
1. A processor comprising: a time counter storing a time count representing a current time of the processor, wherein the time count is incremented periodically; an instruction issue unit coupled to the time counter for receiving a first fused instruction comprising a first operation and a second operation, wherein result data of the first operation are forwarded to the second operation without being stored in an intervening register, and issuing the first fused instruction with a preset execution time based on the time count; and an execution queue coupled to the time counter and the instruction issue unit to receive the first fused instruction from the instruction issue unit, and dispatch the first operation to a first functional unit when the preset execution time of the first operation corresponds to the time count and dispatch the second operation to a second functional unit when the preset execution time of the second operation corresponds to the time count, and wherein the result data from the first functional unit is forwarded to the second functional unit.
2. A processor as in claim 1 wherein: the processor includes a clock circuit, and the time counter increments the time count with each clock cycle; and the preset execution time is correlated to the time count based upon the clock cycle.
3. The processor of claim 2 wherein: the time counter comprises an N-bit counter wherein an Nth-bit count value represents a largest future time for the instruction issue unit to issue an instruction; and the N-bit counter returns to a zero count after reaching the Nth-bit value.
4. The processor of claim 3 further comprising a register scoreboard storing a write time of a register in a register file, and the write time is a future time based on the time count.
5. The processor of claim 4 further comprising an instruction decode unit coupled to the register scoreboard in which the instruction decode unit reads write times for source operands of an instruction from the register scoreboard, and uses the write times to determine an execution time for the instruction.
6. The processor of claim 5 further comprising a time-resource matrix unit coupled to the register scoreboard and the time counter for storing information relating to available resources for each time count of the N-bit time counter, and wherein the available resources include at least one of: a plurality of read buses, a plurality of write buses, and a plurality of functional units.
7. The processor of claim 6 wherein the instruction issue unit is coupled to the time resource matrix unit to receive data therefrom to issue an instruction if all the resources from the time-resource matrix are available, and to stall the instruction if any of the resources is not available.
8. The processor of claim 2 further comprising a read control unit reading a register of a register file or a forwarding functional unit with time count entries and for each register entry therein a forwarding valid bit to indicate when the corresponding register entry may be read and transported on a read bus or the corresponding result data of the functional unit may be forwarded and transported on a read bus.
9. The processor of claim 8 wherein the read control unit further comprises a replay bit to indicate that the instruction is to be canceled and replayed.
10. The processor of claim 8 further comprising a write control unit storing a register of a register file with time count entries to indicate when result data are transported from a write bus and written to a register of the register file.
11. The processor of claim 10 wherein the execution queue stores a plurality of instructions wherein each instruction includes a read time which is a future time based on the time count.
12. The processor of claim 11 wherein the read bus control is synchronized with the read time in the execution queue.
13. The processor of claim 10 wherein the execution queue dispatches instructions to at least one functional unit.
14. A processor comprising: a clock circuit; a time counter storing a time count representing a current time of the processor, wherein the time count is incremented with each cycle of the clock circuit; an instruction issue unit coupled to the time counter for receiving a first fused instruction comprising a first operation and a second operation wherein result data of the first operation are forwarded to the second operation, and issuing the first fused instruction with a preset execution time based on the time count; an execution queue coupled to the time counter and the instruction issue unit to receive the first fused instruction from the instruction issue unit, and dispatch the first operation to a first functional unit when the preset execution time of the first operation is correlated to the time count and the second operation to a second functional unit when the preset execution time of the second operation is correlated to the time count wherein the result data from the first functional unit is forwarded to the second functional unit; a register scoreboard storing a write time of a register in a register file, wherein the write time is a future time based on the time count; an instruction decode unit coupled to the register scoreboard, wherein the instruction decode unit reads write times for source operands of an instruction from the register scoreboard, and uses the write times to determine an execution time for the instruction; a time-resource matrix coupled to the register scoreboard and the time counter for storing information relating to available resources for each time count of the time counter, and wherein the available resources include at least one of: a plurality of read buses, a plurality of write buses, and a plurality of functional units.
15. A method for issuing a fused instruction with a first operation and a second operation to an execution queue in a processor to execute at a future time wherein the result data of the first operation is forwarded to the second operation without writing to a register and wherein the future time is time based on a time count from a time counter which is periodically incremented.
16. The method of claim 15 wherein the time counter provides a maximum time count corresponding to the latest future time to issue an instruction.
17. The method of claim 16 further comprising storing the write time of a register of a register file wherein the write time is a future time based on the time count.
18. The method of claim 17 further comprising storing information corresponding to available resources for each time count in a time-resource matrix, wherein the resources comprise at least one of a plurality of read buses, a plurality of write buses, and a plurality of functional units.
19. The method of claim 18 further comprising storing a register of a register file or a forwarding functional unit in a read bus control, wherein the register is read from the register file and transported on a read bus or the result data of the functional unit is forwarded and transported on a read bus.
20. The method of claim 19 further comprising storing a register of a register file in a write bus control wherein result data are transported from a write bus and written to the register of the register file.
21. The method of claim 15 further comprising storing a plurality of instructions in an execution queue wherein each instruction includes a read time based on the time count.
22. The method of claim 21 further comprising synchronizing the read time of the execution queue with the read bus control.
23. The method of claim 19, wherein the execution queue is configured to dispatch instructions to a single functional unit or to multiple functional units.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Aspects of the present invention are best understood from the following description when read with the accompanying figures.
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
DETAILED DESCRIPTION
[0017] The following description provides different embodiments for implementing aspects of the present invention. Specific examples of components and arrangements are described below to simplify the explanation. These are merely examples and are not intended to be limiting. For example, the description of a first component coupled to a second component includes embodiments in which the two components are directly connected, as well as embodiments in which an additional component is disposed between the first and second components. In addition, the present disclosure repeats reference numerals in various examples. This repetition is for the purpose of clarity and does not in itself require an identical relationship between the embodiments.
[0018] In one embodiment a processor is provided, typically implemented as a microprocessor, that schedules instructions to be executed at a preset time based on a time count from a time counter. In such a microprocessor the instructions are scheduled to be executed using the known throughput and latency of each instruction to be executed. For example, in one embodiment, the ALU instructions have throughput and latency times of 1, the multiply instructions have throughput time of 1 and the latency time of 2, the load instructions have the throughput time of 1 and latency time of 3 (based on a data cache hit), and the divide instruction have throughput and latency times of 32.
[0019]
[0020] According to an embodiment the microprocessor 10 also includes a time counter unit 90 which stores a time count incremented, in one embodiment, every clock cycle. The time counter unit 90 is coupled to the clock unit 15 and uses “clk” signal to increment the time count.
[0021] In one embodiment the time count represents the time in clock cycles when an instruction in the instruction issue unit 55 is scheduled for execution. For example, if the current time count is 5 and an instruction is scheduled to be execute in 22 cycles, then the instruction is sent to the execution queue 70 with the execution time count of 27. When the time count increments to 26, the execution queue 70 issues the instruction to the functional unit 75 for execution in next cycle (time count 27). The time counter unit 90 is coupled to the register scoreboard 40, the time-resource matrix 50, the read control 62, the write control 64, and the plurality of execution queues 70. The scoreboard 40 resolves data dependencies in the instructions. The time-resource matrix 50 checks availability of the various resources which in one embodiment include the read buses 66, the functional units 75, the load-store unit 80, and the write buses 68. The read control unit 62, the write control unit 64, and the execution queues 70 receive the scheduled times from the instruction issue unit 55. The read control unit 62 is set to read the source operands from the register file 60 on specific read buses 66 at a preset time. The write control unit 64 writes the result data from a functional unit 75 or the load-store unit 80 or the data cache 85 to the register file 60 on a specific write bus 68 at a preset time. The execution queue 70 is set to dispatch an instruction to a functional unit 75 or the load-store unit 80 at a preset time. In each case, the preset time is the time setup by the decode/issue unit. The preset time is future time based on the time count, so when the time count is counts up to the preset time, then the specified action will happen, where the specified action is reading data from the register file, writing data to the register file, or issuing instruction to a functional unit for execution. The decode/issue unit 30 determines that the instruction is free of data dependency and the resource is available to set the “preset time” for the instruction to be executed in the execution pipeline.
[0022] In the microprocessor system 10 the instruction fetch unit 20 fetches the next instruction(s) from the instruction cache 24 to send to the instruction decode unit 30. One or more instructions can be fetched per clock cycle from the instruction fetch unit depending on the configuration of microprocessor 10. For higher performance, microprocessor 10 fetches more instructions per clock cycle for the instruction decode unit 30. For low-power and embedded applications, microprocessor 10 might fetch only a single instruction per clock cycle for the instruction decode unit 30. If the instructions are not in the instruction cache 24 (commonly referred to as an instruction cache miss), then the instruction fetch unit 20 sends a request to external memory (not shown) to fetch the required instructions. The external memory may consist of hierarchical of memory subsystems, for example, an L2 cache, an L3 cache, read-only memory (ROM), dynamic random-access memory (DRAM), flash memory, or a disk drive. The external memory is accessible by both the instruction cache 24 and the data cache 85. The instruction fetch unit is also coupled with the branch prediction unit 22 for prediction of the next instruction address when the branch is detected and predicted by the branch prediction unit 22. The instruction fetch unit 20, the instruction cache 24, and the branch prediction unit 22 are described here for completeness of a microprocessor 10. In other embodiments, other instruction fetch and branch prediction methods can be used to supply instructions to the instruction decode unit 30 for microprocessor 10.
[0023] The instruction decode unit 30 is coupled to the instruction fetch unit 20 for new instructions and also coupled to the register scoreboard 40. The instruction decode unit 30 decodes the instructions for instruction type, instruction throughput and latency times, and the register operands. The register operands, as an example, may consist of 2 source operands and 1 destination operand. The operands are referenced to registers in the register file 60. The source and destination registers are used here to represent the source and destination operands of the instruction. The source registers support solving read-after-write (RAW) data dependencies. If a later instruction has the same source register as the destination register of an earlier instruction, then the later instruction has RAW data dependency. The later instruction must wait for completion of the earlier instruction before it can start execution. The register scoreboard 40 is used to keep track of the completion time of the destination registers of the earlier instructions. In the preferred embodiment the completion time is maintained in reference to the time count 90.
[0024] Each of the units shown in the block diagram of
[0025] The integrated circuitry employed to implement the units shown in the block diagram of
[0026] In other embodiments, the units shown in the block diagram of
[0027] The aforementioned implementations of software executed on a general-purpose, or special purpose, computing system may take the form of a computer-implemented method for implementing a microprocessor, and also as a computer program product for implementing a microprocessor, where the computer program product is stored on a non-transitory computer readable storage medium and include instructions for causing the computer system to execute a method. The aforementioned program modules and/or code segments may be executed on suitable computing system to perform the functions disclosed herein. Such a computing system will typically include one or more processing units, memory and non-transitory storage to execute computer-executable instructions.
[0028] One embodiment supports formation of a custom instruction by merging two existing instructions where the result data of the first instruction is forwarded to a second instruction without using the scarce resource of register and write port 68 to the register file 60. This is helpful in, for example, the RISC-V instruction set architecture (ISA) in which some opcode fields are reserved for custom instructions. The custom instruction, which can be generated by a compiler, is supported in the disclosed embodiment by “fusing” instructions in hardware. An example of a fused instruction is a multiply-accumulate instruction. The compiler option has the advantage of increased code density where two instructions are replaced with a single fused instruction. In the following description, the term “fused instruction” is used to refer to the custom instruction which consists of a first micro-operation (or first micro-op) corresponding to a first instruction and a second, subsequent, micro-operation (or second micro-op) corresponding to a second instruction. In a normal case, the first instruction writes result data to a destination register in the register file 60 and the second instruction has read-after-write data dependency with the first instruction. The second instruction retrieves the source operand data by reading the contents of the register from register file 60 or forwarding the result data from the functional unit of the first instruction. For a fused instruction, the first micro-op does not write result data back to the register file 60 and the second micro-op receives only data forwarded from the functional unit of the first micro-op. In one embodiment, the first micro-op writes result data to a phantom register and the second micro-op reads data from the phantom register to establish the read-after-write data dependency of the second micro-op to create the data forwarding path from the functional unit of the first micro-op to the functional unit of the second micro-op. As used herein, the term “phantom register” does not refer to an actual register, such as a temporary register that is used to pass data from one functional unit to another functional unit. Instead, the term “phantom register” refers to a mechanism in static scheduling to pass data from one functional unit to another functional unit without using any temporary register and is explained in further detail in connection with
[0029]
[0030] The write time of a destination register is the read time for the subsequent instruction with RAW data dependency on the same destination register. Referring back to
[0031] An instruction reads source operand data at read time, executes the instruction with a functional unit 75 at execute time, and writes the result data back to the register file 60 at write time. The write time is recorded in the write time field 46 of the register scoreboard 40. With 2 source registers, the instruction selects the later write time from the register scoreboard 40 as the read time for the instruction. The execute time is the read time plus 1 time count where the functional unit 75 or the load-store unit 80 starts executing the instruction. The write time of the instruction is the read time plus the instruction latency time. If the instruction latency time is 1 (e.g., an ALU instruction), then the write time and execution time of the instruction are the same.
[0032] Each instruction has an execution latency time. For example, the add instruction has a latency time of 1, the multiply instruction has a latency time of 2, and the load instruction has a latency time of 3 assuming a data cache hit. In another example, if the current time count is 5 and the source registers of an add instruction receive write time counts of 22 and 24 from the register scoreboard 40, then the read time count is set at 24. In this case, the execution and the write time counts are both 25 for the add instruction. As shown in
[0033]
[0034] The read buses column 51 corresponds to the plurality of read buses 66 in
[0035]
[0036] All available resources for the required times are read from the time-resource matrix 50 and sent to the instruction issue unit 55 for a decision of when to issue an instruction to the execution queue 70. If the resources are available at the required times, then the instruction can be scheduled and sent to the execution queue 70. The issued instruction updates the register scoreboard 40 with the write time and updates the time-resource matrix 50 to reduce the available resource values. All resources must be available at the required time counts for the instruction to be dispatched to the execution queue 70. If all resources are not available, then the required time counts are incremented by one, and the time-resource matrix is checked as soon as the same cycle or next cycle. The particular number of read buses 66, write buses 68, and functional units 75 in
[0037] In one embodiment, the first micro-op of the fused instruction does not have any assigned destination register and write port. The write time 46 of the register scoreboard 40 is used only for forwarding to the second micro-op. The first micro-op checks the write buses 52 of the time-resource matrix 50 for availability of write buses. In order to ensure that the second micro-op will receive the forwarding data, the first and second micro-ops must check for available resources from the time-resource matrix 50 at the same time. The read time and execution time of the first micro-op and the read time, execution time, and write time of the second micro-op concurrently access the time-resource matrix 50 as one set of time for issuance of both micro-ops together. Stated another way, a fused instruction has read/execute/read/execute/write times to access the time-resource matrix 50. The first read/execute is for first micro-op, the subsequent read/execute/write is for second micro-op. If any resource is not available then both micro-ops cannot be issued, the required time counts are incremented by 1, and the time-resource matrix 50 is checked as soon as the same cycle or next cycle.
[0038]
[0039] In the example illustrated in
[0040] In one embodiment, the source register field 61 includes either the register of the register file 60 or the identification of the functional unit which will forward data to the read port. The forward bit 63 is set if the source register field 61 contains the identification (ID) of the functional unit. If the forward bit 63 is set, then the read buses 66 use the functional unit ID stored in the source register field 61 for forwarding of result data from the functional unit. Instead of the source register, the register field 61 stores the ID of the functional unit which is referred to as the phantom register. As illustrated in
[0041]
[0042] Note that the destination register can be, but does not need to be, kept with the instruction. The write control unit 64 is responsible for directing the result data from a functional unit 75 to a write bus 68 to write to the register file 60. The execution queues 70 are only responsible for sending instructions to the functional units 75 or the load-store unit 80. The read time field 77 which has the read time of the instruction is synchronized with the read control unit 62. When the read time 77 is the same as the time count 90 as detected by the comparators 78, the instruction is issued to the functional units 75 or the load/store unit 80. For the example in
[0043] In an embodiment, each functional unit 75 has its own execution queue 70. In another embodiment, an execution queue 70 dispatches instructions to multiple functional units 75. In this case, another field (not shown) can be added to the execution queue 70 to indicate the functional unit number for dispatching of instructions.
[0044] Referring back to
[0045] As shown in
[0046] The read control unit 62 provides the registers 61 (
[0047] In
[0048] In one embodiment, the first micro-op of the fused instruction is dispatched from the execution queue 70 to the first set of “A” multiplexers, source registers, and functional unit 75A. The result data from the functional unit 75A is forwarded to the second micro-op through the second set of “B” multiplexes, source registers, and functional unit 75B. At the time count for the second micro-op, the read control unit 62 has the forward bit 63 set and has the ID of the functional unit 75A in the register field 61. The read control unit 62 selects the result data from the functional unit 75A to send to the second source operand 112B through the multiplexers 120B and 116B. The first micro-op does not set any entry in the write control unit 64, so the result data from functional unit 75A is not selected for writing into the register file 60.
[0049] The multiply-accumulate instruction is used as example for a fused instruction. It is of course, merely an example of a fused instruction and is not intended to be limiting. For example, a load and add instruction can be used, or more than two instructions can be fused.
[0050] The foregoing explanation described features of several embodiments so that those skilled in the art may better understand the scope of the invention. Those skilled in the art will appreciate that they may readily use the present disclosure as a basis for designing or modifying other processes and structures for carrying out the same purposes and/or achieving the same advantages of the embodiments herein. Such equivalent constructions do not depart from the spirit and scope of the present disclosure. Numerous changes, substitutions and alterations may be made without departing from the spirit and scope of the present invention.
[0051] Although illustrative embodiments of the invention have been described in detail with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes and modifications can be affected therein by one skilled in the art without departing from the scope of the invention as defined by the appended claims.