WO1991013402A1 - Antememoire de prediction de branchement a deux niveaux - Google Patents

Antememoire de prediction de branchement a deux niveaux Download PDF

Info

Publication number
WO1991013402A1
WO1991013402A1 PCT/US1991/000826 US9100826W WO9113402A1 WO 1991013402 A1 WO1991013402 A1 WO 1991013402A1 US 9100826 W US9100826 W US 9100826W WO 9113402 A1 WO9113402 A1 WO 9113402A1
Authority
WO
WIPO (PCT)
Prior art keywords
branch
bpc
instruction
cache
address
Prior art date
Application number
PCT/US1991/000826
Other languages
English (en)
Inventor
David R. Stiles
John G. Favor
Korbin S. Van Dyke
Original Assignee
Nexgen Microsystems
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nexgen Microsystems filed Critical Nexgen Microsystems
Publication of WO1991013402A1 publication Critical patent/WO1991013402A1/fr

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3804Instruction prefetching for branches, e.g. hedging, branch folding
    • G06F9/3806Instruction prefetching for branches, e.g. hedging, branch folding using address prediction, e.g. return stack, branch history buffer
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3842Speculative instruction execution
    • G06F9/3848Speculative instruction execution using hybrid branch prediction, e.g. selection between prediction techniques

Definitions

  • the present invention relates generally to cache structures in computer systems, and more specifically to cache structures that aid in predicting conditional and unconditional branches.
  • CISC architecture requires the ability to quickly calculate or otherwise determine the target address of the branch, to quickly resolve the proper path of subsequent instruction processing in the case of conditional branches, and in all cases to then quickly restart the fetching of instructions at the new address. To the extent that these operations cannot be performed quickly, pipeline processing delays result. Relatively long pipelines, or at least large processing latencies, typical in a high performance CISC implementation, make these operations difficult to consistently speed up.
  • Past high performance CISC designs have used forms of cache structures to hold various combinations of information to be used in predicting one or more of the three types of information mentioned above.
  • An aggressive all-encompassing design could be envisioned in which a fully associative cache of a few thousand entries was utilized. Each entry would hold a record of the actual target address associated with the last occurrence of the branch; a copy of the first several instructions at this target address; and in the case of conditional branches a history record of the direction taken by each of the past several branch occurrences.
  • the instruction In parallel with the fetching and/or decoding of a branch instruction, the instruction would also be looked up in the branch prediction cache. Generally, this look-up would be based on the fetch address of the branch or a closely related address. As the instruction is being decoded the branch history information would be used to predict the direction of conditional branches; this would determine whether subsequent instruction processing should continue with the instructions sequentially following the branch, or with the sequence of instructions starting at the target address.
  • a branch prediction cache design incorporated into a high performance CPU implementation would be of a smaller scope. It would not attempt dynamic prediction of all three of the following: target address, target instructions, and conditional branch direction. It would also be of a smaller scale. Prediction success rates and degree of branch processing acceleration are necessarily traded-off to reduce the cost to an acceptable level.
  • the present invention is an improved branch prediction cache (BPC) scheme that utilizes a hybrid cache structure to achieve a more cost-effective trade-off between hardware cost and performance improvement.
  • the invention combines most of the branch processing acceleration of a full scope prediction cache design with the lower cost of simpler and/or smaller prediction cache structures.
  • the invention provides two levels of branch information caching.
  • the first level BPC is a shallow (36 entries) but wide (entries are approximately 32 bytes each) structure which caches full prediction information for a limited number of branch instructions.
  • the second level BPC is a deep (256 entries) but narrow (entries are approximately 2 bytes each) structure which caches only partial prediction information, but does so for a much larger number of branch instructions. As each branch instruction is fetched and decoded, its address is used to perform parallel look-ups in the two branch prediction caches.
  • the first level BPC comprises entries containing a relatively large amount of prediction information.
  • each first level cache entry contains the target address from when the branch instruction was last executed; up to the first 24 bytes of sequential instruction stream starting at the target address; and two history bits recording the direction taken during the most recent two executions of the branch instruction.
  • the first level BPC preferably uses an associative access method.
  • a cache tag for each entry namely the instruction address of the branch associated with the entry, is stored in a content addressable memory (CAM) array.
  • a first level cache look-up is performed by accessing this array using the above next instruction address, and then reading out the prediction information from any, at most one, entry for which there was a tag match.
  • Full associativity maximizes the prediction cache's hit rate for a given cache size (number of entries).
  • the second level BPC unlike the first level BPC, comprises entries containing only a limited amount of prediction information. This is offset by the much larger number of entries, compared to the first level cache, which are capable of implementation with a given amount of hardware circuitry.
  • the size of a second level cache entry is dramatically reduced by not caching target instructions, while the extent to which branch processing can be accelerated is reduced only moderately. This especially makes sense given that the second level cache serves as a backup to the first level cache. With this much larger size, even given the direct-mapped organization, the second level cache provides an effective backup to the first level cache.
  • a second level cache entry holds only a partial target address and one history bit.
  • the predicted direction of a conditional branch is based simply on the direction last taken by that branch.
  • the branch target address is assumed to be within a subset of the instruction address space also containing the branch instruction.
  • the full predicted target address is a concatenation of the upper address bits from the branch instruction's address with the lower 16 bits from the cache entry.
  • the second level BPC uses a direct-mapped access method, versus a set or fully associative method. This is acceptable due to the relatively large number of second level cache entries. Even more significantly, it is then possible to discard the tag and tag storage associated with each cache entry. In essence, when a cache look-up accesses a selected entry, it is simply assumed that the tag and look-up address match.
  • Fig. 1 is a block diagram of a computer system incorporating the present invention
  • Fig. 2 is an overall block diagram of the branch prediction cache (BPC) and its immediate environment
  • Fig. 3 is a block diagram of the first level BPC
  • Figs. 4-8 are logic schematics of the various memory arrays and logic within the first level BPC.
  • Fig. 9 is a logic schematic of the second level BPC.
  • Fig. 1 is a block diagram of a CPU 10 incorporating the present invention.
  • the CPU sometimes referred to as the F86, is designed to execute an instruction set (macro-instructions) compatible with that of the Intel 80386, as described in the Intel 80386 Programmer's Reference Manual published by Intel Corporation, Santa Clara, California, 1986.
  • Each block in the diagram corresponds generally to a separate integrated circuit chip or group of chips in a current embodiment.
  • the CPU communicates with external devices such as memory controllers, I/O devices, and possibly other CPU's via a system bus 11. References below to functional units will normally be understood to mean elements within CPU 10, not such external devices.
  • An Instruction Decoder (DEC) 12 performs instruction fetch, instruction decode, and pipeline control. DEC 12 optionally interleaves instruction prefetch of up to three simultaneous instruction streams. DEC 12 contains a two-level Branch Prediction Cache (BPC) 13.
  • the BPC includes an integrated structure which contains dynamic branch history data, a physical branch target address, and a branch target buffer for each cache entry. As branch instructions are decoded, the
  • branches are executed in a single cycle and do not cause pipeline bubbles.
  • a macro-instruction is selected from one of the three instruction buffers or a branch target buffer in the BPC.
  • the macro-instruction is decoded, assembled into an internal 96-bit decoded instruction word, referred to as a pseudo-op (p-op) or sometimes as an instruction or operation, and dispatched to the various functional units.
  • Instruction decode generally proceeds at a single cycle rate.
  • Each p-op issued by DEC 12 is given a tag which uniquely identifies each p-op currently outstanding in the machine. Tags are issued in increasing order, allowing easy determination of relative age of any two outstanding tags. Bus transactions between chips include the tag of the originating p-op.
  • Functional units pair up p-op, addresses, and operands with these tags.
  • DEC 12 is also responsible for tracking the status of outstanding p-op, pipeline control, and for invoking exception processing when needed.
  • An address Preparation Unit (AP) 15 calculates effective addresses, performs segment relocation, and implements a demand paged memory management system. It contains a translation lookaside buffer (TLB).
  • TLB translation lookaside buffer
  • An Integer Execution Unit (IEU) 17 performs single cycle execution of most integer instructions. It contains an 8 x 32 multiplier and accumulator array, as well as microcode for multiply and divide instructions.
  • the pipeline control architecture allows the IEU to perform parallel and/or out-of-order execution of integer instructions.
  • a Numerics Processor (NP) 20 may optionally be included in the CPU. It is a high performance implementation of the IEEE floating point standard. The NP is integrated into the pipeline and does not incur any special overhead for the transfer of instructions and operands. Integer (IEU) and floating point (NP) instructions execute concurrently.
  • a Memory and Cache Controller (MCC) 25 is responsible for controlling the instruction and data caches and implements the cache coherency protocol.
  • the MCC controls the interface to the system bus 11, supporting high speed single and block mode transfers between cache and memory.
  • the MCC also contains write reservation tables for integer, floating point, and system writes, and includes read after write short circuit paths.
  • An instruction cache subsystem includes a tag RAM chip (ITag) 27 and cache RAM chips (ICache) 30. Each entry in ITag 27 contains the address tag, a Valid bit, and an Attention bit for a corresponding line in ICache 30. The Attention bit indicates that the DEC chip may also have data from this line cached in the BPC.
  • ITag 27 also includes a set of instruction stream address registers 31, each of which contains a fetch address associated with a respective one of three possibly outstanding streams.
  • a data cache subsystem includes a tag RAM chip (DTag) 32 and cache RAM chips (ICache) 35.
  • DTag 32 contains the address tag and line state bits for each line in DCache 35.
  • the possible line states are Absent, Shared Read, Owned Clean, and Owned Dirty, supporting a writeback multiprocessor cache coherency protocol (modified write once).
  • the tag RAM is dual ported to allow both CPU and bus snooping cache lookups in a single cycle.
  • a Data Cache Interface (DCI) chip 37 interfaces DCache 35 to system bus 11.
  • DCI Data Cache Interface
  • Each functional unit chip is packaged in a custom ceramic PGA which contains power and ground planes and associated decoupling capacitors. Roughly 25% of the pins are dedicated to power and ground. For 0.8 micron to 1.2 micron processes, I/O delays are comparable to on-chip critical paths. Inter-chip I/O is incorporated into the pipeline, and thus does not add to the machine cycle time.
  • ICache 30 and DCache 35 use conventional static RAMs.
  • Communications between the various functional units are carried out over a number of internal buses. These include: a 64-bit IFETCH_DATA bus 50 for instruction fetches; a 104-bit p-op bus 52 for communicating issued p-ops to the AP, the IEU, the MCC, and the NP; a 5-bit tag status bus 53 for communicating outstanding p-op information to the AP, the IEU, the MCC and the NP; a 52-bit physical address bus (PAdrBus) 55 for communicating physical addresses; a 64-bit (32 bits in each direction) data cache bus (DIOBus) 57 for data cache transfers; a 32-bit data exchange bus (DXBus) 58 for inter-chip exchange; a 64-bit bus for cache/memory updates; and a number of termination buses, namely an AP termination bus 60, an IEU termination bus 62, an NP termination bus 63, and an MCC termination bus 65 from the functional units to DEC 12. Some of these buses are full width and some half
  • Pipeline control of the processor is distributed across the functional units mentioned above. No centralized scheduling or score boarding of the pipeline is performed. DEC 12 does observe certain overall resource constraints in the architecture and will occasionally hold off on issuing a p-op which would violate resource limitations. Each functional unit is responsible for scheduling its own internal operations. Interlock checking is performed at a local level.
  • DEC 12 issues decoded instructions (p-ops) and the functional units process addresses and operands without regard for the consequences of exceptions detected by other functional units.
  • p-ops decoded instructions
  • each p-op is assigned a tag by DEC 12 when it is issued, and the DEC uses this tag to track the p-op.
  • DEC 12 is responsible for determining when execution has proceeded beyond the point of an exception. Using techniques described below, the DEC will restore the state of the machine to the point immediately preceding (fault exceptions) or following (trap exceptions) the p-op causing the exception. As noted above, each functional unit has a termination bus back to DEC 12. Signals on these buses indicate (by tag) when p-ops have been completed and what exceptions (if any) were detected by that unit. The DEC uses this information to keep track of what p-ops are outstanding in the machine, to track resource constraints, and to decide when exception processing must be initiated.
  • DEC 12 In response to abnormal terminations, DEC 12 will back up the state of the machine to the point of the exception, and begin issuing either a different instruction stream or a sequence of micro-instructions to invoke an exception handler.
  • the processor uses one or more of five general mechanisms to permit the machine to be backed up to a particular state as part of DEC'S response to abnormal terminations. These are issuing abort cycles, reassigning registers, using write reservation tables, using history stacks, and functional unit serialization. Abort cycles are issued by DEC 12 when instructions which have been issued by the DEC must be flushed from the machine. During an abort cycle all functional units are provided a tag which identifies the boundary between instructions which should be allowed to complete and instructions which must be purged from the machine.
  • Register reassignment is used to restore the state of the general register files and the segment register file, flushing any modifications made for instructions which must be aborted.
  • the functional units have more registers physically available than the instruction set specifies.
  • DEC 12 maintains a set of pointers which map the programmer visible (or virtual) registers onto the physical registers. In assembling decoded instructions, the DEC will substitute the appropriate physical register numbers into the register specification fields. When a virtual register is to be modified, the DEC will first allocate a new physical register, modify the pointer set, and use the allocated register number as a destination register. Following execution of the instruction, the old physical register still contains the original value of the virtual register, while the new physical register contains the modified value of the virtual register. To back out of the register modification, the DEC must restore the pointer set to its value prior to issue of the instruction.
  • the DEC maintains a history stack of pointer values, as is described below.
  • Write reservation tables are used in MCC 25 to queue up data writes until it is known that the writes will not have to be aborted.
  • the MCC receives addresses and operands on the internal data buses, matches them up by tag, and performs the irreversible write when it is safe to do so.
  • History stacks are used for saving and restoring miscellaneous machine state, such as the register reassignment pointers, flags register, and program counter.
  • the distributed pipeline control scheme combined with the ability to back out of any state modification, allows a number of performance optimizations.
  • Each functional unit may receive all p-ops, but deals only with p-ops which actually require processing in that unit. This is in contrast to conventional pipelines in which instructions flow through all stages in the pipeline, whether the stage has useful work to do or not.
  • each unit performs an operation as soon as all input operands are available. P-ops that are not ready for immediate execution are stored in that unit's p-op queue. When complete, the result is passed to the next stage for further processing, and the next operation is examined. A stage only stops execution when it has nothing available for execution.
  • This behavior allows out-of-order execution between functional units.
  • the AP will not be able to compute the memory address.
  • the IEU is able to provide the data and does so immediately, after which it continues on to the next instruction.
  • the AP's interlock does not need to create a pipeline bubble in any other pipeline stage. Later on, the IEU may be held up performing a multiply, or waiting for a memory operand. At this time, the AP has a chance to catch-up with the IEU.
  • the functional unit makes a local decision, completely unaware that it might cause instructions to be completed out-of-order.
  • the pipeline control mechanisms guarantee that any modifications made by an instruction executed out-of-order can be purged.
  • the functional unit makes no special checks.
  • IEU 17 provides an example of internal out of order execution. The IEU examines the instruction at the head of it's instruction queue to see if it is ready to execute. If a data interlock prevents immediate execution, the IEU will examine the next younger instruction to see if it is ready to execute. This process can continue until an instruction is found which can execute. The IEU will only pay a data interlock penalty if there is no instruction available which is ready to execute. Note that even if the IEU pays an interlock penalty, that doesn't mean that the processor as a whole loses a cycle.
  • a special case of a functional unit choosing to execute instructions out-of-order is parallel execution of instructions within the functional unit.
  • this concept is applied to instructions which take multiple cycles.
  • Parallel execution of other single cycle instructions allows the multi-cycle instruction to have an effective throughput of one cycle.
  • DCache misses would normally stop the pipeline for a full cache miss penalty.
  • the cache miss penalty is reduced.
  • misses in the AP chip's TLB are different from the others in that the number of penalty cycles is usually fairly high, making it difficult to fully overlap them with useful work.
  • branch instruction The instruction causing a change in control flow is called a branch instruction, and the address of this instruction is called the branch instruction address.
  • the branch instruction may include within it the address of the instruction to be branched to, which is called the branch target instruction.
  • the address of the branch target instruction is the target address. Alternately, a formula for calculating the target address may be included in the branch instruction.
  • the branch instruction may be a conditional branch. A conditional branch causes a jump to a branch target instruction only if a test set forth in the branch instruction is met. If the condition is not met, then the branch is not taken and sequential execution continues.
  • Fig. 2 is a block diagram of BPC 13 according to the present invention.
  • the BPC is a two-level structure including a first level BPC 152 and a second level BPC 155.
  • BPC 13 is located within the multi-function DEC chip and communicates with an instruction decoder (ID) 160, instruction decode control circuitry (IDC) 162, and instruction fetch control circuitry (IFC) 165.
  • ID instruction decoder
  • IDC instruction decode control circuitry
  • IFC instruction fetch control circuitry
  • the primary function of IDC 162 is to control decoding of instructions, and in particular to ensure the proper handling of branches based on information from the BPC.
  • IDC 162 also determines where instructions can be fetched from and controls IFC 165 accordingly.
  • first level BPC 152 is a shallow but wide structure which caches full prediction information for a limited number of branch instructions.
  • first level BPC 152 contains 36 entries, each including 4 bytes for branch address tag with a valid bit, 4 bytes for target address, two history bits, and 24 target instruction bytes with 3 target instruction valid (TIV) bits.
  • Second level BPC 155 is a deep but narrow structure which caches only partial prediction information but for a much larger number of branch instructions. Second level BPC 155 contains 256 entries, each containing two bytes of partial target address information and one history bit.
  • the instruction's decode PC is used to perform parallel lookups in the first and second level BPC's. (Since the incoming instructions have not been decoded at this point, non-branch instructions are also checked).
  • the target instruction bytes are communicated to instruction decoder 160, the branch history bits are communicated to IDC 162, and the target address is communicated to IFC 165.
  • second level BPC 155 is always assumed to hit. Therefore, second level BPC 155 communicates the branch history bit to IDC 162 and the partial target address to IFC 165 on every access.
  • IFC 165 Based on this target address information, IFC 165 sends a target address to AP and a fetch address to ITAG 27 on PAdrBus 55. In the event of a hit on the first level BPC, the fetch address is offset from the target address by the number of target instruction bytes cached for that branch. In the event of a miss, the fetch address and the target address are the same.
  • prediction information for a branch i.e., a valid cache entry associated with the instruction
  • a branch is encountered at least once and continues to exist in the cache only until replaced by a set of prediction information for another branch.
  • the benefit of these cache schemes primarily exists on a statistical basis.
  • the cache does not contain an entry for a branch instruction about to be processed, the pipeline becomes exposed to branch processing delays.
  • the cache must provide enough prediction information to enable suitable acceleration of branch processing, and it must provide it for a high enough percentage of the branch instructions processed by the CPU.
  • These two levels of cache cooperate to provide an overall performance benefit approximating that of a single cache structure with the prediction information width of the first level cache and a number of cache entries equal to the second level cache.
  • the amount of hardware circuitry required to implement the two-level hybrid cache structure is much less than for the single "deep and wide" cache structure.
  • Fig. 3 is a block diagram showing the various elements in first level BPC 152.
  • the first level BPC comprises entries containing a relatively large amount of prediction information.
  • this cache structure contains a full scope of information to enable single branch execution, including: the branch direction if the branch is conditional, the branch target address, and cached target instruction data. More specifically, each first level cache line contains the target address from when the branch instruction was last executed; up to the first 24 bytes of sequential instruction stream starting at the target address; and two history bits recording the direction taken during the past executions of the branch instruction.
  • first level BPC 152 includes a program counter cache (PCC) preferably implemented as a program counter content addressable memory (PcCAM) 170 with associated valid bit (Vbit) memory 172.
  • PCC program counter cache
  • PcCAM program counter content addressable memory
  • the target address memory is a branch address cache/target CAM (BAC/TgtCAM) 175.
  • the history of past branch directions is stored in a branch history cache (BHC) 177.
  • a branch target cache (BTC) 180 contains the target instruction data, with an associated target instruction valid (TIV) memory 182.
  • Each of the memory arrays contains 36 lines and is directly accessed via word select inputs (as opposed to encoded word address inputs). Some of these sets of word selects for reading and writing each line are generated by address selection logic 185 with an associated multiplexer network 188. Other word selects are generated by the match outputs of PcCAM 170.
  • a least Recently Used (LRU) logic block 181 has logic which performs the function of selecting a BPC line to be overwritten by a new block of instruction data.
  • LRU least Recently Used
  • this first level cache Given the relatively limited size of this first level cache, it is designed to support accesses in a highly associative manner versus a direct-mapped or two/four-way set associative manner. This look-up, to check whether an entry currently exists in the cache for a branch about to be processed, is typically performed using the address of the branch instruction. For some pipeline designs, a closely related address may instead need to be used.
  • the term fully associative means that bits of the input address are compared with potentially matching bits of all the entries in cache. A hit is defined to have occurred when the input address matches at least one stored address.
  • the term direct mapped means that some number of bits of the input address are used to index into the memory, and the remaining bits are stored in the memory. When the entry is read out of the memory, the stored address bits are compared with the corresponding bits in the input address, and a hit is defined to have occurred when the two agree. This entails a single comparison. In the event that two branch instructions index to the same entry (different PC's with the same set of index bits), a direct mapped cache can only accommodate one, even if there are other empty entries.
  • the term two-way set associative refers to a structure with two memory banks, so that two entries are read out for a given index and two comparisons are performed. This concept can be expanded to more than two-way set associative.
  • the address of the first byte of the next instruction to be decoded is used for the look-up in the first level BPC, and is done in parallel with instruction fetch completion and start of instruction decode.
  • This look-up is also done in a fully associative manner which provides substantial performance improvement relative to direct-mapped or two/four-way set- associative access methods.
  • a cache tag for each entry namely the instruction address of the branch associated with the entry, is stored in PcCAM 170.
  • a first level cache look-up is performed by accessing PcCAM 170 using the above next instruction address, and then reading out the prediction information from any, but at most one, entry for which there was a tag match.
  • Fig. 4 is a logic schematic of PcCAM 170 and associated Vbit memory 172.
  • PcCAM 170 is a RAM/CAM array holding the instruction address of the branch for which each cache entry is storing prediction information.
  • Each line in PcCAM 170 includes a 32-bit RAM word 190 and a CAM comparator 192.
  • Each line in Vbit memory 172 holds a valid bit indicating the overall validity of the line, and is implemented as a latch 195.
  • the CAM address input may be the address of the first byte of the next instruction to be decoded, and is compared with the contents of RAM word 190. In the event of equality, the CamMatch2 line for that entry is asserted, as qualified by a true output from Vbit latch 195.
  • Fig. 5 is a logic schematic of BAC TgtCAM 175.
  • the BAC/TgtCAM is a mixed
  • Each line includes a 39- bit RAM word 200, a 4-bit CAM comparator 202, a pair of 7-bit CAM comparators 203 and 205, and a 16-bit CAM comparator 207.
  • 39 bits 32 bits are the target address of the branch.
  • the other 7 bits are additional target address information, as will be described below.
  • the full 32-bit target address is made available for readout if the particular BAC/TgtCAM line is selected, as determined by CamMatch2 from PcCAM 170 via multiplexer 188.
  • CAM segments of BAC/TgtCAM are used to detect memory stores by instructions currently being processed within the CPU pipeline. Since these instructions possibly modify target instruction bytes, it is necessary to invalidate the BPC entry in order to maintain proper coherency between target instruction bytes in the BTC and their image in main memory (actually in the ICache).
  • ICache RAM chip 30 contains 64 kilobytes, organized as 32-byte lines, and is thus characterized by an 11-bit address (the five low order bits may be ignored).
  • the ITAG RAM contains the high order 16 bits.
  • the 27-bit address ChkAddr of a line being written in the ICache is communicated to the CamAddrl input of the BAC/TgtCAM.
  • the BTC entry could straddle a line boundary, and so may be characterized by two line addresses.
  • two target addresses are examples of two target addresses.
  • the high order 16 bits need not be checked for an external write, because the BPC is constrained to have only entries which are in the Icache for external writes. All variations of the upper 16 bits of instruction addresses which have the same 11 bits below must share the same Icache line so only 11 bits of each address need to be checked.
  • Two 11-bit addresses in the BPC are checked, covering the possibly that two ICache lines could be spanned by a 24-byte BTC line. By requiring that the two lines be in the same 4-kilobyte page (i.e., that the BTC line not straddle a page boundary), the 4 most significant bits of the second 11-bit address will be the same as for the first 11 bit address, and can be ignored.
  • the 7 bits of the second address are added to the same physical RAM word containing the 32-bit BAC address.
  • CAM comparators 203 and 205 compare the two 7-bit fields of the RAM line with the corresponding 7 bits of ChkAddr on the CAMAddrl input while CAM comparator 202 compares the 4-bit field in the RAM line with the corresponding 4 bits of ChkAddr. A match is defined to have occurred on a particular line if the 4 bits of the 27-bit
  • ChkAddr match the 4 bits of the RAM line (as detected by comparator 202), the 7 bits of the ChkAddr match either 7-bit field of the RAM line (as detected by comparators 203 and 205) and the external write line is enabled or (for internal writes) the 16-bit field of ChkAddr matches the 16-bit field of the RAM entry (as detected by comparator 207). If a match occurs (more than one can occur since more than one BTC entry can be affected by a write in a given line), the corresponding BPC entries are invalidated.
  • the 32-bit branch target address can be read out through a driver 204 on data bus BACData.
  • Fig. 6 is a logic schematic of BTC 180.
  • Each BTC line comprises a 192-bit RAM word, implemented as three 64-bit RAM words (double-words) 220a, 220b, and 220c.
  • the BTC holds the first few instructions as the target address of the branch (in this case, up to the first 24 bytes of target instructions).
  • the BTC cache caches the target instruction stream image as found in main memory.
  • the first one or several target instructions could be cached in an alternate, possibly decoded, representation that may be more suitable for other CPU implementations.
  • Each 64-bit output is provided through drivers 218a, 218b, and 218c, with each RAM word output forming a 64 bit portion of 192-bit Data output bus.
  • the read select signal for a particular one of the 36 lines is provided through an AND gate 216.
  • the write select signals are provided through a series of AND gates 210, 212, and 214.
  • Fig. 7 is a logic schematic of TIV 182 and BHC 177.
  • Each line of TIV 182 includes latches 225a, 225b, and 225c, each holding a valid bit corresponding to eight of the 24 instruction bytes within the BTC line.
  • Each line of BHC 177 is a 2-bit RAM 227.
  • Fig. 8 is a logic schematic of address select circuitry 185.
  • Four pairs of latches designated IL1, FL1 through IL4, FL4 are provided.
  • the first latch (IL) in each pair stores a pointer to a line in the branch prediction cache.
  • Four sets are provided to track multiple branches.
  • (FL) in each pair is provided to point to a pre-fetch instruction queue which may be associated with each branch.
  • One input to each of the IL latches is provided through multiplexers 240, 242, 244, and 246 from the PcCAM match line 248.
  • Inputs to the FL latches are provided through a 36-bit input bus 252.
  • the outputs of both the IL and the FL latches are provided to a multiplexing network 256.
  • the circuit of Fig. 8 provides a flexible approach to producing a number of control signal outputs from the multiplexing network 256, as discussed below. For example, a PcCAM match will provide a "1" bit on one of the 36 bit lines, with all the rest being zero. This could be written into latch ILl, for instance, so that a single bit in latch IL1 is enabled. The output could then be provided to multiplexing network 256 to activate the appropriate control lines for that entry.
  • address select logic 185, PcCAM 170, and BAC/TgtCAM 175 provide various select and enable signals to control reading, writing, setting and clearing of addresses, instructions, and valid bits.
  • the integrated BPC structure allows any number of these operations to be performed in the same cycle for different lines without contention of competing elements.
  • a first access path, used to access the BPC entry, is invoked by communicating a 32-bit DecodePC signal to the CamAddr2 input of PcCAM 170. If a match occurs, a single bit of the 36-bit CamMatch2 output 248 is asserted, and is communicated to read select inputs on the other memory elements, namely BAC 175, BHC 177, BTC 180, and TIV 182 via multiplexer 188. The result is that the corresponding entries, constituting the entire BPC entry, are read out of respective data outputs of the memory elements.
  • a second access path used to clear an old entry and start a new entry, is invoked by writing a 36-bit word, with all 0's except for a single bit, which has a 1, into one of the latches of Fig. 8 through input 248 and multiplexers 240, 242, 244, and 246.
  • the desired 32- bit address to be stored is provided to the WrData input of PcCAM 170 (see Fig. 3).
  • the output 258 of multiplexer network 256 is selected to assert signals at the WrSel2 input of PcCAM 170, and the Clear2a input of Vbit memory 172. This enables writing a new entry into the PcCAM, and clears the valid bit, pending acquisition of the target bytes.
  • the same latch is used as a pointer for the BTC write, BAC write, and BHC, V and ⁇ V writes for that entry.
  • One latch pair in address select logic 185 is a working latch pair which is not being used to track a particular branch at that time.
  • the use of four sets of latches allows three instruction streams to be kept active (the original stream and two branches), while the fourth pair of latches is used for working purposes such as writing to PcCAM.
  • the output of each FL latch which is written to through address input 252, is also coupled back through the multiplexers 240-246 so that it can be written into the IL latch as desired.
  • the FL is loaded for access (2), a write to PcCAM. It remains unchanged throughout (3)-(6) style accesses below if there is a hit. If there is a miss and an entry is created, then the FL is reloaded to point to a new queue. Accesses (3)-(6) may then occur. Similarly, IL is loaded when there is a hit with the PcCAM output. It is then used for accesses (3)-(5). 3. Write to BTC. A third access path is used to fill in the BTC queue. The line is pointed to by the latch pointing to the PcCAM portion of the line. Eight byte select signals are provided to the WrEnx2 input of BTC 180.
  • a single 8-byte block to be stored for the selected entry is provided to the WrData inputs on BTC 180. This allows part of a BTC entry to be written as multiplexer network 256 output 260 asserts select signals at inputs to the WrSel2 input of BTC 1.S0.
  • a fourth access path is used to write 39 bits of target address to the WrData inputs of BAC/TgtCAM 175 when the target address is available.
  • a sixth data path is invoked by referencing one of the IL or FL latches and as output 264 of multiplexing network 256.
  • a select signal is also provided to multiplexer 188. This allows a given BTC and BAC line to be read out independently of any CAM hit from PcCAM 170. The entire BTC entry can be read, or one or more of the three double-words in the
  • BTC entry can be read. This provides flexibility that allows certain otherwise unused BTC entries to be used for other purposes (such as instruction queues) and be controlled independently.
  • a seventh access path is invoked by communicating ICache address information to the CAMAddr input of BAC/TgtCAM 175 for an external write to the Icache.
  • the CAM portion of BAC/TgtCAM 175 performs the function of maintaining consistency between the target instruction bytes in BTC 180 and corresponding bytes in main memory (actually in the instruction cache).
  • a match causes assertion of the appropriate CamMatchl output line 266, and clears the corresponding Vbit.
  • An eighth access path is invoked by asserting a signal at the ClearA112 input 268 of Vbit 172. This can be carried out in a manner independent of other ongoing operations, and in some sense supercedes them all, because it invalidates all the BPC entries.
  • Fig. 9 is a logic schematic of second level BPC 155.
  • the second level BPC unlike first level BPC 152, comprises entries containing only a limited amount of prediction information (17 bits as compared to 226 bits). This is offset by the much larger number of entries (256 as compared to 36 for the first level BPC), which are capable of implementation with a given amount of hardware circuitry.
  • Second level BPC 155 is implemented as a 256 x 17 bit RAM. Each entry holds 2 bytes of a 4-byte target address (see discussion below why this is viable) and a single history bit.
  • the trade-off betw.een the amount of information stored in each entry, and thus the cost in hardware circuitry, and the extent to which branch processing can be accelerated, is based in part on a recognition that by far the largest, and most costly, information component stored in a first level cache entry is the copy of the first several target instructions.
  • a typical average instruction length is in the range of 3-4 bytes, with significant variation up and down.
  • To store branch target address and history information requires roughly four bytes. Comparing these numbers it is clear that to cache the first several target instructions in most cases, requires several times the number of instruction bytes as target address/history bytes.
  • a further recognition is that a significant part of the delays that can be incurred in processing a branch instruction is associated with the processing necessary before target instruction fetching can be initiated. This is particularly true in the context of the relatively long pipeline designs described earlier. The delay in actually fetching the first target instruction ⁇ ), particularly when from an instruction cache, is also significant but is not dominant.
  • the size of a second level cache entry can be dramatically reduced by not caching target instructions, while the extent to which branch processing can be accelerated is reduced only moderately. This especially makes sense given that the second level cache serves as a backup to the first level cache.
  • the primary purpose of the second level cache is to cheaply minimize the processing delays stemming from as many of the rest of the branch instructions as is possible.
  • a large part of the overall cost-effectiveness of this invention stems from the exchanging of a second level cache entry's ability to accelerate branch processing for hardware cost savings and substantial increases in the number of second level cache entries.
  • a second level BPC entry holds only a partial target address and one history bit.
  • the predicted direction of a conditional branch is based simply on the direction last taken by that branch.
  • the branch target address is assumed to be within a subset of the instruction address space also containing the branch instruction. For example, if the branch instruction and target instruction are assumed to be within the same 64-KB block, then only 16 bits of target address prediction information need be stored.
  • the full predicted target address is a concatenation of the upper address bits from the branch instruction's address with the lower 16 bits from the cache entry.
  • Second level BPC 155 uses a direct-mapped access method, versus a set or fully associative method. This is acceptable due to the relatively large number of second level cache entries. Even more significantly, it is then possible to discard the tag and tag storage associated with each cache entry, along with the valid bit. In essence, when a cache look-up accesses a selected entry, it is simply assumed that the tag and look-up address match, and it is a hit.
  • a bad address prediction is no worse than no prediction. Further, the occurrence of such bad predictions corresponds to the miss rate of the second level cache and thus is reasonably low given the relatively large number of cache entries. This is also enhanced by applying the hardware savings from eliminating the tag storage to increasing the number of cache entries. Operation
  • each branch instruction As each branch instruction is fetched its address is used to perform parallel look-ups in the two levels of BPC: the large-set or fully associative first level access using the full branch address; and the direct-mapped, tag-less second level using only a subset of the address bits for the index. If there is a tag match with a first level cache entry, then all of this entry's prediction information is read out, and the second level BPC is ignored. All the necessary predictions are made, effectively eliminating or hiding any delays in otherwise processing the branch instruction and in starting processing of successive instructions. Of course, when one or more of the predictions is subsequently found to be wrong, any hidden delays become exposed and possibly an additional delay incurred while the CPU pipeline is flushed and/or restored to an appropriate state from which to continue correct instruction processing.
  • the prediction information read out from the indexed second level cache entry is used to at least predict some aspects of the branch instruction's processing.
  • a second level cache look-up effectively is assumed to always hit.
  • a full 32-bit target address is predicted as well as, in the case of a conditional branch, the branch direction. This enables delays in the processing of the branch itself to be hidden; if the branch is predicted as being taken, this also includes initiation of target instruction fetching. Actually, because of the support for prefetching down multiple instruction streams, target instruction fetching will still tend to take place as a lower priority activity, even if the branch is predicted as not being taken. There will still be a delay before processing of target instructions can begin, if the branch is predicted taken.
  • Second level cache mis-predictions are the same as for the first level cache. There is also no substantive difference between whether the prediction was based on cached information from an earlier execution of this branch or from some other branch. With a low second level cache miss rate, the latter type of mis-prediction will be uncommon.
  • the present invention provides a surprisingly effective and efficient approach to operation of a BPC, providing most of the benefits of a much larger structure.
  • the first level cache is preferably implemented as fully associative, it could be implemented as a direct-mapped or set associative structure. Therefore, the above description should not be taken as limiting the scope of the invention which is defined by the appended claims.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

Agencement d'antémémoire de prédiction de branchement (APB) amélioré utilisant une structure d'antémémoire hybride. L'APB (13) présente deux niveaux de mise en antémémoire d'informations de branchement. L'APB (152) du premier niveau entièrement associatif est une structure peu profonde mais large (36 entrées à 32 octets), laquelle met en antémémoire des informations de prédiction entière pour un nombre limité d'instructions de branchement. L'APB (155) du second niveau à projection directe est une structure profonde mais étroite (256 entrées à 2 octets), laquelle met en antémémoire uniquement des informations de prédiction partielle pour un nombre beaucoup plus élevé d'instructions de branchement. A mesure que chaque instruction de branchement est extraite et est décodée, son adresse est utilisée afin d'effectuer des recherches parallèles dans les deux antémémoires de prédiction de branchement.
PCT/US1991/000826 1990-02-26 1991-02-06 Antememoire de prediction de branchement a deux niveaux WO1991013402A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US48530690A 1990-02-26 1990-02-26
US485,306 1990-02-26

Publications (1)

Publication Number Publication Date
WO1991013402A1 true WO1991013402A1 (fr) 1991-09-05

Family

ID=23927649

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/US1991/000826 WO1991013402A1 (fr) 1990-02-26 1991-02-06 Antememoire de prediction de branchement a deux niveaux

Country Status (1)

Country Link
WO (1) WO1991013402A1 (fr)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4679141A (en) * 1985-04-29 1987-07-07 International Business Machines Corporation Pageable branch history table
US4860199A (en) * 1987-07-31 1989-08-22 Prime Computer, Inc. Hashing indexer for branch cache
US4894772A (en) * 1987-07-31 1990-01-16 Prime Computer, Inc. Method and apparatus for qualifying branch cache entries
US4943908A (en) * 1987-12-02 1990-07-24 International Business Machines Corporation Multiple branch analyzer for prefetching cache lines

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4679141A (en) * 1985-04-29 1987-07-07 International Business Machines Corporation Pageable branch history table
US4860199A (en) * 1987-07-31 1989-08-22 Prime Computer, Inc. Hashing indexer for branch cache
US4894772A (en) * 1987-07-31 1990-01-16 Prime Computer, Inc. Method and apparatus for qualifying branch cache entries
US4943908A (en) * 1987-12-02 1990-07-24 International Business Machines Corporation Multiple branch analyzer for prefetching cache lines

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
A. THAMPY THOMAS; "A Single Cycle VLSI CISC- Based Workstation: System Overview and Performance Characteristics"; COMPUTER SOCIETY OF THE IEEE", pages 500-503, Published 1989. *

Similar Documents

Publication Publication Date Title
US5163140A (en) Two-level branch prediction cache
US5511175A (en) Method an apparatus for store-into-instruction-stream detection and maintaining branch prediction cache consistency
US5860107A (en) Processor and method for store gathering through merged store operations
US5963984A (en) Address translation unit employing programmable page size
US5778407A (en) Methods and apparatus for determining operating characteristics of a memory element based on its physical location
US6542984B1 (en) Scheduler capable of issuing and reissuing dependency chains
US6687789B1 (en) Cache which provides partial tags from non-predicted ways to direct search if way prediction misses
US6502185B1 (en) Pipeline elements which verify predecode information
US5093778A (en) Integrated single structure branch prediction cache
US5596740A (en) Interleaved memory conflict resolution with accesses of variable bank widths and partial return of non-conflicting banks
US5793941A (en) On-chip primary cache testing circuit and test method
US5249286A (en) Selectively locking memory locations within a microprocessor's on-chip cache
US5752274A (en) Address translation unit employing a victim TLB
US6622237B1 (en) Store to load forward predictor training using delta tag
US5940858A (en) Cache circuit with programmable sizing and method of operation
US6694424B1 (en) Store load forward predictor training
US6564315B1 (en) Scheduler which discovers non-speculative nature of an instruction after issuing and reissues the instruction
GB2284912A (en) Data processor with speculative instruction fetching and method of operation
US5835949A (en) Method of identifying and self-modifying code
US5596735A (en) Circuit and method for addressing segment descriptor tables
US5732243A (en) Branch processing unit with target cache using low/high banking to support split prefetching
US6622235B1 (en) Scheduler which retries load/store hit situations
US6721877B1 (en) Branch predictor that selects between predictions based on stored prediction selector and branch predictor index generation
US6647490B2 (en) Training line predictor for branch targets
US5649137A (en) Method and apparatus for store-into-instruction-stream detection and maintaining branch prediction cache consistency

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): DE GB JP KR

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): AT BE CH DE DK ES FR GB GR IT LU NL SE

REG Reference to national code

Ref country code: DE

Ref legal event code: 8642