In a system where multiple instruction pipes share access to a common return stack buffer (RSB), coordination is provided to ensure that no instruction pipe gains unfair access to the RSB. Additionally, further coordination control may be provided to ensure that a pipe operates upon valid data notwithstanding communication delays that may be present in a communication path between the pipe and the RSB. In one embodiment, if a system must gain access to the RSB, it determines with reference to prior accesses to the RSB whether immediate access the RSB would exceed a predetermined access rate. If so, it delays its attempt to access the RSB until it re-synchronizes to the access rate. In another embodiment, it delays use of data from the RSB until communication delays are overcome.
|
1. An instruction pipe control method comprising:
reading a call instruction from an instruction pipestage,
determining, with reference to other instructions read previously from the instruction pipestage, whether immediate processing of the call instruction would exceed a predetermined access rate of the instruction pipe to a return-stack buffer and,
stalling processing of the call instruction until sufficient time has expired to synchronize processing of the call instruction with the predetermined access rate.
4. An interface method for an instruction pipe that shares access to a return-stack buffer, comprising:
reading a call instruction from an instruction pipestage,
determining with reference to other call and/or return instructions read previously from the instruction pipestage, whether immediate processing of the call instruction would cause the instruction pipe to exceed the instruction pipe's access allocation to the return-stack buffer,
if so, stalling the call instruction, and after the stalling terminates, storing a return address associated with the call instruction both locally and in a shared resource.
2. The method of
3. The method of
5. The method of
|
The present invention relates to a control mechanism for an instruction pipe in a processor that maintains timing synchronism between the instruction pipe and other elements outside the instruction pipe.
Execution logic in modern processors have begun to incorporate multiple instruction pipes. Each instruction pipe may include sufficient circuitry to execute most program instructions independently of the other pipes. Thus, a processor having multiple instruction pipes may perform nearly perfect parallel execution of program instructions.
It may not be desirable for instruction pipes to operate with complete independence from each other. For certain operations, greater efficiencies may be achieved by having the instruction pipes share access to other logic circuits. By way of example, it may be preferable for multiple instruction pipes to share a single Return Stack Buffer (“RSB”). As is known, an RSB is a buffer that stores forward and return pointers associated with call and return instructions. When a processor executes a call, it pushes an address associated with the call instruction to the RSB, typically the address of an instruction immediately following the call instruction, and begins execution at another program instruction at an address specified in the body of the call instruction. When a processor executes a return instruction, it retrieves an address from the top of the RSB and commences program execution at the retrieved address. Even in a processor having multiple instruction pipes, it may be more efficient to provide a single RSB for all instruction pipes rather than to provide a separate RSB for each of the instruction pipes. Because RSBs typically are not used every clock cycle, sharing the RSB improves utilization and reduces cost over a double-RSB design, for example.
In one implementation, an RSB may be provided within a first instruction pipe. Other instruction pipes in the processor may communicate with the RSB to store addresses therein for call instructions or to retrieve addresses therefrom for return instructions. However, this implementation raises a variety of timing problems.
A first timing problem arises because one RSB must be shared among a variety of instruction pipes. For N instruction pipes in a processor, each instruction pipe may enjoy utilization of the RSB reduced on a pro rata basis (1/Nth of the RSB's total capacity). If an instruction pipe issues read or write requests to the RSB in excess of its pro rata share, the requests may be dropped. This would result in processor failure.
A second timing problem may arise due to round-trip communication latencies between an instruction pipe and the RSB. Requests must propagate from an instruction pipe to an RSB, be acted upon by the RSB and results therefrom must return to the instruction pipe. An instruction pipe that does not account for this round-trip latency during operation may act upon invalid data. Again, this would result in processor failure.
Accordingly, there is a need in the art for a timing control mechanism for use in instruction pipes to conform operation of the instruction pipe to timing limitations that may arise when interfacing the instruction pipe with external elements.
Embodiments of the present invention provide a clock throttling mechanism for a dual instruction pipe processor. In such an embodiment, an external element such as an RSB may be shared among a plurality of instruction pipes. The clock throttling mechanism of the present invention permits the instruction pipe to delay operation of its own elements to synchronize them with the outside element. Delay may be introduced for several reasons: to ensure that the processing of the instruction pipe does not exceed the pipe's access to the shared element, and to ensure that the instruction pipe always acts upon valid data from the shared element, even in the presence of significant round-trip communication latency between the instruction pipe and the shared element.
Although
The logic shown in
Calls and returns may be nested within other calls and returns. That is, a processor may encounter a first call instruction that causes the processor to execute a first segment of code. The processor further may encounter a second call instruction that causes the processor to execute a second segment of code prior to conclusion of the first segment. The layered relationship of the calls and returns is highly efficient for program designers. In this regard, the characteristics of call and return instructions are well known.
According to this embodiment, when the first instruction pipestage 110 receives instruction information relating to a call instruction, it may store the following information relating to the instruction:
The instruction pipe 100 may be provided in communication with an RSB (not shown) over communication lines 130, 140. A first set of communication lines 130 may provide an outbound communication link from the first pipestage 110 to the RSB. The first set of communication lines 130 also may be input to a first register 150.
A second set of communication lines 140 may provide an inbound communication link from the RSB to the second instruction pipestage 120 via a second register 160. Outputs of the first and second register 150, 160 each may be input to a selection multiplexer 170. An output of the selection multiplexer 170 may be input to the second pipestage 120.
In an embodiment, the instruction pipe 100 may include a state machine 180 that controls the clock throttling of the pipestage. The state machine 180 may control a read/write controller 190 that interfaces the instruction pipe 100 to the RSB (not shown) and also controls reading and writing of data to the second pipestage 120. The state machine 180 also may control a clock controller 200. The clock controller 200 may cause an input clock signal CLK to be throttled by disabling propagation of the clock signal under control of the state machine 180. In an embodiment, the clock controller 200 simply may be an AND gate.
Consider operation of the instruction pipe 100 in response to a call instruction. When a call instruction is read from the first instruction pipestage 110, the state machine 180 may decode the instruction type data from the first pipestage 110. Based upon the instruction type, the state machine 180 may cause the read/write controller 190 to issue a write command to the RSB. Address information from the first instruction pipestage 110 may be produced to the RSB over communication lines 130. The address information also may be written to the first register 150.
When a return instruction is read from the first instruction pipestage, again the state machine may decode the instruction based on its instruction type. Again the state machine 180 may control the read/write controller 190. For a return instruction, the read/write controller 190 requests an address to be read from the RSB. The address may be read into the second register 160 over the second communication lines 140.
According to an embodiment, an RSB may operate according to a “read-ahead” policy. The RSB may provide address data from the top of its stack in advance of being requested for the data. Accordingly, after the round-trip communication latency period passes from a previous call or return, the second register 160 should store address data associated with a return instruction at the top of the RSB stack. When the state machine 180 decodes a return instruction, it may cause data from the second register 160 to be read directly into the second instruction pipestage 120 without waiting for a response from the RSB to the read command issued by the read/write controller 190. When the RSB acts upon the read command from the read/write controller 190, the RSB may pop an address from the top of its stack, advances a new address to the top of the stack and pushes it to the second register 160 automatically. This configuration helps to maximize throughput of the instruction pipe.
In an embodiment, the first register 150 stores data associated with a most recent call instruction. According to this embodiment, even if program flow caused a call and a return to occur at a rate that overwhelms the RSB round-trip latency (within less than 5 clock cycles of each other), the return could proceed. The register 150 would store the address of the most recent call instruction. Thus, address information for the return instruction could be stored in the second pipestage. The addition of the first register 150 provides advantages in that it improves throughput of the instruction pipe and leads to a simpler state mechanism 180.
The first instruction pipestage 110 may receive data relating to an instruction to be processed. Instruction data may identify an instruction type. For different instruction types, the instruction data may differ. For a call instruction, in addition to an instruction type identifying the instruction as a “call,” the instruction may include an address of an instruction that represents a return point from the call.
In an embodiment, the state machine 180 controls the multiplexer 170 to cause return data from one of the first or second registers 150, 160 to be stored in the second instruction pipestage 120.
Typically, within an instruction pipe 100, data of a single instruction propagates through one pipestage for each clock cycle. Thus, during operation, data may be read out of the first pipestage 110 at a first clock cycle. According to an embodiment, type information from the instruction may be input to the state machine 180. As described herein, the state machine may distinguish between call instructions, return instructions and all other instructions.
According to an embodiment, the state machine 180 may be adapted to conform the operation of the instruction pipe 100 to timing limitations of the RSB. Typical timing limitations include:
According to an embodiment, the clock controller 200 may generate a local clock signal LCLK. The local clock LCLK may be input to the two pipestages 110, 120 and to every pipestage preceding the first pipestage 110 in the instruction pipe 100. There is no requirement that the local clock LCLK be input to any pipestages following the second pipestage 120. Thus, when the state machine 180 stalls the instruction pipe 100, it need only stall a portion of the instruction pipe 100 that precedes the stalled call or return instruction.
The state diagram 300 of
At initialization, the state machine 180 may start in an idle state 310. As instructions propagate through the instruction pipe, the state machine 180 may classify instructions into three types for the purposes of clock throttling: a call instruction, a return instruction or an “other” instruction (not a call, not a return). The return instruction may cause the state machine to advance to a state 320 and issue the return. The call instruction may cause the state machine to advance to another state 330 and issue the call. Any other instruction may be processed according to normal procedures; the state machine 180 may remain at the idle state 310 for the purposes of clock throttling.
From state 320, the state machine 180 may classify an instruction as a return, a call or other. If a second return instruction occurs (back-to-back returns), the state machine 180 may begin a multi-clock stall, represented by states 340-370. Using the example of a 5 cycle round-trip communication delay, the clock stall would occur for 5 cycles. Again, other embodiments may be appropriate for different round-trip communication latencies. From state 320, the state machine 180 may progress in sequence through each of the stall states 340-370 regardless of the instructions that follow the second return. At the conclusion of the stall at state 370, the state machine returns to state 320 and issues the second of the back-to-back returns. Thereafter, the state machine determines the type of the instruction following the second return and processes this new instruction based on its instruction type.
From state 320, a next instruction may be a call instruction (a return, followed immediately by a call). In this case, the state machine 180 may advance to state 380 and stall the clock. Thereafter, the state machine may advance to state 390 and issue the call instruction. This single-cycle stall satisfies the timing limitation that requires sequential communications with the RSB to be separated by at least two cycles. In this case, although the call instruction arrives at the state machine 180 immediately after the return that preceded it, the call instruction will be delayed by a cycle to ensure that the communications with the RSB satisfy the 2 cycle timing limitation.
From state 390, the state machine 180 examines a next instruction from the first pipestage 110. Again, the instruction may be classified as a call, return or other. If the state machine 180 determines that the new instruction is a return, the state machine 180 may advance to state 360 and stall the instruction pipe. This response is appropriate because the instruction sequence (return-call-return) implicates both timing limitations. Without clock throttling, the instruction sequence would violate not only the 2 cycle limitation governing sequential communication with the RSB but also the 5 cycle limitation governing round-trip communications with the RSB. By advancing to state 360, the state machine will satisfy both timing limitations. It will wait another three cycles (states 360, 370, 320) before issuing the return instruction.
From state 390 the state machine may determine that the next instruction is a call instruction. In this case, the state machine may advance to state 400 and stall the clock for a single cycle. Thereafter, the state machine may advance to state 330 and issue the call instruction.
From state 390, the state machine may determine that the next instruction is neither a call nor a return. In this case, the state machine 180 may advance to state 410. The state machine 180 may permit the instruction to proceed. At state 410, the state machine processes a next instruction. For a call instruction, no timing requirements prevent the instruction from being issued, the state machine 180 may advance to state 330 and issue the call instruction. For an “other” instruction, the state machine may advance to the idle state 310. Execution of the “other” instruction will cause the state machine to be removed from the return issued at state 320 by the minimum five cycles; therefore, the state machine may return to the idle state.
If the state machine detects a return at state 410, the state machine may advance to state 370. The new instruction is part of a sequence, return-stall-call-other-return. Advancing from state 410 to state 370 is appropriate to ensure that the 5 cycle round-trip latency is maintained. Thus, the second return will be stalled for a clock cycle. Thereafter, the state machine may advance to state 320 and issue the return.
As noted, when the state machine is at the idle state 310 and detects a call instruction, it may advance to state 330 and issue the call. Thereafter, the state machine may classify a new instruction following the call. If the new instruction is itself a call instruction (back-to-back calls), the state machine may advance to state 400 and stall the new instruction. After the single-cycle stall, the state machine may return to state 330 and issue the second call.
If, at state 330, a next instruction is a return, the state machine may advance to state 370 and stall the instruction. Following state 370, the state machine may advance to state 320 and issue the return instruction.
From state 330, any instruction classified at “other” may cause the state machine to return to the idle state. The instruction may proceed.
From state 320, if the state machine classifies a new instruction as other, it may permit the new instruction to proceed (state 420). From state 420, a return instruction may cause the state machine to advance to state 350, an appropriate state in the multi-cycle stall that must be maintained for successive return instructions. From state 420, a call instruction may cause the state machine to advance to state 390. The call may be issued. From state 420, any other instruction may cause the state machine to advance to a state 430; the other instruction is permitted to proceed.
From state 430, a call instruction may cause the state machine to advance to state 330 and any other instruction may cause the state machine to advance to a state 440. No timing limitation prevents either the call instruction or other instruction from being processed. A return instruction, however, may cause the state machine to advance from state 430 to state 360. A remainder of the multi-cycle delay for successive returns must be completed prior to issuing the second return at state 320.
From state 440, a return instruction may cause the state machine 180 to advance to state 370 for a single-cycle stall. A call instruction, however, may be issued; the state machine, therefore, may advance to state 330. Any other instruction also may be issued; the state machine 180 thereafter returns to the idle state 310.
The principles of the present invention find application with other embodiments of instruction pipes such as those that independently process multiple code streams. In common operating systems, these multiple streams are called “threads”.
In this embodiment, as instructions propagate through the instruction pipe 100, the instructions carry data identifying the stream to which the instruction belongs. Of the pair of registers 150, 210 connected to the first communication path 130, a first register 150 may store call addresses associated with one stream and a second register 210 may store similar addresses associated with another stream. So, too, with the registers 140, 220 connected to the second communication path 140. A first register 140 may store call addresses associated with the first stream and a second register 220 may store similar addresses associated with the second stream.
A multi-stream instruction pipe may operate under the same timing restraints as a “uni-stream” instruction pipe. Accordingly, operation of the state machine 180 need not change from the embodiments described above. However, as the state machine 180 controls the multiplexer 170 to read data from one of the registers 150-160, 210-220 to the second instruction pipestage 120, it performs its selection based not only on the timing of the instructions but also the stream from which the instruction originated.
In the embodiment shown in
According to an embodiment, an RSB 530 may communicate with multiple stages of a single instruction pipe. For example, the RSB 530 accepts two communication links 550, 560 from the second instruction pipe 520. In this embodiment, each communication link 550, 560 may be treated by the RSB 530 as a different entity. Thus, each portion of an instruction pipe may have access to the RSB 530 on a pro rata basis based on the number of communication links into the RSB 530 rather than just an absolute number of instruction pipes in the processor.
Although
Several embodiments of the present invention are specifically illustrated and described herein. However, it will be appreciated that modifications and variations of the present invention are covered by the above teachings and within the purview of the appended claims without departing from the spirit and intended scope of the invention.
Patent | Priority | Assignee | Title |
7174444, | Mar 31 2003 | Intel Corporation | Preventing a read of a next sequential chunk in branch prediction of a subject chunk |
7464310, | Sep 30 2002 | AVAGO TECHNOLOGIES GENERAL IP SINGAPORE PTE LTD | Programmable state machine of an integrated circuit |
9037152, | Nov 12 2005 | Small footprint real-time operating system for reactive systems |
Patent | Priority | Assignee | Title |
4394729, | Oct 16 1980 | NCR Corporation | Jump return stack |
4399507, | Jun 30 1981 | IBM Corporation | Instruction address stack in the data memory of an instruction-pipelined processor |
5222220, | Nov 16 1989 | SIEMENS VDO AUTOMOTIVE ELECTRONICS CORPORATION | Microprocessor stack built-in guards |
5515519, | Mar 19 1993 | Renesas Electronics Corporation | Data processor and method utilizing coded no-operation instructions |
5604877, | Jan 04 1994 | Intel Corporation | Method and apparatus for resolving return from subroutine instructions in a computer processor |
5968169, | Jun 07 1995 | Advanced Micro Devices, Inc. | Superscalar microprocessor stack structure for judging validity of predicted subroutine return addresses |
6021489, | Jun 30 1997 | Intel Corporation | Apparatus and method for sharing a branch prediction unit in a microprocessor implementing a two instruction set architecture |
6151671, | Feb 20 1998 | Intel Corporation | System and method of maintaining and utilizing multiple return stack buffers |
6170998, | May 11 1995 | Godo Kaisha IP Bridge 1 | Processor which returns from a subroutine at high speed and a program translating apparatus which generates machine programs that makes a high-speed return from a subroutine |
6247134, | Mar 31 1999 | Synopsys, Inc | Method and system for pipe stage gating within an operating pipelined circuit for power savings |
Executed on | Assignor | Assignee | Conveyance | Frame | Reel | Doc |
Jun 19 2000 | DOUGLAS, JONATHAN P | Intel Corporation | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 010916 | /0996 | |
Jun 21 2000 | Intel Corporation | (assignment on the face of the patent) | / |
Date | Maintenance Fee Events |
May 02 2005 | ASPN: Payor Number Assigned. |
Dec 18 2008 | M1551: Payment of Maintenance Fee, 4th Year, Large Entity. |
Nov 21 2012 | M1552: Payment of Maintenance Fee, 8th Year, Large Entity. |
Jan 27 2017 | REM: Maintenance Fee Reminder Mailed. |
Jun 21 2017 | EXP: Patent Expired for Failure to Pay Maintenance Fees. |
Date | Maintenance Schedule |
Jun 21 2008 | 4 years fee payment window open |
Dec 21 2008 | 6 months grace period start (w surcharge) |
Jun 21 2009 | patent expiry (for year 4) |
Jun 21 2011 | 2 years to revive unintentionally abandoned end. (for year 4) |
Jun 21 2012 | 8 years fee payment window open |
Dec 21 2012 | 6 months grace period start (w surcharge) |
Jun 21 2013 | patent expiry (for year 8) |
Jun 21 2015 | 2 years to revive unintentionally abandoned end. (for year 8) |
Jun 21 2016 | 12 years fee payment window open |
Dec 21 2016 | 6 months grace period start (w surcharge) |
Jun 21 2017 | patent expiry (for year 12) |
Jun 21 2019 | 2 years to revive unintentionally abandoned end. (for year 12) |