Abstract:
A method of compacting an instruction queue in an out of order processor includes determining the number of invalid instructions below and including each row in the queue, by counting invalid bits or validity indicators associated with rows below and up to the current row. For each row, multiplexor select signals are generated from the flat vector counts for the N rows above and including the present row, and from the validity indicators associated with the N rows, where N is a predetermined value. A multiplexor associated with a particular row selects one of the N rows according to the select value, and moves or passes the instruction held in the selected row to the present row. A row&#39;s select value is determined by forming a diagonal from the N count vectors corresponding to the N rows above and including the present row, and logically ANDing, each diagonal bit with the valid bit associated with the same row. Each row&#39;s count vector is determined in two stages. In the first stage, a local count is determined for each row in a local group of rows, and a global count is determined for the entire local group. Each local count is determined by counting the validity indicators associated with rows in the local group. In the second stage, a final count is determined for each row in the queue, by combining the local and global counts generated for the local group in the first stage, with global counts generated in local groups below the local group. The N rows can extend to the queue&#39;s input pipeline.

Description:
RELATED APPLICATIONS  
       [0001]    This application is a continuation of U.S. application Ser. No. 09/465,175, filed Dec. 17, 1999, which claims the benefit of U.S. Provisional Application No. 60/118,130, filed on Feb. 1, 1999. The entire teachings of the above applications are incorporated herein by reference. 
     
    
     
       BACKGROUND OF THE INVENTION  
         [0002]    An instruction queue is typically a random-access storage array which holds instructions between the time they are fetched from memory and when they are issued to an execution unit. The queue is typically structured as a set of rows, each of which holds one instruction.  
           [0003]    In many modern microprocessors, instructions issue from the instruction queue out-of-order, with instruction prioritization managed with pointers to the oldest and newest instructions in the queue. The concept of out-of-order execution is also called “dynamic execution” or “dynamic scheduling”. The queue structure itself may also be called an “instruction buffer”, “re-order buffer”, or “scoreboard”.  
           [0004]    In some CPUs, for example, the instruction queue is called a “Re-order Buffer.” There are two buffers, one for ALU instructions and one for memory operations, each containing twenty-eight entries. Instructions remain in a buffer from the time they are fetched until they are retired, and are not removed at issue time. Instructions are inserted into a queue in a round-robin fashion based on the “newest” instruction pointer. Issue arbitration starts at the oldest instruction pointer, looking for the first data-ready instruction. Because instructions remain in the buffer during their life and retire in-order, empty rows are not produced within the buffer.  
           [0005]    Other instruction queue architectures, sometimes called re-order buffers, appear to hold twenty-four instructions through similar execute and retirement operations.  
           [0006]    Other out-of-order issue machines with a 16-entry or larger re-order buffer track the status of each in-flight instruction, and twelve integer and eight floating-point “rename buffers” assign instructions to execution units. Each execution unit has a “reservation station,” that is, an instruction buffer dedicated to an execution unit from which data-ready instructions are issued.  
         SUMMARY OF THE INVENTION  
         [0007]    In each cycle of a computer system encompassing the present invention, any combination of up to four instructions can be issued from the queue, and up to four new instructions can enter the queue. Instructions are removed from the queue two cycles after they are issued, creating empty queue rows. New instructions can enter the queue only when there are a sufficient number of empty rows in which to place the instructions.  
           [0008]    While in the queue, instructions are prioritized to prevent deadlock by insuring all instructions are issued from the queue in a finite amount of time, and to meet performance goals by issuing oldest instructions first.  
           [0009]    A preferred embodiment of the present invention compacts older instructions toward the bottom of the queue each cycle while maintaining their original order, using an update logic circuit which generates control signals to perform the compaction. This creates room at the top of the queue where new instructions enter. This greatly simplifies the issue prioritization process, allowing the use of fast, simple arbitration circuits.  
           [0010]    One system employing the present invention has two instruction queues: an integer queue with twenty entries, or rows, and a floating point queue with fifteen entries. The bottom row is numbered row  0 , and the top row is  19  for the integer queue and  14  for the floating-point queue. Operation of the queues is similar, thus attention is focused primarily on the integer queue.  
           [0011]    Pointers are not used. Instructions in the queue are ordered, from the bottom to the top, in the relative order in which they entered the queue. Instructions are removed from the queue when they are issued, i.e., sent to functional units for execution.  
           [0012]    Because instructions are issued out-of-order, removal of instructions from the queue leaves empty rows, marked as invalid, scattered throughout the queue. The remaining instructions are physically compacted in the queue toward the bottom, i.e., row  0 , each cycle. This leaves empty queue rows toward the top of the queue, where they are filled with instructions entering in subsequent cycles. This operation is preferably simplified by moving instructions at most four rows lower each cycle. Since no more than four instructions enter the queue each cycle, maximum input bandwidth is guaranteed.  
           [0013]    Instructions are moved through the queue via multiplexors associated with each queue row. Each multiplexor has five data inputs. For row N, these inputs correspond to the contents of rows N through N+4. An instruction in row N+2 is moved to row N by asserting the “N+2” multiplexor select signal for the multiplexor associated with row N. The Update Logic circuit generates each row&#39;s multiplexor selects to control the compaction of the queue.  
           [0014]    Maintaining instructions in-order from bottom to top of the queue eliminates the use of pointers to track oldest/newest queue instructions. This greatly simplifies the issue prioritization process, allowing the use of fast, simple arbitration circuits.  
           [0015]    In a fast computer system, e.g., one having a frequency of 600 MHZ, simplifying the arbitration stage, i.e., the primary critical path in the issue logic, is essential to meet performance goals. Adding an extra stage of logic to the issue signal critical path to prioritize instructions based on pointers would mean running at a much slower cycle time, reducing the performance of the entire machine.  
           [0016]    Accordingly, a method of compacting an instruction queue in an out of order processor, comprises determining the number of invalid instructions below and including each row in the queue, by counting invalid bits or validity indicators associated with rows below and up to the current row.  
           [0017]    For each row, a select value is determined from the previously determined counts for the N rows above and including the present row, and from the validity indicators associated with the N rows, where N is a predetermined value. A multiplexor associated with a particular row selects one of the N rows according to the select value, and moves or passes the instruction held in the selected row to the present row.  
           [0018]    Where a maximum of N new instructions can enter the queue during any given cycle, it is sufficient to limit each count to N.  
           [0019]    Preferably, each count is a flat vector, where each position in the vector indicates a different number of valid instructions up to the present row, and in which only one bit is set at any time.  
           [0020]    A row&#39;s select value is preferably determined by forming a diagonal from the N counts corresponding to the N rows above and including the present row, and logically ANDing, or masking, each diagonal bit with the valid bit associated with the same row.  
           [0021]    Preferably, only valid queue instructions are moved.  
           [0022]    In a preferred implementation, however, validity indicators must be moved regardless of the validity indicator. Thus, for each row, an additional modified select value is determined, similar to the select value already determined. However, the most significant bit is not masked, and is derived from a modified diagonal. A second multiplexor associated with each row moves a valid bit from a row indicated by the modified select value to the validity indicator storage location associated with the present row.  
           [0023]    Preferably, each row&#39;s count is determined in two stages. In the first stage, a local count is determined for each row in a local group of rows, and a global count is determined for the entire local group. Each local count is determined by counting the validity indicators associated with rows in the local group. In the second stage, a final count is determined for each row in the queue, by combining the local and global counts generated for the local group in the first stage, with global counts generated in local groups below the local group.  
           [0024]    Preferably, the N rows can extend to the queue&#39;s input pipeline. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0025]    The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the invention.  
         [0026]    [0026]FIG. 1 is a block diagram illustrating the pipeline stages of a CPU to which the present invention is applied.  
         [0027]    [0027]FIG. 2 is a block diagram showing the relationship between the issue logic, update logic, and execution units of the CPU.  
         [0028]    [0028]FIG. 3 is a block diagram describing the organization of the issue logic.  
         [0029]    [0029]FIG. 4 is a timing diagram illustrating the register request, arbitration, scoreboard update, and instruction execution.  
         [0030]    [0030]FIG. 5 is a schematic diagram illustrating the instruction queue compaction process of the present invention  
         [0031]    [0031]FIG. 6 is a schematic diagram illustrating one of the multiplexors which move instructions through the queue.  
         [0032]    [0032]FIG. 7 is a schematic diagram illustrating the counters and valid bits associated with each queue row.  
         [0033]    [0033]FIG. 8 is a schematic diagram illustrating a preferred method of generating the update signals from the counters.  
         [0034]    [0034]FIG. 9 is a block diagram of a preferred embodiment of the Update Logic circuit for five of the twenty queue rows.  
         [0035]    [0035]FIG. 10 is a schematic diagram of a simplified circuit of a local stage  1  adder circuit of FIG. 9.  
         [0036]    [0036]FIG. 11 is a schematic diagram illustrating a preferred implementation of generating update signals for the valid indicators.  
         [0037]    [0037]FIG. 12 is a schematic diagram illustrating a problem which the implementation shown in FIG. 11 resolves. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0038]    [0038]FIG. 1 is a block diagram illustrating the pipeline stages of a CPU  10  in which the present invention is implemented. Specifically, during fetch stages  0  and  1 , four instructions  12  are fetched per machine cycle from the instruction cache  14 .  
         [0039]    Mapping pipeline stage  2  assigns the virtual registers identified in the fetched instruction to physical registers maintained in the CPU  10 . In the preferred embodiment, four instructions are renamed per cycle, assigning up to eight source and four destination registers. Further, there are eighty physical integer registers and seventy-two physical floating point registers. These mappings are performed in a separate integer register mapper  22  and a floating point register mapper  24 .  
         [0040]    Queue pipeline stage  3  issues instructions out-of-order when data is ready, i.e., when the registers containing the data are available. In the preferred embodiment, there are twenty instruction rows in the integer queue  26  and fifteen instruction rows in the floating point queue  28 . Four integer instructions issue per cycle, and up to two floating point instructions issue per cycle.  
         [0041]    Instructions leave the queues after they issue and the empty rows are marked as invalid. Valid flags or indicators are maintained in valid indicator storage locations. A valid indicator storage location is associated with each queue row.  
         [0042]    In register pipeline stage  4 , dual integer register files  30 ,  32  pass the data required by the issued instructions to four integer execution units  34 - 40 . In a similar fashion, floating point register file  42  passes the required data for the floating point instructions to floating point divide/squareroot unit  44  and floating point multiply unit  46 .  
         [0043]    Two of the integer execution units  36 ,  40  have the capability to issue addresses to data cache  48 , enabling two load/stores per cycle. The data cache  48  communicates off-chip via the bus interface  50 .  
         [0044]    [0044]FIG. 2 shows the general layout for integer execution. Four integer execution units  34 - 40  are arranged in two clusters, Cluster  0  and Cluster  1 . Each cluster contains a complete copy of the register file: register file 0  30  and register file 1  32 . The physical distance between the clusters requires that one cycle of latency exist between the conclusion of an operation in one cluster and the availability of the destination register in the other cluster. Register result data crosses between the clusters in intercluster register bypass buses  56 .  
         [0045]    The issue logic  100  schedules instructions to minimize the inter-cluster latency. The instructions are statistically assigned to request either the upper or lower pairs of execution units. This allows the instructions to have an opportunity to issue on the same cluster that produces the dependent register.  
         [0046]    [0046]FIG. 3 shows the issue logic data path for the instruction queue. It contains twenty rows, one instruction occupying each row. The instructions are ordered from the oldest, INST 0 , at the bottom to the newest, INST 19 , in row  19 , at the top. Up to four instructions enter the instruction queue per cycle, requiring compaction of the instructions remaining in the queue toward the bottom every cycle.  
         [0047]    Register scoreboard logic is divided in halves  102 ,  104  book-ending the update  106 , valid  108 , arbiter  110 , and request logic  112 . Register scoreboard logic  102  holds the forty even registers and register scoreboard logic  104  holds the odd registers of the eighty integer physical registers, in the preferred embodiment.  
         [0048]    For every instruction and each potential register required by the instructions, the register scoreboard logic holds two decoded fields (see fields a, b in register score board logic  104  at instruction INST 0 ). The lower field is the decoded source register, and the upper field is the decoded destination register. Each cycle, the source field is compared to outstanding destination register numbers and a match signal is generated on one of two register request wires  114  running across the data path.  
         [0049]    The request logic  112  stores execution unit assignment information. Each of the execution units  34 - 40  may execute different instructions or may or may not have access to the data cache  48 . The request logic combines the execution assignment information with the two register request signals  114 . The output is a four bit field  116  that indicates the execution units requested to the arbiter  110  by each row/instruction.  
         [0050]    The arbiter  110  contains two pick-oldest-two arbiter circuits operating in parallel to choose up to four instructions each cycle for execution.  
         [0051]    The valid logic  108  maintains a valid bit for each row and pulls one of the request lines when invalid. It calculates a new valid bit each cycle based on issue, invalidate, and reset information.  
         [0052]    Finally, the update logic  106  accepts five new valid bits each cycle and generates five select signals  117  used to compact the instructions in the queues  102 ,  104 .  
         [0053]    [0053]FIG. 4 is a timing diagram showing the progress of instructions from request to execution. In the illustrated example, ADD enters the queue, requests an execution unit, and wins the arbitration by the end of machine cycle  3 , i.e., request and arbitration occur within one machine cycle. The issue signal is an index into the array with the instruction data enabling the instruction read in cycle  4 . Passage of the instruction to the execution unit enables the register file read in the end of cycle  4  and the instruction execution in cycle  5 .  
         [0054]    Next, the SUB instruction can request to issue in cycle  4  since in the present invention, issuance of single cycle instructions makes available the corresponding registers for the next machine cycle. In this case, destination register R 3  of ADD will be reflected as available in the scoreboard logic  102 ,  104  for the subsequent SUB, which uses R 3  as the source register.  
         [0055]    The issued instructions participate in the update calculation, which will overwrite that row in cycle  4  for the ADD and cycle  5  for the SUB, since in those cycles the corresponding instructions have exited the queue. This provides queue compaction at the beginning of each cycle as indicated by shaded region  116 . The update logic calculates multiplexor select signals from valid states of the instructions in the queue and moves enough instructions to the bottom of the queue to free up to four rows at the top for newly fetched instructions.  
         [0056]    Queue Compaction  
         [0057]    [0057]FIG. 5 illustrates the instruction queue compaction process  156 . For example, before compaction, the instruction queue  150 A holds several valid instructions, INST A-INST J. Since instructions are issued out-of-order, removal of instructions from the queue leaves empty, or invalid, rows, indicated by asterisks (*), scattered throughout the queue  150 A.  
         [0058]    Each cycle, the remaining valid instructions INST A-INST J are physically compacted in the queue, toward the bottom, i.e., row  0 , resulting in the queue as shown at  150 B. In a preferred embodiment, compaction is simplified by moving instructions at most four rows each cycle. Because no more than four instructions enter the queue each cycle, the first four empty rows  152  will always be at the top of the queue. Thus, up to four new instructions are placed at the top of the queue, at  154 , each cycle.  
         [0059]    [0059]FIG. 6 illustrates one of the multiplexors  130  which move instructions through the queue. Preferably, one multiplexor is associated with each queue row. Here, queue row N  138  is shown with its associated multiplexor  130 .  
         [0060]    In the illustrated embodiment, each multiplexor has five data inputs  136 . For row N, for example, these inputs  136  correspond to the instructions stored in rows N through N+4. One of the input instructions is selected by the multiplexor  130  and passed to queue row N  138 . Five select signals UPDATE&lt;4-0&gt;  134 , generated for each row by the update logic circuit  106  (FIG. 3), determine which of the five input instructions  136  will be moved to row N. For example, an instruction at row N+2 is moved two rows lower to row N by asserting the UPDATE&lt;2&gt; select signal to the multiplexor  130  for row N.  
         [0061]    Note that each instruction stored in the queue forms an input to its own multiplexor as well as the multiplexors associated with the four rows immediately below. For example, the contents  140  of queue row N, is routed to multiplexors associated with rows N, N-1, N-2, N-3 and N-4, as shown at  142 .  
         [0062]    The update logic circuit  106  (FIG. 3) generates each row&#39;s multiplexor select signals to control the compaction of the queue. For each queue row, the update logic circuit counts the number of invalid rows from the bottom of the queue up to and including the instant row. This count saturates at four in the illustrated embodiment since instructions are shifted at most by four rows per cycle.  
         [0063]    [0063]FIG. 7 illustrates the counters and valid bits associated with each queue row, where each counter is a flat vector. That is, for each row, five count bits are generated, only one of which is set at any time. Here, each counter  161  of counter block  160  is a vector counter associated with the corresponding queue row. In any counter, the position of the set bit indicates the number of invalid rows in the queue from that row to the bottom of the queue. Valid indicator storage locations  162  hold valid indicators associated with each queue row are also shown, a 1 here indicating a valid instruction in the corresponding queue row.  
         [0064]    For example, row  0 &#39;s valid indicator is 1, indicating that row  0  in the queue holds a valid instruction. Since there are no invalid instructions below, the bit corresponding to a count of 0 is set, and row  0 &#39;s counter is &lt;00001&gt;.  
         [0065]    Row  1  is empty, so the corresponding valid indicator is 0. Thus, there is one empty instruction up to and including row  1 , so the bit corresponding to a count of 1 is set, yielding a counter value of &lt;00010&gt; for row  1 .  
         [0066]    As can be seen from rows  6  and up, the counters saturate at a value of 4, i.e., &lt;10000&gt;. As indicated by the arrows  164 , each valid instruction is moved toward the bottom of the queue by the number of rows indicated by the corresponding counter.  
         [0067]    Preferably, for each row in the queue, for example, row N, the update logic circuit  106  forms five multiplexor select signals, UPDATE&lt;4:0&gt; from counters  161  associated with rows N through N+4, and drives the select signals across the entire queue datapath at the start of each new cycle.  
         [0068]    [0068]FIG. 8 illustrates a preferred method of generating the update signals from the counters. For row  0 , UPDATE&lt;4:0&gt; signals  134  are formed by combining the counter bits from rows  0  to  4  which lie in the diagonal  170 , respectively. Each bit in the diagonal is logically ANDed with its row&#39;s valid bit to mask the count when the row contains an invalid instruction. Masked bits are indicated with asterisks (*). This has the effect of turning on only one UPDATE signal for each row when receiving a valid instruction, while shutting off all UPDATE signals for rows into which only invalid instructions would be shifted. This saves a large amount of power in the queue because invalid instructions are not moved within the queue. They are either overwritten with valid instructions or with the precharged value of the shift multiplexor  130 .  
         [0069]    Thus, for example, while the diagonal  170  corresponding to row  0  has the value &lt;00111&gt;, the masked UPDATE signals  134  which derive from the diagonal  170  ANDed with valid indicators for rows  0 - 4 , or &lt;11001&gt;, are &lt;00001&gt;. This drives the multiplexor  130  to select the instruction stored in row  0 . Thus the valid instruction in row  0  is not moved.  
         [0070]    The update logic circuit  106  preferably extends beyond the queue to include four extra rows. These rows represent the four incoming instructions  172 , which will enter the queue on the next cycle. Their valid bits  176  are counted and additional counters  174  are provided which affect the queue multiplexor select lines in the same manner as valid bits for instructions within the queue.  
         [0071]    As FIG. 9 illustrates, the update logic circuit  106  has one cycle of latency and consists of two stages, each taking one phase to complete. FIG. 9 illustrates a 5-row slice  200  of the 20-row update datapath. The structure of the datapath is similar to a carry lookahead adder, with the global adders performing the lookahead function.  
         [0072]    Stage 1  201  counts instruction invalid bits up to and including each row and saturates at four. Stage 1 adders are broken into groups of five rows, as shown, to reduce their delay. Local adders  207  in four of the five rows sum the invalid bits in the complementary valid/invalid input pairs  205  within the group up to and including the designated row. A global adder  203  sums all five invalid bits within each group, similar to a lookahead adder. Local and global adder sums  208  are then driven into stage 2  211  through latch  209  and gates  213 .  
         [0073]    Stage 2  211  combines local and global sums  208  from stage 1  201  with Stage 1 global sums  224  from the groups below the instant group to form multiplexor selects  134  for each instruction queue row as described previously. The global sums from the groups below  224  and from the instant group are passed to the group above at  225 .  
         [0074]    The multiplexor select wiring  219  generates the update signals  227  from the diagonals of the counters as described above. The update signals  227  pass through gates  221  when enabled by clock signal  223 , forming Stage 2 outputs  134 . The Stage 2 outputs  134  are driven across the entire instruction queue, and control precharged NMOS pass transistor multiplexors to shift instructions within the queue.  
         [0075]    [0075]FIG. 10 illustrates an update circuit Stage 1 adder  207  of FIG. 9 in detail.  
         [0076]    Clock  233  has two phases, phase A and phase B. Each instruction&#39;s new valid bit is calculated from its issue signal during the clock&#39;s low assertion time, phase B. In phase A, or the high assertion time of clock  233 , the valid bit is shifted into its new row through a precharged NMOS pass multiplexor  231 , and dominoes into the stage 1 adder  207  using the old update multiplexor outputs  134 , via gates  254  and  256 . Note that complementary versions  205 A,  205 B of each row&#39;s valid bit are needed for the pass/shift function. The example of FIG. 10 has each of three rows drive into the stage 1 adder cells.  
         [0077]    The adder  207  is implemented as a 5-bit precharged NMOS shifter array for fast addition, as illustrated by the center cell  258 . The adder  207  adds by shifting a token left one bit for each valid entry. The five bits represent an invalid row count that saturates at four. The illustrated local adder  207  sums valid bits for three rows.  
         [0078]    The stage 1 sum  208  is latched at  209  and driven to stage 2 in phase B. The update logic stage 2 output is turned into multiplexor selects as previously described and is driven across the issue logic datapath during the next phase A, which closes the loop.  
         [0079]    As shown in FIG. 8, each rows&#39; count bits are logically ANDed with that row&#39;s valid bit to mask the count when the row contains an invalid instruction. This has the effect of turning on only one UPDATE signal for each row when receiving a valid instruction, while shutting off all UPDATE signals for rows into which only invalid instructions would be shifted. This saves a large amount of power in the queue because invalid instructions are not moved within the queue: they are either overwritten with valid instructions or with the precharged value of the shift multiplexor.  
         [0080]    However, in a preferred implementation, the two complementary valid bits associated with each instruction within the queue must be shifted properly and not dropped, even when that instruction is invalid, in order to guarantee correct results from the issue logic. These valid bits cannot simply receive the precharge value from the shift multiplexor when the row is invalid because that would destroy the information in those bits, which is needed.  
         [0081]    [0081]FIG. 11 thus illustrates an implementation for generating update signals for shifting the valid indicators during compaction. A modified diagonal  170 A is formed for each row. A second multiplexor  130 A is associated with each queue row, using the same UPDATE&lt;3-0&gt; signals as the first multiplexor  130  (FIG. 8), but using an alternate select bit UPDATE&lt;5&gt; in place of UPDATE&lt;4&gt;. This alternate select UPDATE&lt;5&gt; is generated for each row N using the most significant bit, or count&lt;4&gt; wire, from row N+3, unmasked by the row&#39;s valid indicator.  
         [0082]    This signal UPDATE&lt;5&gt; indicates that a count of 3 was found up to row N+3, and will become a count of 4 at row N+4 if row N+4 is invalid. If row N+4 is valid, the count stays at 3 and this bit will be off and does not conflict with UPDATE&lt;3&gt; which also comes from row N+3. This unmasked bit allows one UPDATE multiplexor select to remain on, thus selecting correct control values for these two bits even for invalid instructions.  
         [0083]    [0083]FIG. 12 illustrates why the unmasked UPDATE&lt;5&gt; bit is taken from row N+3 rather than row N+4. Assume that all rows up to and including row N hold valid instructions and that rows N+1 through N+4 do not hold valid instructions. If the unmasked UPDATE&lt;5&gt; signal were taken from row N+4, the count value would be &lt;10001&gt; 300 , possibly causing improper overwriting of the valid indicator for row N. On the other hand, when the UPDATE&lt;5&gt; signal is taken from row N+3, as in a preferred embodiment, the resulting count  302  is &lt;00001&gt; and there is no conflict.  
         [0084]    While this invention has been particularly shown and described with references to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.