CN1282930C - Apparatus and method for efficiently updating branch target address cache - Google Patents
Apparatus and method for efficiently updating branch target address cache Download PDFInfo
- Publication number
- CN1282930C CN1282930C CNB2004100018088A CN200410001808A CN1282930C CN 1282930 C CN1282930 C CN 1282930C CN B2004100018088 A CNB2004100018088 A CN B2004100018088A CN 200410001808 A CN200410001808 A CN 200410001808A CN 1282930 C CN1282930 C CN 1282930C
- Authority
- CN
- China
- Prior art keywords
- instruction
- target address
- branch
- branch target
- btac
- Prior art date
- Legal status (The legal status 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 status listed.)
- Expired - Lifetime
Links
- 238000000034 method Methods 0.000 title claims description 50
- 239000000872 buffer Substances 0.000 claims description 70
- 230000015572 biosynthetic process Effects 0.000 claims description 16
- 230000004044 response Effects 0.000 claims description 12
- 230000000712 assembly Effects 0.000 claims description 10
- 238000000429 assembly Methods 0.000 claims description 10
- 230000001915 proofreading effect Effects 0.000 claims description 2
- 230000003111 delayed effect Effects 0.000 abstract 1
- 230000008569 process Effects 0.000 description 37
- 238000010586 diagram Methods 0.000 description 16
- 230000004913 activation Effects 0.000 description 6
- 238000012546 transfer Methods 0.000 description 6
- 230000008901 benefit Effects 0.000 description 4
- 230000002596 correlated effect Effects 0.000 description 4
- 238000010606 normalization Methods 0.000 description 3
- 229920006395 saturated elastomer Polymers 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 230000008676 import Effects 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 101150064138 MAP1 gene Proteins 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000003466 anti-cipated effect Effects 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000011002 quantification Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Images
Landscapes
- Advance Control (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
A microprocessor with a write queue for a branch target address cache (BTAC) is disclosed. The BTAC is read in parallel with an instruction cache in order to predict a target address of a branch instruction in the accessed cache line. In one embodiment, the BTAC is single-ported; hence, the single port must be shared for reading and writing. When the BTAC needs updating, such as when a branch target address is resolved, the microprocessor stores the branch target address and related information in the write queue. Thus, the write queue potentially enables updating of the BTAC to be delayed until the BTAC is not being read, such as when the instruction cache is idle, a misprediction by the BTAC is being corrected, or a prediction by the BTAC is being overridden. If the write queue becomes full, then it updates the BTAC anyway.
Description
Technical field
The present invention relates to a kind of branch prediction (branch prediction) of microprocessor, and particularly relate to a kind of branch prediction that utilizes the predictability branch target address caching.
Background technology
Modern microprocessor all is the microprocessor of streamline (pipeline).That is, in the different masses or flow line stage of microprocessor, can operate several instructions simultaneously.By John L.Hennessy and David A.Patterson at its works: computer architecture: quantification method (Computer Architecture:A Quantitative Approach) is (by the root Huffman publishing house (California of rubbing, San Francisco) at 1996 second editions that gone out) in, the definition streamline is: " when carrying out, the technical application that a plurality of indications overlap each other (an implementation technique whereby multiple instructions areoverlapped in execution).It provides the excellent description of streamline: streamline is similar to assembly line.In the vehicle assembly line, many steps are arranged, each step is made some contribution to the assembling of vehicle.Though for different vehicle, the operation of each step is parallel to other step.In computer pipeline, each streamline of streamline is finished the some of instruction.Be similar to assembly line, different step has been finished the partly different of parallel different instruction.Each step is called flow line stage (pipe stage) or streamline part (pipesegment).These stages are connected with each other to form streamline, and instruction enters from an end, via these phase process, and exports in the other end, just handles vehicle as assembly line.
Synchronous microprocessor is to operate according to the clock period.Generally speaking, in each clock period, instruction advances to another stage from a stage of the streamline of this microprocessor.In the vehicle assembly line, if because do not have vehicle to assemble to make that the personnel of working online are in idle, then the output of this line or performance can descend.Similar, if at a clock in the cycle, the streamline of a certain microprocessor is not because instruction will be operated and is in idlely, and being often referred to this state is streamline bubble (pipeline bubble), and then the performance of this microprocessor can descend.
One of possible cause that causes the streamline bubble is a branch instruction.When handling branch instruction, processor must determine the destination address of this branch instruction and begin at this destination address place rather than the acquisition instruction of the next address place after this branch instruction.Even if this branch instruction is a situation branch instruction (that is, must whether exist according to a particular condition to determine whether this branch will carry out), except determining this destination address, this processor must determine also whether this branch instruction will be carried out.Because this flow line stage of this destination address of final decision and/or branch outcome (that is whether branch will carry out) is in the below in instruction acquisition stage usually, may produce bubble.
Be head it off, Modern microprocessor is generally used branch prediction mechanism with early prediction destination address and branch outcome at streamline.One example of branch prediction mechanism is that (branch target address cache, BTAC), it is parallel to from the instruction cache acquisition instruction of this microprocessor predicts this branch outcome and destination address to branch target address caching.When microprocessor was carried out branch instruction and final decision and will be carried out this branch with its destination address of decision, the address of this branch instruction and its destination address write in this BTAC.Next time, this branch instruction address can be hit in this BTAC and this BTAC can export this branch instruction destination address in early days at streamline when this instruction cache captures this branch instruction.
Effectively BTAC can get rid of or reduce the number of bubbles that will wait for the branch instruction decision, to improve processor performance.Yet when this BTAC prediction error, the part of the streamline of mistake acquisition instruction must be abandoned, and essential acquisition right instructions, when generation is abandoned and captured in instruction, can cause bubble in streamline.When the streamline of microprocessor was darker, the validity of BTAC more can be the key aspect that influences performance.
The validity of BTAC mainly is the effect of the hit rate of BTAC.One of factor that influences the BTAC hit rate is the different branch instruction quantity of its stored destination address.Store many more branch instruction destination addresses, BTAC is effective more.Yet the microprocessor chip area is always limited, thereby will make the area of set functional block (such as BTAC) diminish as far as possible.A factor that influences the real area of BTAC is the size that destination address and relevant information is stored in the storage element (cell) in the BTAC.Particularly, the area of single port unit is less than the area of multiport unit.The BTAC that is made up of the single port unit can only read or write in a set clock period, can't read and write simultaneously, but can be read and write simultaneously in a set clock period by the BTAC that the multiport unit is formed.Yet the area of multiport BTAC is greater than single port BTAC.This means, suppose the real area that is allowed to of given BTAC, the storable destination address quantity of multiport BTAC must be less than the storable destination address quantity of single port BTAC, thereby can reduce the validity of BTAC.Therefore, viewpoint thus, single port BTAC is preferable.
Yet, because single port BTAC can only read or write in a set clock period, can't read and write simultaneously, this true meeting reduces BTAC validity because puppet is fallen through (false miss).In the cycle that BTAC need be read, BTAC just is written into when single port, when utilizing the fresh target address to upgrade BTAC maybe will to make a certain destination address invalid, puppet can take place fall through.In the case, BTAC must read to produce and fall through this, because it can't supply with this destination address that may be present in the BTAC, because this BTAC just is written into.
Thereby, the method and apparatus that needs a kind of puppet that can reduce in the single port BTAC to fall through.
The additional phenomenon that may reduce BTAC validity is the destination address that BTAC can repeatedly store branch instruction.This phenomenon may betide in multidirectional instruction set associating (multi-way set-associative) BTAC.Because the BTAC space is limited, unnecessary destination address stores and can reduce BTAC validity, because unnecessary BTAC inlet point can store the destination address of another branch instruction.Streamline is longer, that is number of stages is bigger, and unnecessary destination address more may be stored in the BTAC.
Same branch instruction is in the tight loop (tight loop) at sign indicating number by the most common situation of high-speed cache repeatedly in BTAC.Carry out for the first time branch instruction and its destination address and be writing to this BTAC, such as be written to second to because second to being not use at most.Yet before destination address write to BTAC, branch instruction occurred once more, that is this BTAC looks into and transfer this instruction cache acquisition address fall through, because this destination address does not write in this BTAC as yet.Then, destination address can be write to this BTAC for the second time.Read and cause second if in this instruction set, insert the BTAC of different branch instructions to no longer being usefulness not at most, then another to, such as first to, can be selected to and write this destination address for the second time.Now, the destination address secondary of same branch instruction is present in this BTAC.This is the waste of a kind of BTAC space and can reduces BTAC validity, because write the actual target address that covers another branch instruction possibly for the second time.
Therefore, the method and apparatus that needs a kind of useful BTAC space that unnecessary high-speed cache caused waste of the destination address that can avoid same branch instruction.
Even the combination that is relevant to some situation of BTAC predictability can cause the interior fast knot (deadlock) of little processing.The combination of the branch prediction of BTAC, across the branch instruction of instruction cache boundary line, and can the conclude the business fact of predictability instruction acquisition of processor bus, the situation that can make the mistake causes the fast knot under some situation.
Thereby, need the method and apparatus of the fast knot situation in a kind of microprocessor that can avoid applied forcasting BTAC.
Summary of the invention
The invention provides a kind of queue memory that writes to postpone writing of BTAC, do not read, thereby reduce the puppet rate of falling through up to this BTAC.According to an aspect of the present invention, a kind of queue memory that writes is provided, improve the efficient of the branch target address caching (BTAC) in the microprocessor, this writes queue memory and comprises that one requires input end, receive one and require to upgrade this branch target address caching, this requirement comprises a branch instruction destination address; A plurality of storage assemblies store these requirements that this requires input end to receive; Control logic circuit is coupled to these storage assemblies, will be stored in these storage assemblies these in response to one or more both stable condition and one of require to write to this branch target address caching; The one high-speed cache input end that leaves unused, be coupled to this control logic circuit, when one instruction cache of access is idle when being parallel to this branch target address caching, these one or more both one of stable condition of specifying this branch target address caching not to be read; The full up input end of one impact damper, be coupled to this control logic circuit, because an instruction buffer is full up, these one or more both one of stable condition that it specifies this branch target address caching not to be read, wherein an instruction cache of this instruction buffer access from being parallel to this branch target address caching receives instruction; One prediction replaces input end, be coupled to this control logic circuit, because one second branch instruction predictions that one first branch instruction predictions that this branch target address caching is finished is finished by the branch prediction logic in this microprocessor replaces, these one or more both one of stable condition that it specifies this branch target address caching not to be read; One branch mistake is surveyed input end, is coupled to this control logic circuit, finishes the survey of branch instruction mistake, these one or more both one of stable condition that it specifies this branch target address caching not to be read because detect this branch target address caching; And the full up input end of a formation, be coupled to this control logic circuit, specifying whole storage assemblies is just to store these one or more both one of stable condition that require to this branch target address caching to be written.
According to a further aspect in the invention, provide a kind of microprocessor to comprise: an instruction cache provides a cache line of command byte in response to an instruction acquisition address; One branch target address caching is coupled to this instruction cache, and prediction is stored in a branch target address of the branch instruction in this cache line; One writes queue memory, is coupled to this branch target address caching, stores the branch target address that is used to upgrade this branch target address caching; One branch prediction logic, be coupled to this and write queue memory, wherein after this branch target address caching is finished one first prediction of a branch instruction, this branch prediction logic is finished one second prediction of this branch instruction, and wherein this microprocessor utilizes this second prediction to replace this first prediction; And branch's decision logic circuit, be coupled to this and write queue memory, correct a mistake of the branch instruction that this branch target address caching finishes and survey; If wherein this to write queue memory be not empty, when this instruction cache is in when idle, then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching; If this writes queue memory is not empty, when this instruction buffer indicates that it is when full, then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching, zero or a plurality of cache lines that this instruction buffer storage receives from this instruction cache; If this writes queue memory is not empty, when utilizing this second prediction, this microprocessor replaces this first when prediction, and then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching; If this writes queue memory is not empty, when this mistake of proofreading and correct this branch instruction that this branch target address caching finishes when this microprocessor was surveyed, this write queue memory and utilizes one of these branch target address to upgrade this branch target address caching; Become full uply if this writes queue memory, this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching.
The method of the branch target address caching (BTAC) in a kind of renewal one microprocessor is provided according to a further aspect in the invention.This method comprises the following steps: to produce one and requires to upgrade this branch target address caching; Storing this requires in a formation; Determine because of an instruction cache that is coupled to this branch target address caching is idle whether this branch target address caching is not read, if this branch target address caching is not read, then upgrade this branch target address caching according to this requirement; Determine because of an instruction buffer is full up whether this branch target address caching is not read, if this branch target address caching is not read, then upgrade this branch target address caching according to this requirement, wherein this instruction buffer receives the instruction of exporting from this instruction cache; One second branch instruction predictions whether one first branch instruction predictions that determines this branch target address caching to finish is finished by other branch prediction logic in this microprocessor replaces, if this first branch instruction predictions that this branch target address caching is finished is replaced by this second branch instruction predictions, then upgrade this branch target address caching according to this requirement; Determine whether this branch target address caching surveys a branch instruction by mistake; If this branch target address caching is surveyed a branch instruction by mistake, then upgrade this branch target address caching according to this requirement; Determine that whether this formation is full up, if this formation is full up, then upgrades this branch target address caching according to this requirement.
The invention has the advantages that it can reduce when being read because of BTAC but will write to the quantity that puppet that BTAC causes is fallen through, to increase the efficient of BTAC.In addition, the present invention can use single port BTAC, but not uses the bigger multiport BTAC of area, to reduce the area of BTAC.In addition, the present invention can make BTAC can store more destination address, thereby more efficient, compared with the multiport BTAC of similar size.
For above and other objects of the present invention, feature and advantage can be become apparent, a preferred embodiment cited below particularly, and be described with reference to the accompanying drawings as follows.
Description of drawings
Fig. 1 shows the block diagram according to microprocessor of the present invention.
Fig. 2 shows the part detailed diagram according to the microprocessor of Fig. 1 of the present invention.
Fig. 3 shows the part detailed diagram according to the BTAC of Fig. 1 of the present invention.
Fig. 4 shows the block diagram according to the destination address array inlet point content of Fig. 3 of the present invention.
Fig. 5 shows the block diagram according to the label array inlet point content of Fig. 3 of the present invention.
Fig. 6 shows the block diagram according to the counter array inlet point content of Fig. 3 of the present invention.
The BTAC that Fig. 7 shows according to Fig. 1 of the present invention writes the block diagram that requires content.
Fig. 8 shows the block diagram that writes queue memory according to the BTAC of Fig. 3 of the present invention.
Fig. 9 shows the operational flowchart that writes queue memory according to the BTAC of Fig. 1 of the present invention.
Figure 10 shows the block diagram according to the invalid logical circuit of unnecessary destination address of this BTAC in this microprocessor of Fig. 1 of the present invention.
Figure 11 shows the operational flowchart according to the unnecessary destination address device of Figure 10 of the present invention.
Figure 12 shows the block diagram of avoiding logical circuit according to the fast knot in this microprocessor of Fig. 1 of the present invention.
Figure 13 shows the operational flowchart of avoiding logical circuit according to the fast knot of Figure 12 of the present invention.
The drawing reference numeral explanation:
100: microprocessor 102: the instruction acquisition device
104: instruction cache 106: instruction buffer
108: instruction normalizer 112: standardizing order formation
114: instruction transfer interpreter 116: translate the back instruction queue
118: the buffer stage 122: address phase
124: data phase 126: execute phase
128: storage stage 132: write back the stage
134: totalizer 136,148,206: multiplexer
138: instruction 142:BTAC
144:BTAC writes formation (BWQ) storer 146: queue depth
152: branch's mistake is surveyed signal 154: prediction replaces signal
156: instruction buffer is full up signal 158: the instruction cache idle signal
162: capture address 164 at present: predicted target address
166: next captures address 168: present instruction pointer
172: correct address 174: replace predicted target address
176:BTAC writes and requires 178:BTAC to write the queue memory address
182: address 202: moderator
212:BTAC reading requirement signal 214: unnecessary destination address (TA) requires signal
216: fast knot requires the non-spacing wave of signal 218:BWQ
222:BWQ is full up signal 234: unnecessary TA address
236: fast knot address 244: unnecessary TA data-signal
246: fast knot data-signal 248:BWQ data-signal
252,258,262,1204: control signal
256: data-signal 302: the destination address array
304: label array 306: counter array
312: destination address array inlet point 314: label array inlet point
316: counter array inlet point 402: branch target address
404,708: beginning field 406: across the position
502: label 504:A significance bit
506:B significance bit 508:lru field
602: predicted state A counter 604: predicted state B counter
606:A/Blru position 702: branch instruction address field
706: destination address 712: across the position
714: write activation A field 716: write activation B field
718: invalid A field 722: invalid B field
724: to field 802: storage assembly
804,1004: significance bit 806,1014: control logic circuit
1002: label 1006: matched signal
1012: comparer 1022: unnecessary TA invalid data buffer
1024: unnecessary TA sign buffer 1026: unnecessary TA Address Register
1202:F_wrap signal 1206: signal falls through
1208: prediction signal 1212: carry out/do not carry out (T/NT) signal
1214:B_wrap signal 1222: fast knot invalid data buffer
1224: fast knot sign buffer 1226: fast knot Address Register
Embodiment:
Refer now to Fig. 1, show block diagram according to a microprocessor 100 of the present invention.This microprocessor 100 comprises a streamline microprocessor.
Instruction normalizer 108 also comprises the logical circuit that produces branch target address, is called to replace predicted target address 174.In one embodiment, branch target address produces logical circuit and comprises a totalizer, and the deviation of a relative branch instruction is added to branch instruction address to produce replacement predicted target address 174.In one embodiment, this logical circuit comprises that a branch target buffer is to produce the destination address of indirect branch instruction.In one embodiment, this logical circuit comprises a calling/passback storehouse, to produce the destination address of calling out with the passback instruction.Instruction normalizer 108 comprises that also a prediction replaces signal 154.Instruction normalizer 108 produces it and replaces signal 154 to replace the branch prediction that BTAC142 was done in this microprocessor 100 for really predicting, will be discussed in more detail below.That is, if the destination address that logical circuit produced in the instruction normalizer 108 does not meet destination address that BTAC142 produces, then instruct normalizer 108 to be produced as and really predict to replace signal 154 so that the instruction of the forecasting institute of this BTAC142 acquisition is abandoned and made microprocessor 100 branch to this replacement predicted target address 174.In one embodiment, abandoned and microprocessor 100 branched in the time of this replacement predicted target address 174 in instruction, BTAC142 can not be read.
Microprocessor 100 also comprises one second multiplexer 136, is coupled to BTAC142.Multiplexer 136 selects one of 6 inputs to capture address 162 at present to be output into one.One of input is next the acquisition address 166 that is produced by a totalizer 134, and 134 pairs of totalizers capture address 162 at present and add that the size of cache line is to produce this next acquisition address 166.Behind instruction cache 104 normal acquisition one cache lines, multiplexer 136 selects this next acquisition address 166 to be output into this acquisition address 162 at present.Another input is to capture address 162 at present.Another input is a BTAC predicted target address 164, if BTAC142 indicates a branch instruction to be present in this cache line of being selected out from address 162 of acquisition at present of this instruction cache 104 and BTAC142 dopes this branch instruction and will be performed, then multiplexer 136 is selected BTAC predicted target address 164.Another input is the correct address 172 that receives from storage stage 128, and multiplexer 136 selects correct address 172 to survey to proofread and correct branch mistake.Another input is the replacement predicted target address 174 that receives from instruction normalizer 108, and multiplexer 136 selects this replacement predicted target address 174 to replace this BTAC test target address 164.Another input is a present instruction pointer 168, and it points at present just by the address of these instruction normalizer 108 normalized instructions.Multiplexer 136 selects this present instruction pointer 168 to avoid the fast knot situation, and is as described below.
BTAC writes queue memory 144 generations one BTAC and writes queue memory address 178, and it inputs to multiplexer 148.BTAC writes queue memory 144 and also comprises a buffer that stores a present queue depth 146.Queue depth 146 points out to be stored at present effective BTAC in the BWQ144 and writes and require 176 quantity.The initial value of queue depth 146 is 0.A BTAC is write at every turn and require 176 to deposit to BTAC and write in the queue memory 144, queue depth 146 all can increase.A BTAC is write at every turn and require 176 to remove from BWQ144, queue depth 146 all can reduce.BTAC writes queue memory 144 and will describe in detail below.
Refer now to Fig. 2, show part detailed diagram according to the microprocessor of Fig. 1 of the present invention.Fig. 2 shows that BTAC writes queue memory 144, the multiplexer 148 of BTAC142 and Fig. 1, and other increases by a moderator 202, and is coupled in this BTAC and writes 3-input multiplexer 206 between queue memory 144 and this BTAC142.Though the multiplexer 148 of Fig. 1 receives only 2 inputs, multiplexer 148 is 4-input multiplexers, as shown in Figure 2.As shown in Figure 2, BTAC142 comprises a read/write input end, an address input end and a data input pin.
As shown in Figure 1, multiplexer 148 receives acquisition address 162 and this BWQ address 178 at present.In addition, multiplexer 148 also receives a unnecessary TA address 234 and a fast knot address 236, will do detailed description with reference to figure 10-11 and Figure 12-13 respectively.The control signal 258 that multiplexer 148 is produced according to this moderator 202 selects one of its 4 inputs to be output into the address date 182 of Fig. 1, and this address date 182 is these address input ends that input to this BTAC142.
This multiplexer 206 receives a unnecessary TA data-signal 244 and a fast knot data-signal 246, will do detailed description with reference to figure 10-11 and Figure 12-13 respectively.Multiplexer 206 also receives from this BTAC and writes the BWQ data-signal 248 that queue memory 144 transmits, and it writes the data that queue memory 144 needs to upgrade this BTAC142 for this present BTAC.The control signal 262 that multiplexer 206 is produced according to this moderator 202 selects one of three inputs to be output into a data-signal 256, and it inputs to the data input pin of this BTAC142.
Moderator 202 arbitrations require a plurality of sources of access to this BTAC142.When BTAC142 was read or write, moderator 202 produced this read/write input end of a signal 252 to this BTAC142 with control.Moderator 202 receives a BTAC reading requirement signal 212, and its representative is parallel to and also utilizes acquisition address 162 at present and the utilization of reading of instruction cache 104 is captured address 162 and the requirement of reading BTAC142 at present.Moderator 202 also receives a unnecessary destination address (TA) and requires signal 214, and a requirement of a unnecessary inlet point of the interior same branches instruction of these the unnecessary TA address 234 selected instruction set in invalid this BTAC142 is wanted in its representative, will be described below.Moderator 202 also receives a fast knot requirement signal 216, and its representative will be surveyed a branch instruction in the damned total address 236 selected instruction set not across a requirement of the inlet point ineffective treatment in this BTAC142 of high-speed cache boundary line with mistake, will be described below.Moderator 202 also receives the non-spacing wave 218 of a BWQ that writes queue memory 144 outputs from this BTAC, and its representative has pending at least one requirement to upgrade the inlet point in this BTAC142 in these BWQ address 178 selected instruction set, and this will be described below.Moderator 202 also receives the full up signal 222 of a BWQ that writes queue memory 144 outputs from this BTAC, on behalf of this BTAC, it write the pending requirement that queue memory 144 has filled up the inlet point in this BTAC142 that will upgrade in these BWQ address 178 selected instruction set, will be described below.
In one embodiment, moderator 202 assigned priorities, shown in following table 1, wherein 1 represent highest priority and 5 represent lowest priority:
The 1-fast knot requires 216
2-BMQ is full up 222
3-BTAC reading requirement 212
The unnecessary TA of 4-requires 214
5-BWQ non-NULL 218
Refer now to Fig. 3, Fig. 3 shows the detailed diagram according to the BTAC142 of Fig. 1 of the present invention.As shown in Figure 3, this BTAC142 comprises a destination address array 302, one label arrays 304, with a counter array 306.Each array 302,304 and 306 receives the address 182 of Fig. 1.The embodiment of Fig. 3 shows 4 to instruction set associating BTAC142 high-speed cache.In another embodiment, BTAC142 comprises 2 to the instruction set associative cache.In one embodiment, this destination address array 302 is single port with this label array 304, but counter array 306 is to have the dual-port that a read port and is write inbound port, because the renewal frequency of counter array 306 is higher than the renewal frequency of this destination address array 302 and this label array 304.
This destination address array 302 comprises a storage assembly array, to store the destination address array inlet point 312 of energy high-speed cache branch target address and correlated branch information of forecasting.The content of destination address array inlet point 312 will be described below with reference to figure 4.This label array 304 comprises a storage assembly array, to store the label array inlet point 314 that can store address label and correlated branch information of forecasting.The content of label array inlet point 314 will be described below with reference to figure 5.This counter array 306 comprises a storage assembly array, to store the counter array inlet point 316 that can store the branch outcome information of forecasting.The content of counter array inlet point 316 will be described below with reference to figure 6.
Each destination address array 302, label array 304, with counter array 306 be formulated for 4 to, the as directed the 0th to (way 0), the 1st to (way 1), the 2nd to (way 2) with the 3rd to (way 3).Preferably, each of destination address array 302 is to storing 2 inlet points or some, with high-speed cache branch target address and predictability branch information, by A and B representative, if making has two branch instructions to be present in the cache line, BTAC142 is measurable to go out suitable branch instruction.
Each array 302-306 is indexed by the address 182 of Fig. 1.The low level of address 182 is selected the cache line in each array 302-306.In one embodiment, each array 302-306 comprises 128 instruction set.Therefore, BTAC142 can high-speed cache up to 1024 destination addresses, each of each instruction set has 2 addresses to (each instruction set have 4 to).Preferably, array 302-306 is indexed to select 4 in the BTAC142 to instruction set by the position [11:5] of address 182.
Refer now to Fig. 4, Fig. 4 shows the content according to the destination address array inlet point 312 of Fig. 3 of the present invention.
This destination address array inlet point 312 comprises a branch target address (TA) 402.In one embodiment, destination address 402 comprises the 32-bit address, obtains from the previous execution high-speed cache of branch instruction.BTAC142 provides the destination address 402 about prediction TA output 164.
This destination address array inlet point 312 also comprises field 404 at the beginning.The representative of beginning field 404 is in response to this byte deviation (byte offset) of first byte of acquisition address 162 and this branch instruction in the cache line of these instruction cache 104 outputs at present.In one embodiment, a cache line comprises 32 bytes; Therefore, beginning field 404 comprises 5.
This destination address array inlet point 312 also comprises one across (wrap) position 406.If this predicted branches instruction is two high speed cache lines across instruction cache 104, is true across position 406.BTAC142 provide about B_wrap signal 1214 across position 406, will be discussed below with reference to Figure 12.
Please refer to Fig. 5, Fig. 5 shows the content according to the label array inlet point 314 of Fig. 3 of the present invention.
This label array inlet point 314 comprises a label 502.In one embodiment, label 502 comprises 20 of the high-orders of the address of this branch instruction, and this branch instruction makes the relevant inlet points in this destination address array 302 store a predicted target address 402.If this inlet point is effective words, relatively 20 of the high-orders of label 502 and the address 182 of Fig. 1 are determining whether this inlet point is matched with address 182 for BTAC142, that is whether hit in BTAC142 address 182.
This label array inlet point 314 also comprises an A significance bit 504, if in one's duty this destination address 402 of A portion of the relevant inlet point in this destination address array 302 is effectively to talk about, A significance bit 504 is true.This label array inlet point 314 also comprises a B significance bit 506, if in one's duty this destination address 402 of B portion of the relevant inlet point in this destination address array 302 is effectively to talk about, this B significance bit 506 is true.
This label array inlet point 314 also comprises a 3-position lru field 508, its indicate selected instruction set this 4 to which to being lru (Least Recently Used does not use at most).In one embodiment, when carrying out BTAC branch, BTAC142 only upgrades this lru field 508.That is, having only as BTAC142 and predict that a branch instruction will be performed and this microprocessor 100 when branching to this predicted target address 164 that this BTAC142 provides according to prediction, BTAC142 just can upgrade this lru field 508.When BTAC branch Zhizheng is performed, BTAC142 be not read and do not need to use BTAC write queue memory 144 during in, BTAC142 can upgrade lru field 508.
Please refer to Fig. 6, Fig. 6 shows the content according to the counter array inlet point 316 of Fig. 3 of the present invention.
Counter array inlet point 316 comprises a predicted state A counter 602.In one embodiment, this predicted state A counter 602 is 2-position saturated counters, and when these microprocessor 100 decisions will be carried out the correlated branch instruction at every turn, it was up counted; When not carrying out the correlated branch instruction, it is down counted at every turn.When up counting, this predicted state A counter 602 is saturated in the binary value of b`11; When down counting, this predicted state A counter 602 is saturated in the binary value of b`00.In one embodiment, if the value of this predicted state A counter 602 is b`11 or b`10, then BTAC142 predicts that the A branch instruction partly that is relevant to selected destination address array inlet point 312 will be performed; Otherwise the instruction of BTAC142 predicted branches is not performed.Counter array inlet point 316 also comprises a predicted state B counter 604, and it is operated similar in appearance to this predicted state A counter 602, but it is relevant to the B part of selected destination address array inlet point 312.
Counter array inlet point 316 also comprises an A/Blru position 606.On behalf of the A of selected destination address array inlet point 312, the binary value of the b`1 in the A/Blru position 606 do not use at most; Otherwise the B that then is selected destination address array inlet point 312 does not use at most.In one embodiment, when branch instruction arrived this storage stage 128 of meeting decision branch outcome (that is whether branch will carry out), A/Blru position 606 was updated with B counter 602 and 604 together with this predicted state A.In one embodiment, refresh counter array inlet point 316 does not need to use BTAC and writes queue memory 144, writes inbound port because counter array 306 comprises a read port and, as shown in Figure 3.
Now please refer to Fig. 7, Fig. 7 shows BTAC according to Fig. 1 of the present invention and writes and require 176 content.Fig. 7 shows that input to BTAC that BTAC writes queue memory 144 writes and require to upgrade the information of the inlet point of a BTAC142 by storage stage 128 being used to of being produced in the signal 176, it also is to be stored in the interior content of inlet point that BTAC writes queue memory 144, as shown in Figure 8.
BTAC writes and requires 176 to comprise a branch instruction address field 702, and it is the address that will upgrade the previous execution branch instruction of this BTAC142.When this writes when requiring 176 then to upgrade BTAC142,20 of the high-orders of branch instruction address field 702 are deposited to the label field 502 of the label array inlet point 314 of Fig. 5.The low order of branch instruction address field 702 7 [11:5] is as the index of BTAC142.In one embodiment, branch instruction address field 702 is 32-bit fields.
BTAC writes and requires 176 also to comprise field 708 at the beginning, in the beginning field 404 that is stored in Fig. 4.BTAC writes and requires 176 also to comprise one across position 712, be stored in Fig. 4 across in the position 406.
BTAC writes and requires 176 to comprise that also one writes activation A field 714, its representative whether to utilize BTAC to write to require 176 specified message upgrade in the selected destination address array inlet point 312 A partly.BTAC writes and requires 176 to comprise that also one writes activation B field 716, its representative whether to utilize BTAC to write to require 176 specified message upgrade in the selected destination address array inlet point 312 B partly.
BTAC writes and requires 176 also to comprise an invalid A field 718, and whether its representative wants the A part in the selected destination address array of the ineffective treatment inlet point 312.A in the selected destination address array of the ineffective treatment inlet point 312 comprises: this A significance bit 504 of removing Fig. 5.BTAC writes and requires 176 also to comprise an invalid B field 722, and whether its representative wants the B part in the selected destination address array of the ineffective treatment inlet point 312.B in the selected destination address array of the ineffective treatment inlet point 312 partly comprises: this B significance bit 506 of removing Fig. 5.
BTAC writes and requires 176 also to comprise a 4-position to field 724, its appointment to upgrade selected instruction set four-way which to.To field 724 are full Xie Code.In one embodiment, when microprocessor 100 reads BTAC142 when obtaining branch prediction, microprocessor 100 decisions will be put in the value in field 724 and should value by flow line stage down deliver to storage stage 128 and write and require in 176 to be contained in this BTAC.If microprocessor 100 is upgrading the existing inlet point in the BTAC142, that is, hit in BTAC142 if capture address 162 at present, microprocessor 100 with existing inlet point to being located in field 724.If microprocessor 100 is writing new inlet point in BTAC142, such as, new branch instruction, microprocessor 100 is not used to being located in field 724 at most with selected BTAC142 instruction set.In one embodiment, when microprocessor 100 reads BTAC142 when obtaining branch prediction, microprocessor 100 from the lru field 508 of Fig. 5 decide do not use at most to.
Refer now to Fig. 8, Fig. 8 shows the block diagram that writes queue memory 144 according to the BTAC of Fig. 3 of the present invention.
BTAC writes queue memory 144 and comprises that plural storage assembly 802 writes with the BTAC that stores Fig. 7 and require 176.In one embodiment, BTAC writes queue memory 144 and comprises that 6 storage assemblies 802 write and require 176 to store 6 BTAC, as shown in the figure.
BTAC writes queue memory 144 and also comprises a significance bit 804, is relevant to each BTAC and writes and require inlet point 802; If relevant inlet point is that effectively then significance bit 804 is true; If relevant inlet point is invalid, then significance bit 804 is false.
BTAC writes queue memory 144 and also comprises control logic circuit 806, is coupled to storage assembly 802 and significance bit 804.Control logic circuit 806 also is coupled to queue depth's buffer 146.Write when requiring 176 to be loaded on BTAC and to write queue memory 144 as a BTAC, control logic circuit 806 increases queue depths 146; Require 176 when BTAC writes queue memory 144 and shifts out when BTAC writes, control logic circuit 806 reduces queue depths 146.Control logic circuit 806 receives the BTAC that transmits from the storage stage 128 of Fig. 1 and writes and require signal 176 and the requirement that is received is stored in inlet point 802.Control logic circuit 806 also receives the branch mistake of Fig. 1 and surveys signal 152, and prediction replaces signal 154, instruction buffer is full up signal 156 and instruction high-speed cache idle signals 158.When queue depth 146 greater than 0 the time, it is the non-spacing wave 218 of BWQ of genuine Fig. 2 that control logic circuit 806 produces it.When the value when queue depth 146 equaled the total quantity (being 8 among the embodiment at Fig. 8) of inlet point 802, it was the full up signal 222 of BWQ of genuine Fig. 2 that control logic circuit 806 produces it.When control logic circuit 806 produced it and is the non-spacing wave 218 of genuine BWQ, control logic circuit 806 was located at the branch instruction address 702 that BTAC writes the oldest (or bottommost) inlet point 802 of queue memory 144 in the BWQ address signal 178 of Fig. 1.In addition, when control logic circuit 806 produced it and is the non-spacing wave 218 of genuine MWQ, the field 706-724 of Fig. 7 that control logic circuit 806 also writes BTAC the oldest (or bottommost) inlet point 802 of queue memory 144 was located in the BWQ data-signal 248.
Refer now to Fig. 9, Fig. 9 shows the operational flowchart that writes queue memory 144 according to the BTAC of Fig. 1 of the present invention.Flow process starts from determining piece 902.
At decision piece 902, BTAC writes queue memory 144 and whether equals BTAC by the queue depth 146 of decision Fig. 1 and write total inlet point quantity in the queue memory 144 whether decide BTAC to write queue memory 144 full up.If full up, flow process skips to piece 918 to upgrade BTAC142; Otherwise flow process skips to decision piece 904.
At decision piece 904, BTAC writes queue memory 144 by checking that this instruction cache idle signal 158 decides this instruction cache 104 of Fig. 1 whether idle.If idle, in case of necessity, flow process skips to decision piece 922 to upgrade BTAC142 because BTAC142 may not be read; Otherwise flow process skips to decision piece 906.
At decision piece 906, BTAC writes queue memory 144 by checking that the full up signal 156 of this instruction buffer decides the instruction buffer 106 of Fig. 1 whether full up.If full up, in case of necessity, flow process skips to decision piece 922 to upgrade BTAC142 because BTAC142 may not be read; Otherwise flow process skips to decision piece 908.
At decision piece 908, BTAC writes queue memory 144 by checking that this prediction replaces signal 154 and decides the BTAC142 branch prediction whether to be substituted.If in case of necessity, flow process skips to decision piece 922 to upgrade BTAC142 because BTAC142 may not be read; Otherwise flow process skips to decision piece 912.
At decision piece 912, BTAC writes queue memory 144 by check that this branch surveys signal 152 and decides the BTAC142 branch prediction whether to be corrected by mistake.If in case of necessity, flow process skips to decision piece 922 to upgrade BTAC142 because BTAC142 may not be read; Otherwise flow process skips to decision piece 914.
At decision piece 914, BTAC writes queue memory 144 decision and whether has produced this BTAC and write and require 176.If not, flow process skips back to decision piece 902; Otherwise flow process skips to piece 916.
At decision piece 916, BTAC writes queue memory 144 and loads these BTAC and write and require 176 and increase queue depth 146.This BTAC writes and requires 176 to be loaded on the invalid inlet point that BTAC writes the top of queue memory 144, and then this inlet point is denoted as effectively.Flow process skips back to decision piece 902.
At decision piece 918, BTAC writes the oldest or bottom inlet points that queue memory 144 utilizes BTAC to write in the queue memory 144 and upgrades BTAC142, and reduces queue depth 146.BTAC writes queue memory 144 then toward moving down an inlet point.Be set as BWQ address signal 178 by the value of the branch instruction address field 702 of Fig. 7 of old inlet point, and with the oldest BTAC write require 176 other partly be located at BWQ data-signal 248, BTAC writes the oldest inlet points that queue memory 144 utilizes BTAC to write in the queue memory 144 and upgrades BTAC142.In addition, BTAC writes queue memory 144 and sends it and be the moderator 202 of the non-spacing wave 218 to Fig. 2 of genuine BWQ.If flow process skips to piece 918 from decision piece 902, BTAC writes queue memory 144 and also sends it and be the moderator 202 of the full up signal 2228 to Fig. 2 of genuine BWQ.Flow process skips to decision piece 914 from piece 918.
Be noted that if in BTAC reading requirement signal 212 is also during pending BTAC writes queue memory 144 and sends the full up signal 222 of this BWQ and this moderator 202 and allow BTAC to write queue memory 144 access BTAC142; Then BTAC142 will fall through, if but the actual target address of the branch instruction that BTAC142 predicted is present in the specified cache line in present acquisition address 162 in the BTAC142, and this falls through is that puppet is fallen through.Yet advantageously, by under most situation the write latency of BTAC142 not being read to BTAC142, BTAC writes the possibility that puppet that queue memory 144 can reduce BTAC142 is fallen through, as shown in Figure 9.
At decision piece 922, whether control logic circuit 806 equals 0 by decision queue depth 146 determines whether that BTAC writes queue memory 144 for empty.If flow process skips to decision piece 914; Otherwise flow process skips to decision piece 922 to upgrade BTAC142 because BTAC142 may not be read.
Refer now to Figure 10, Figure 10 shows according to the block diagram with the logical circuit of unnecessary destination address ineffective treatment in this BTAC in this microprocessor 100 of Fig. 1 of the present invention.
Microprocessor 100 also comprises control logic circuit 1014, is coupled to comparer 1012, and this circuit 1014 receives matched signal 1006 and useful signal 1004.If the selected instruction set of label array 304 in have and multidirectionally have its matched signal 1006 and be the significance bit 1004 of true value with at least one for true value, then control logic circuit 1014 stores a true value in unnecessary TA sign buffer 1024, is stored in the BTAC142 with the more than one actual target address of representing same branch instruction.In addition, control logic circuit 1014 makes address 182 load as in the unnecessary TA Address Register 1026.At last, control logic circuit 1014 loads unnecessary TA invalid data to unnecessary TA invalid data buffer 1022.In one embodiment, be stored in data in the unnecessary TA invalid data buffer 1022 and write similar in appearance to the BTAC of Fig. 7 and require 176, except not storing branch instruction address 702, because the address of this branch instruction is to be stored in the unnecessary TA Address Register 1026; And also do not store destination address 706, start bit 708 is and across position 712, because it is inessential in invalid BTAC142 inlet point; Thereby when carrying out unnecessary TA ineffective treatment, destination address array 302 can not be written into, and has only label array 304 to be updated with invalid this unnecessary BTAC142 inlet point.The output of this unnecessary TA invalid data buffer 1022 comprises the unnecessary TA invalid data signal 244 of Fig. 2.The output of this unnecessary TA sign buffer 1024 comprises that the unnecessary TA of Fig. 2 requires 214.The output of this unnecessary TA Address Register 1026 comprises the unnecessary TA address 234 of Fig. 2.In one embodiment, be stored in this unnecessary TA invalid data buffer 1022 with should be unnecessary the table 2 of interior these the generation equatioies of TA sign buffer 1024 below being shown in to value 724.In table 2, significance bit [3] comprises the logic OR result of A significance bit [3] 504 and B significance bit [3] 506; Significance bit [2] comprises the logic OR result of A significance bit [2] 504 and B significance bit [2] 506; Significance bit [1] comprises the logic OR result of A significance bit [1] 504 and B significance bit [1] 506; And significance bit [0] comprises the logic OR result of A significance bit [0] 504 and B significance bit [0] 506.
RedundantInvalWay[3]=(valid[3]&match[3])&((valid[0]&match[0])|(valid[1]&match[1])|(valid[2]&match[2]));
RedundantInvalWay[2]=(valid[2]&match[2])&((valid[0]&match[0])|(valid[1]&match[1]));
RedundantInvalWay[1]=(valid[1]&match[1])&(valid[0]&match[0]);
RedundantInvalWay[0]=0; / * Way 0 be disabled never */
RedundanInAFlag=((valid[3]&match[3])&(valid[2]&match[2]))|
((valid[3]&match[3])&(valid[1]&match[1]))|
((valid[3]&match[3])&(valid[0]&match[0]))|
((valid[2]&match[2])&(valid[1]&match[1]))|
((valid[2]&match[2])&(valid[0]&match[0]))|
((valid[1]&match[1])&(valid[0]&match[0]));
Proper handling for the invalid logical circuit of unnecessary destination address that makes Figure 10 as shown in figure 11, is implemented as example with a string instruction and does explanation, and it can produce the unnecessary destination address inlet point of same branch instruction in BTAC142.
First of Fig. 1 captures address 162 at present and inputs to instruction cache 104 and BTAC142.First captures address 162 selected cache lines at present comprises a branch instruction, is called branch-A.First captures the instruction set that address 162 is selected in the BTAC142 at present, is called instruction set N.The inside neither one label 1002 of instruction set N is matched with first and captures address 162 at present; Therefore, BTAC142 produces and falls through.In this example, not the using at most to being 2 of l ru value 508 representatives.Therefore, down send along streamline about the information system of the renewal BTAC142 of branch-A, together with representative to the 2 branch-A that must be updated.
Then, import one second and capture address 162 at present to this instruction cache 104 and BTAC142.Capture address 162 selected cache lines at present by second and comprise a branch instruction, be called branch-B.Second at present acquisition address 162 also selection instruction collect N and hit in instruction set N 3 to; Then, BTAC142 generation one is hit.In addition, the lru value 508 of BTAC142 update instruction collection N be 1 to.
Then because branch-A is the some of tight loop of sign indicating number, import once more this first at present acquisition address 162 to this instruction cache 104 and BTAC142, and selection instruction collection N once more.Because carry out the storage stage 128 of no show Fig. 1 the first time of branch-A, BTAC142 does not utilize the destination address of branch-A to do renewal.Then, BTAC142 produces once more and falls through.Yet, not the using at most of this lru value 508 indications to being 1, because lru508 is updated in response to hitting of branch-B.Therefore, be down to send about the information of the renewal BTAC142 that carries out branch-A for the second time along streamline, carry out to the second time of the 1 branch-A that must be updated together with representative.
Then, this first branch-A arrive this storage stage 128 and produce a BTAC write require 176 with the destination address of utilizing branch-A come update instruction collection N to 2, this will carry out in follow-up.
Then, this second branch-A arrive this storage stage 128 and produce a BTAC write require 176 with the destination address of utilizing branch-A come update instruction collection N to 1, this will carry out in follow-up.Therefore, same branch instruction, branch-A, two effective inlet points be present in the BTAC142.One of these inlet points be unnecessary and the use that causes BTAC142 than inefficiency, because this unnecessary inlet point can be used by another branch instruction and/or the actual target address of another branch instruction that can account for.
Refer now to Figure 11, Figure 11 shows the operational flowchart according to the unnecessary destination address device of Figure 10 of the present invention.Flow process starts from piece 1102.
At piece 1102, moderator 202 allows the access of 212 couples of BTAC142 of BTAC reading requirement of Fig. 2, cause multiplexer 148 select acquisition address 162 at present with on the address signal 182 of being located at Fig. 1 and the control signal 252 that produces Fig. 2 to represent reading of BTAC142.Then, the low-order bit that captures address 162 at present passes through the index that the instruction set of selecting BTAC142 is treated as in address 182.Flow process continues to piece 1104.
At piece 1104,4 of all of the instruction set of comparer 1012 more selected BTAC142 to label 1002 and the high-order position of being located at the present acquisition address 162 on the address signal 182 of Figure 10 to produce the matched signal 1006 of Figure 10.Control logic circuit 1014 receives the matched signal 1006 and significance bit 1004 of Figure 10.Flow process continues to piece 1106.
At piece 1106, whether control logic circuit 1014 decisions more than one effective tag match takes place.That is according to significance bit 1004 and matched signal 1006, whether control logic circuit 1014 decisions have the interior Xiang Youyi more than 2 of instruction set of present acquisition address 162 selected BTAC142 effectively to mate label 1002.If flow process continues to piece 1108; Otherwise flow process finishes.
At piece 1108, control logic circuit 1014 stores a true value in unnecessary TA sign buffer 1024, stores address 182 in unnecessary TA Address Register 1026, and stores invalid data in unnecessary TA invalid data buffer 1022.Particularly, control logic circuit 1014 store its for the writing activation A field 714, write activation B field 716 of true value, invalid A field 718 and invalid B field 722 in unnecessary TA invalid data buffer 1022.In addition, control logic circuit 1014 will be stored in unnecessary TA invalid data Address Register 1022 according to the value to field 724 of the described table 2 of Figure 10.Flow process continues to piece 1112.
At piece 1112, moderator 202 allows the unnecessary TA of Fig. 2 to require the access of 214 couples of BTAC142, causes multiplexer 148 to select control signal 252 the writing with indication BTAC142 of unnecessary TA address 234 to be located on the address signal 182 and to produce Fig. 2.Then, the low-order bit of unnecessary TA address 234 is treated as the index of the instruction set of selecting BTAC142 by address 182.BTAC142 receive redundant data signal 244 that unnecessary TA data buffer 1022 exported and with in the selected instruction set to pointed these of field 724 to ineffective treatment.Flow process ends at piece 1112.
Refer now to Figure 12, Figure 12 shows the block diagram of avoiding logical circuit according to the fast knot in this microprocessor 100 of the present invention.
The BTAC142 of Figure 12 displayed map 1, instruction cache 104, instruction buffer 106, instruction normalizer 108, normalization back instruction queue 112 and multiplexer 136, and the control logic circuit 1014 of Figure 10.
As Figure 12, microprocessor 100 also comprises a fast knot invalid data buffer 1222, one fast knot sign buffers 1224, with a fast knot Address Register 1226.
The decoding of instruction normalizer 108 is stored in the instruction in this instruction buffer 106, and if instruction normalizer 108 decipher out branch instruction across two high speed cache lines, then produce it and be genuine F_wrap signal 1202.Particularly, when instruction normalizer 108 is deciphered out branch instruction across two high speed cache lines, in case deciphered out this first part of one in one first cache line that is stored in the instruction buffer 106 across branch instruction, though instruction normalizer 108 whether deciphered in this second cache line that is not stored in as yet in the instruction buffer 106 should across branch instruction other partly, it is genuine F_wrap signal 1202 that instruction normalizer 108 produces it.F_wrap signal 1202 inputs to control logic circuit 1014.
When present acquisition address 162 fell through, instruction cache 104 was produced as the signal 1206 that falls through of true value.The signal 1206 that falls through inputs to control logic circuit 1014.
When predict the present acquisition address 162 that inputs to instruction cache 104, that is, when present acquisition address 162 is a predictability address, it is a prediction signal 1208 of true value that instruction cache 104 produces it, is when capturing address 162 at present such as select BTAC predicted target address 164 when multiplexer 136.Prediction signal 1208 inputs to instruction cache 104.In one embodiment, instruction cache 104 is delivered to prediction signal 1208 the instruction acquisition device 102 of Fig. 1, make call instruction acquisition device 102 abandon capturing the cache line that falls through in instruction cache 104 from the forecast memory address of storer, reason will be described below with reference to Figure 13.
BTAC142 produces one and carry out/does not carry out (T/NT) signal 1212, and it exports control logic circuit 1014 to.It is represented address 182 for the T/NT signal 1212 of true value and hits in BTAC142, represent BTAC142 to predict that a branch instruction is included in the cache line that is provided by instruction cache 104 in response to capturing address 162 at present, represent this branch instruction to be performed, and represent BTAC142 that the destination address of branch instruction is located on the BTAC predicted target address signal 164.BTAC142 produces T/NT signal 1212 according to the predicted state A 602 of Fig. 6 or the value of predicted state B 604, depends on that this BTAC142 is to use A or B partly when branch prediction.
BTAC142 also produces B_wrap signal 1214, exports control logic circuit 1014 to.The value across position 406 of Fig. 4 of selected BTAC destination address array inlet point 312 is to be set as B_wrap signal 1214.Therefore, the representative of the puppet value of B_wrap signal 1214, BTAC142 predicts into this branch instruction and is not across two high speed cache lines.In one embodiment, control logic circuit 1014 temporary B_wrap signals 1214 are to keep from the value of the B_wrap signal 1214 of previous BTAC142 access gained.
If control logic circuit 1014 detect the fast knot state (that is, the B_wrap signal 1214 of being kept in is pseudo-value, be true value with F_wrap signal 1202, the signal 1206 that falls through with prediction signal 1208), this will describe in detail below, then control logic circuit 1014 stores a true value has the fast knot state now to represent in a fast knot sign buffer 1224, make that the inlet point in the BTAC142 that causes the fast knot state is disabled.In addition, control logic circuit 1014 loads the fast knot invalid data to fast knot invalid data buffer 1222.In one embodiment, being stored in data in the fast knot invalid data buffer 1222 writes similar in appearance to the BTAC of Fig. 7 and requires 176; Except not storing branch instruction address 702, because the address of this branch instruction is stored in the fast knot Address Register 1226; And do not store destination address 706, start bit 708 with across position 712 because in an invalid BTAC142 inlet point, these positions are inessential; Thereby when carrying out the fast knot ineffective treatment, destination address array 302 is not written into, and has only label array 304 to be updated inlet point ineffective treatment with the BTAC142 that will survey by mistake.The output of fast knot invalid data buffer 1222 comprises the fast knot data-signal 246 of Fig. 2.The output of fast knot sign buffer 1224 comprises that the fast knot of Fig. 2 requires 216.The output of fast knot Address Register 1226 comprises the fast knot address 236 of Fig. 2.Being stored in the fast knot invalid data buffer 1222 this is to inserting by this of this BTAC142 that causes this fast knot state to value 724.
If control logic circuit 1014 detects the fast knot state, then after will surveying the inlet point ineffective treatment by mistake, control logic circuit 1014 also produces one and is worth on control signal 1204 so that this multiplexer 1306 selects these present instruction pointers 168 to cause the branch of microprocessor 100, makes to comprise that this mistake surveys this cache line of branch instruction and can be captured once more.
Refer now to Figure 13, Figure 13 shows the operational flowchart of avoiding logical circuit according to the fast knot of Figure 12 of the present invention.Flow process starts from piece 1302.
At piece 1302, capturing address 162 at present is to input to instruction cache 104 via address signal 182 and input to BTAC142.In Figure 13, this captures address 162 at present and is called acquisition address A.Flow process continues to piece 1304.
At piece 1304, instruction cache 104 will capture the specified cache line of address A (being called cache line A) and provide to instruction buffer 106, and cache line A comprises first part of branch instruction, comprises the whole of this branch instruction but there is no.Flow process continues to piece 1306.
At piece 1306, in response to acquisition address A, branch instruction in the BTAC142 predictive cache line A will be performed and be located on the T/NT signal 1212, be produced as the B_wrap signal 1214 of pseudo-value, and a predicted target address is located on the BTAC predicted target address 164.Flow process continues to piece 1308.
At piece 1308, control logic circuit 1014 control multiplexers 136 serve as next acquisition at present address 162 to select BTAC predicted target address 164, are called acquisition address B.Control logic circuit 1014 also is produced as the prediction signal 1208 of true value, because BTAC predicted target address 164 is predictability.Flow process continues to piece 1312.
At piece 1312, instruction cache 104 is produced as the signal 1206 that falls through of true value to represent branch address B system to fall through in instruction cache 104.Under the normal condition, instruction acquisition device 102 may capture this cache line that falls through from storer; Yet because prediction signal 1208 is true, instruction normalizer 108 not storer captures this cache line that falls through, and reason will be described below.Flow process continues to piece 1314.
At piece 1314, the cache line A in the instruction normalizer 108 translation instruction impact dampers 106 also is produced as the F_wrap signal 1202 of true value, because this branch instruction is across two high speed cache lines.Instruction normalizer 108 is waited for next cache line that will be stored in the instruction buffer 106, make its can finish to the normalization of branch instruction with will export normalization back instruction queue 112 to.Flow process continues to piece 1316.
At piece 1316, control logic circuit 1014 decisions: whether the B_wrap signal 1214 of being kept in is pseudo-value, and whether F_wrap signal 1202 is true value, and whether the signal 1206 that falls through is whether true value and prediction signal 1208 are true value; This has comprised following described fast knot state.If flow process continues to piece 1318; Otherwise flow process finishes.
At piece 1318, control logic circuit 1014 will cause this BTAC142 inlet point ineffective treatment of fast knot state, as described in reference Figure 12.Then, in the time will capturing address A and input to BTAC142 next time, BTAC142 will produce one and fall through, because existing being disabled of this inlet point that causes the fast knot state.Flow process continues to piece 1322.
At piece 1322, control logic circuit 1014 control multiplexers 136 are to branch to present instruction pointer 168, as the description of reference Figure 12.In addition, when this multiplexer 136 of control logic circuit 1014 control was selected present instruction pointer 168, control logic circuit 1014 produced the prediction signal 1208 that it be pseudo-value, because present instruction pointer 168 is not the predictability storage address.Instruction pointer 168 can hit in instruction cache 104 at present probably; Yet if recklessly, instruction acquisition device 102 will capture the specified cache line of present instruction pointer 168 from storer, because the present instruction pointer 168 of prediction signal 1208 representatives is not a predictability.Flow process ends at piece 1322.
If decision piece 1316 is a true time, the reason that has the fast knot state is, causes the necessary situation of fast knot to exist.First situation that causes fast knot is the multibyte branch instruction that is across two different cache lines.That is first of this branch instruction byte partly is the tail end that is positioned at first cache line, and the second part system of this branch instruction byte is positioned at the beginning of next cache line.Because possibility across branch instruction, this BTAC142 is essential to store prediction one branch instruction whether across the information of cache line, makes control logic circuit 1014 learn and whether will capture next cache line just to obtain the Lower Half of branch instruction byte before the cache line that is positioned at destination address 164 in acquisition.If BTAC142 has stored wrong information of forecasting, BTAC142 may be predicted as mistakenly this branch instruction not across, but in fact have across.Under this example, this instruction normalizer 108 will be utilized the first half of branch instruction to decipher this cache line and detect and have a branch instruction, but be not that whole bytes of branch instruction can be used for decoding.This instruction normalizer 108 can be waited for next cache line.This streamline can be waited for always will be by the execution of normalized more multiple instruction to incite somebody to action.
Cause second situation of fast knot situation to be, because this BTAC142 predicts that this branch instruction is not across, the cache line (there is no next cache line of acquisition) that the destination address 164 of this BTAC142 output of this branch control logic circuit 1014 acquisitions is inferred.Yet this destination address 164 is fallen through in this instruction cache 104.Therefore, next cache line of being waited for of this instruction normalizer 108 must capture from storer.
Cause the 3rd situation of fast knot situation to be, the chipset of microprocessor there is no to be anticipated to have in some memory address range and captures instruction, if and this microprocessor is when unexpected memory address range produces the instruction acquisition, the chipset of microprocessor may make that system is idle or produce other bad system situation.The instruction acquisition such as the destination address 164 that BTAC142 exported, may be caused from unexpected memory address range in the predictability address.Thereby, a predictability BTAC predicted target address 164 acquisition one of this microprocessor 100 and the storer of the having no way of cache line that falls through.
Therefore, other of instruction normalizer 108 and streamline partly waited for another cache line.Simultaneously, these instruction acquisition device 102 these streamlines of wait will be carried out a nonanticipating acquisition to inform.Under non-fast knot situation, such as, if this destination address 164 is hit in instruction cache 104, branch instruction after instruction normalizer 108 can be standardized branch instruction (though being to utilize incorrect byte) and will standardize provides the execute phase to branch, execute phase can detect the mistake survey and the mistake of BTAC142 is surveyed corrigendum, thereby makes this prediction signal 1208 become pseudo-value.Yet under the fast knot situation, this execution will can't detect mistake forever and survey, because the branch instruction after instructing normalizer 108 will not standardize provides the execute phase to branch, because instruction normalizer 108 is still being waited for next cache line.Therefore, the fast knot situation takes place.Yet the fast knot of Figure 12 avoids logical circuit can effectively avoid the generation of fast knot situation, as described in Figure 12 and Figure 13, but thereby makes microprocessor 100 proper handlings.
Though described the present invention and its purpose in detail, feature and advantage, the present invention still can comprise other embodiment.Such as, though writing queue memory, this is relevant to single port BTAC, in some microprocessor architecture design, puppet is fallen through and also may be betided among the multiport BTAC, although frequency is lower.Therefore, can use this and write queue memory with the puppet that the reduces multiport BTAC rate of falling through.In addition, in not reading some microprocessor of BTAC, may also have except other situation this description situation, wherein the requirement of formation in this writes queue memory can write to BTAC.
In addition, though described the present invention and its purpose in detail, feature and advantage, the present invention still can comprise other embodiment.Except utilizing hardware to implement the present invention, present invention may also be implemented in computing machine can use computer readable code in formula (such as, the readable formula) medium (such as, computer readable program code, data etc.).Computer code can be finished disclosed function of the present invention or manufacturing or both and all can.Such as, can utilize the general procedure language (such as, C, C++, JAVA etc.); The GDSII database; (hard description language HDL), comprises Verilog HDL to hardware description language, VHDL, AlteraHDL (AHDL) etc.; Or existing other program and/or circuit (that is summary formula) acquisition instrument.Computer code can load on and comprise semiconductor memory, disk, CD (such as, CD-ROM, DVD-ROM etc.) any known computer can use in formula (such as, the readable formula) medium; And be implemented on computing machine with the form of computer data signal and can use formula (such as, readable formula) transmission medium (, or comprising numeral, other medium of optics or analog medium) such as, carrier wave.Therefore, computer code can be transmitted in and comprise on the Internet and enterprise network (instruction tranet) communication network.Know, invention can be implemented in computer code (, such as being microcontroller core, or being system level design) and the part hardware that converts integrated circuit to such as system single chip (SOC) such as, the some of IP (the intelligence ownership of property) core.In addition, present invention may be embodied in the combination of hardware and computer code.
Though the present invention discloses as above with a preferred embodiment; right its is not in order to limit the present invention; those skilled in the art can do some changes and retouching under the premise without departing from the spirit and scope of the present invention, so protection scope of the present invention is looked accompanying Claim and is as the criterion.
Claims (8)
1. one kind writes queue memory, improves the efficient of the branch target address caching in the microprocessor, and this writes queue memory and comprises:
One requires input end, receives one and requires to upgrade this branch target address caching, and this requirement comprises a branch instruction destination address;
A plurality of storage assemblies store these requirements that this requires input end to receive;
Control logic circuit is coupled to these storage assemblies, will be stored in these storage assemblies these in response to one or more both stable condition and one of require to write to this branch target address caching;
The one high-speed cache input end that leaves unused, be coupled to this control logic circuit, when one instruction cache of access is idle when being parallel to this branch target address caching, these one or more both one of stable condition of specifying this branch target address caching not to be read;
The full up input end of one impact damper, be coupled to this control logic circuit, because an instruction buffer is full up, these one or more both one of stable condition that it specifies this branch target address caching not to be read, wherein this instruction cache of this instruction buffer access from being parallel to this branch target address caching receives instruction;
One prediction replaces input end, be coupled to this control logic circuit, because one second branch instruction predictions that one first branch instruction predictions that this branch target address caching is finished is finished by the branch prediction logic in this microprocessor replaces, these one or more both one of stable condition that it specifies this branch target address caching not to be read;
One branch mistake is surveyed input end, is coupled to this control logic circuit, finishes the survey of branch instruction mistake, these one or more both one of stable condition that it specifies this branch target address caching not to be read because detect this branch target address caching; And
The full up input end of one formation is coupled to this control logic circuit, and specifying whole storage assemblies is just to store these one or more both one of stable condition that require to this branch target address caching to be written.
2. the queue memory that writes as claimed in claim 1 also comprises:
A plurality of significance bits are coupled to this control logic circuit, and whether this requirement that each significance bit indication is stored in the corresponding storage assembly is effective.
3. the queue memory that writes as claimed in claim 1, wherein this requirement also comprises a storage address of this branch instruction.
4. the queue memory that writes as claimed in claim 1, wherein this branch target address caching be a N one to the instruction set associative cache, wherein this requirement also comprise specify this requirement be to write in this branch target address caching this N to which to information.
5. microprocessor comprises:
One instruction cache provides a cache line of command byte in response to an instruction acquisition address;
One branch target address caching is coupled to this instruction cache, and prediction is stored in a branch target address of the branch instruction in this cache line;
One writes queue memory, is coupled to this branch target address caching, stores the branch target address that is used to upgrade this branch target address caching;
One branch prediction logic, be coupled to this and write queue memory, wherein after this branch target address caching is finished one first prediction of a branch instruction, this branch prediction logic is finished one second prediction of this branch instruction, and wherein this microprocessor utilizes this second prediction to replace this first prediction; And
One branch's decision logic circuit is coupled to this and writes queue memory, corrects a mistake of the branch instruction that this branch target address caching finishes and surveys; Wherein
If this writes queue memory is not empty, when this instruction cache is in when idle, then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching;
If this writes queue memory is not empty, when this instruction buffer indicates that it is when full, then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching, zero or a plurality of cache lines that this instruction buffer storage receives from this instruction cache;
If this writes queue memory is not empty, when utilizing this second prediction, this microprocessor replaces this first when prediction, and then this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching;
If this writes queue memory is not empty, when this mistake of proofreading and correct this branch instruction that this branch target address caching finishes when this microprocessor was surveyed, this write queue memory and utilizes one of these branch target address to upgrade this branch target address caching;
Become full uply if this writes queue memory, this writes queue memory and utilizes one of these branch target address to upgrade this branch target address caching.
6. microprocessor as claimed in claim 5, when wherein this write queue memory and is writing this branch target address caching, if this branch target address caching is read, this branch target address caching produced one and falls through.
7. method of upgrading the branch target address caching in the microprocessor, this method comprises the following steps:
Producing one requires to upgrade this branch target address caching;
Storing this requires in a formation;
Determine because of an instruction cache that is coupled to this branch target address caching is idle whether this branch target address caching is not read, if this branch target address caching is not read, then upgrade this branch target address caching according to this requirement;
Determine because of an instruction buffer is full up whether this branch target address caching is not read, if this branch target address caching is not read, then upgrade this branch target address caching according to this requirement, wherein this instruction buffer receives the instruction of exporting from this instruction cache;
One second branch instruction predictions whether one first branch instruction predictions that determines this branch target address caching to finish is finished by other branch prediction logic in this microprocessor replaces,
If this first branch instruction predictions that this branch target address caching is finished is replaced by this second branch instruction predictions, then upgrade this branch target address caching according to this requirement;
Determine whether this branch target address caching surveys a branch instruction by mistake;
If this branch target address caching is surveyed a branch instruction by mistake, then upgrade this branch target address caching according to this requirement;
Determine whether this formation is full up,
If this formation is full up, then upgrade this branch target address caching according to this requirement.
8. method as claimed in claim 7, the step of wherein upgrading this branch target address caching are to be executed in a time clock of this microprocessor after this storing step in the cycle.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US44006503P | 2003-01-14 | 2003-01-14 | |
US60/440,065 | 2003-01-14 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1542625A CN1542625A (en) | 2004-11-03 |
CN1282930C true CN1282930C (en) | 2006-11-01 |
Family
ID=34375165
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004100018088A Expired - Lifetime CN1282930C (en) | 2003-01-14 | 2004-01-14 | Apparatus and method for efficiently updating branch target address cache |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN1282930C (en) |
TW (1) | TWI283827B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103870249B (en) * | 2014-04-01 | 2017-08-25 | 龙芯中科技术有限公司 | IA acquisition methods and instant compiler |
CN106227676B (en) * | 2016-09-22 | 2019-04-19 | 大唐微电子技术有限公司 | A kind of cache and the method and apparatus that data are read from cache |
CN111459551B (en) * | 2020-04-14 | 2022-08-16 | 上海兆芯集成电路有限公司 | Microprocessor with highly advanced branch predictor |
CN111459550B (en) * | 2020-04-14 | 2022-06-21 | 上海兆芯集成电路有限公司 | Microprocessor with highly advanced branch predictor |
CN112181497B (en) * | 2020-09-28 | 2022-07-19 | 中国人民解放军国防科技大学 | Method and device for transmitting branch target prediction address in pipeline |
-
2004
- 2004-01-08 TW TW093100409A patent/TWI283827B/en not_active IP Right Cessation
- 2004-01-14 CN CNB2004100018088A patent/CN1282930C/en not_active Expired - Lifetime
Also Published As
Publication number | Publication date |
---|---|
TWI283827B (en) | 2007-07-11 |
TW200414034A (en) | 2004-08-01 |
CN1542625A (en) | 2004-11-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1632877A (en) | Variable latency stack cache and method for providing data | |
CN1254739C (en) | Branch instruction for processor architecture | |
CN1934543A (en) | Cache memory and control method thereof | |
CN1291311C (en) | Device and method for selectively covering return godown to respond the detection of non-standard return sequence | |
EP1624369B1 (en) | Apparatus for predicting multiple branch target addresses | |
CN1141647C (en) | Method and apparatus for aliasing memory data in advanced microprocessor | |
CN1217262C (en) | Appts. and method for replacing target address in imaginary branch target address high speed buffer storage | |
CN1296827C (en) | Method and equipment for reducing execution time in set associative cache memory with group prediction | |
CN1629801A (en) | Pipeline type microprocessor, device and method for generating early stage instruction results | |
CN1121014C (en) | Eight-bit microcontroller having a RISC architecture | |
CN1658154A (en) | Pipeline work micro processor, apparatus and method for performing early correction of conditional branch instruction mispredictions | |
CN1742257A (en) | Data speculation based on addressing patterns identifying dual-purpose register | |
CN1217271C (en) | Imaginary branch target address high speed buffer storage | |
CN1619511A (en) | Microprocessor and apparatus for performing fast speculative load operation | |
CN1387641A (en) | Execution of multiple threads in parallel processor | |
CN1296224A (en) | Method and device for caculating page table index from virtual address | |
CN1387644A (en) | SDRAM controller for parallel processor architecture | |
CN1879092A (en) | Cache memory and control method thereof | |
CN1397887A (en) | Virtual set high speed buffer storage for reorientation of stored data | |
KR20150066526A (en) | Reducing cold tlb misses in a heterogeneous computing system | |
CN1476559A (en) | Data processing apparatus and method for saving return state | |
CN1967506A (en) | Merging entries in processor caches | |
CN1397874A (en) | Appts. and method for quick fetching line selecting target address of high speed buffer storage | |
CN1194321C (en) | High-speed information search system | |
CN1898654A (en) | Cache memory and its controlling method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CX01 | Expiry of patent term |
Granted publication date: 20061101 |
|
CX01 | Expiry of patent term |