KR100445054B1 - Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state - Google Patents
Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state Download PDFInfo
- Publication number
- KR100445054B1 KR100445054B1 KR1019960026521A KR19960026521A KR100445054B1 KR 100445054 B1 KR100445054 B1 KR 100445054B1 KR 1019960026521 A KR1019960026521 A KR 1019960026521A KR 19960026521 A KR19960026521 A KR 19960026521A KR 100445054 B1 KR100445054 B1 KR 100445054B1
- Authority
- KR
- South Korea
- Prior art keywords
- branch
- reorder buffer
- unique number
- instruction
- microprocessor
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 13
- 239000000872 buffer Substances 0.000 claims abstract description 31
- 238000003672 processing method Methods 0.000 claims description 2
- 238000011084 recovery Methods 0.000 abstract description 10
- 238000010586 diagram Methods 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30003—Arrangements for executing specific machine instructions
- G06F9/3005—Arrangements for executing specific machine instructions to perform operations for flow control
- G06F9/30058—Conditional branch instructions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30003—Arrangements for executing specific machine instructions
- G06F9/30072—Arrangements for executing specific machine instructions to perform conditional operations, e.g. using predicates or guards
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)
Abstract
Description
본 발명은 마이크로프로세서(Microprocessor)의 브랜치(branch) 처리를 위한 장치 및 그 방법에 관한 것으로, 잘못 예측된 브랜치 처리시 브랜치 이전 상태로 용이하게 복구할 수 있는 장치 및 방법에 관한 것이다. 이크로프로세서의 성능향상을 위해 여러 방식들이 채용되고 있는데, 그중 대표적인 것이 브랜치 예측 기술과 명령(instruction) 실행을 원래 프로그램순서에 상관없이 실행하는 아웃-오브-오더(out-of-order) 실행 기술이다.The present invention relates to an apparatus and method for branch processing of a microprocessor, and more particularly, to an apparatus and a method for easily recovering to a pre-branch state during a mispredicted branch processing. Several methods are employed to improve the performance of microprocessors, including the branch prediction technique and the out-of-order execution technique that executes instruction execution regardless of the original program order. .
이 두가지 기술이 동시에 사용될 때는 잘못 예측된 브랜치 처리를 위해서 브랜치 이전 상태로 복구하는 것이 어려워진다.When both techniques are used at the same time, it becomes difficult to recover to the pre-branch state for mispredicted branch processing.
즉, 잘못 예측된 브랜치 발생시에는 브랜치 이전에 수행되어야 할 명령들은 모두 완료하고 원래는 브랜치 이후에 수행되었어야 하지만 아웃-오브-오더 실행에 의해 미리 끝나버린 명령은 모두 무효화해야 하며, 그 다음에 다시 올바른 브랜치 타겟으로부터 명령을 가져와 수행하여야 한다. 이러한 절차를 브랜치 예측 미스(misprediction)시 리커버리(recovery)라고 한다.In other words, when a mispredicted branch occurs, all instructions that must be executed before the branch must be completed and originally executed after the branch, but all instructions that have already been completed by out-of-order execution must be invalidated, and then again. You need to get the instructions from the correct branch target. This procedure is called recovery in branch prediction misprediction.
종래에는 브랜치 명령마다 명령의 수행순서를 쉽게 파악할 수 없어 잘못 예측된 브랜치 처리시 브랜치 이전 상태로의 리커버리가 용이하지 않아 리커버리 미스의 문제점이 다수 발생되었다.In the related art, the order of execution of instructions is not easily understood for each branch instruction, and recovery of the branch to the previous branch state is not easy during mis-predicted branch processing.
본 발명은 명령 디코딩시 브랜치 명령마다 브랜치 고유번호(ID)를 부여하고 이를 통하여 명령의 수행순서를 쉽게 파악할 수 있어 잘못 예측된 브랜치 처리시 브랜치 이전 상태로 용이하게 리커버리 할 수 있는 마이크로프로세서에서의 브랜치 처리 방법을 제공하는데 그 목적이 있다.According to the present invention, a branch unique number (ID) is assigned to each branch instruction when decoding the instruction, and the order of execution of the instruction can be easily understood through this. Its purpose is to provide a treatment method.
상기 목적을 달성하기 위한 본 발명은 다수의 명령을 프로그램 순서대로 받아들이는 디코더, 다수의 명령 결과가 프로그램 순서에 관계없이 완료되어 저장된 리오더 버퍼 및 브랜치 명령을 수행하는 브랜치 실행부를 구비하는 마이크로프로세서에서 브랜치 처리 방법에 있어서, 상기 리오더 버퍼 및 브랜치 실행 장치에 브랜치 고유번호를 부여하되 다음 브랜치 명령전까지 해당 브랜치 명령 이후에 오는 모든 명령은 같은 고유번호를 갖도록 하는 단계; 브랜치 예측 미스시 상기 브랜치 실행 장치로 부터의 브랜치 고유번호와 상기 리오더 버퍼에 할당된 브랜치 고유번호를 비교하여, 고유번호가 서로 같지 않은 동안은 해당 명령을 완료할때까지 기다렸다가 레지스터 파일을 업데이트시키고, 고유번호가 같은 명령이 나타나자마자 그 이후의 모든 명령은 완료 여부에 관계없이 디스카드시키며 리오더 버퍼를 포함한 마이크로 프로세서의 모든 내부 장치를 클리어시키는 단계; 및 정상적인 브랜치 타겟에 근거하여 새로운 실행을 수행하는 단계를 포함하여 이루어지는 것을 특징으로 한다.The present invention for achieving the above object is a branch in a microprocessor having a decoder for accepting a plurality of instructions in a program order, a branch execution unit for executing a branch instruction and a reorder buffer stored in which the plurality of instruction results are completed regardless of the program order A processing method comprising: assigning a branch unique number to the reorder buffer and a branch execution device, such that all instructions following the branch instruction until the next branch instruction have the same unique number; When a branch misses, the branch unique number from the branch execution device is compared with the branch unique number assigned to the reorder buffer, and while the unique numbers are not the same, wait until the command is completed and update the register file. As soon as a command with the same unique number appears, discarding all subsequent commands regardless of whether they have completed and clearing all internal devices of the microprocessor including the reorder buffer; And performing a new execution based on the normal branch target.
그리고, 상기 리오더 버퍼 및 브랜치 실행 장치에 할당된 고유번호를 브랜치 명령이 수행되는 유지하는 것을 특징으로 한다.The branch command is performed by maintaining a unique number assigned to the reorder buffer and the branch execution device.
이하, 첨부된 도면 제 1 도를 참조하여 본 발명의 일실시예를 상세히 설명한다.Hereinafter, an embodiment of the present invention will be described in detail with reference to FIG. 1.
리절베이션 스테이션(Reservation station)을 이용한 일반적인 아웃-오브-오더 실행을 하는 슈퍼스칼라 프로세스(superscalar processor)의 구조에서, 명령 디코딩(decoding)시 결과를 생성하는 명령에 대해서는 리오더 버퍼(Reorder buffer)의 한 엔트리(entry)를 할당하고 이 명령이 여러 실행 장치(execution unit)중 하나에서 완료되면 그 결과로 리오더 버퍼를 업데이트(update) 시킨다. 리오더 버퍼내의 해당 엔트리는 브랜치 예측 미스에 의한 디펜던시(dependency)가 완전히 사라지면 레지스터 파일(Register file)을 업데이트하고 진정한 명령수행 완료가 이루어진다. 일단 레지스터 파일에 업데이트된 후에는 리커버리가 불가능하므로 아직 리오더 버퍼에 있을 동안 브랜치 예측 미스에 의한 리커버리 여부를 확인 완료해야 한다.In the structure of a superscalar processor that performs normal out-of-order execution using a retention station, one of the reorder buffers for instructions that produce a result upon instruction decoding is used. Allocate an entry and update the reorder buffer as a result when this command completes on one of several execution units. This entry in the reorder buffer updates the register file and completes true instruction execution once the dependency caused by branch prediction miss is completely removed. Recovery is not possible once updated in the register file, so it is necessary to check whether the recovery is due to branch prediction miss while it is still in the reorder buffer.
브랜치 예측 미스시 그 브랜치를 기준으로 선행하는 명령은 계산을 완료하여 레지스터 파일을 업데이트시켜야하고 이후의 명령은 디스카드(discard) 시켜야 한다. 이를 위해서는 앞서 설명한 바와 같이 프로세서가 명령의 실제 실행 순서에 관계없이 원래 프로그램에서의 순서를 알고 있어야 한다.In the event of a branch prediction miss, the preceding instruction must complete the calculation to update the register file, and subsequent instructions must be discarded. To do this, as described above, the processor must know the order in the original program regardless of the actual order of execution of the instructions.
따라서, 원래 프로그램의 순서를 브랜치를 기준으로 보존하여 예측 미스시 쉽게 리커버리를 가능케 할 수 있다.Therefore, the order of the original program can be preserved based on the branch so that recovery can be easily performed in the case of a prediction miss.
제 1 도는 브랜치 처리를 위한 본 발명에 따른 장치로서, 10은 리오더 버퍼, 20은 브랜치 실행 장치, 30은 디코더, 40은 비교기를 각각 나타낸다.1 is a device according to the present invention for branch processing, wherein 10 is a reorder buffer, 20 is a branch execution device, 30 is a decoder, and 40 is a comparator.
도면에 도시된 바와 같이, 본 발명에서는 브랜치 예측 미스시 리커버리 수행을 위해 슈퍼스칼라 프로세서의 구성을 이루는 리오더 버퍼(10) 및 브랜치 실행 장치(20)에 디코더(30)에서 브랜치 고유번호를 할당할 수 있도록 하는 회로를 구성하고, 리오더 버퍼(10) 및 브랜치 실행 장치(20)의 각각의 고유번호를 비교하도록 비교기(40)를 구성하였다.As shown in the figure, in the present invention, a branch unique number may be allocated in the decoder 30 to the reorder buffer 10 and the branch execution device 20 constituting the superscalar processor to perform branch prediction miss recovery. The comparator 40 is configured to compare a unique number of each of the reorder buffer 10 and the branch execution device 20.
디코더(30)에서는 원래 프로그램 순서대로 명령을 받아들인다. 이때 명령의 디펜던시 등을 고려하여 리오더 버퍼의 엔트리를 할당받는데 일반적인 리오더 버퍼의 필드(field)외에 브랜치 고유번호 필드가 추가된다.The decoder 30 accepts commands in the original program order. At this time, an entry of the reorder buffer is allocated in consideration of the dependency of an instruction, and a branch unique number field is added in addition to the field of the general reorder buffer.
디코더(30)에서는 새로운 브랜치 명령을 만날때마다 리오더 버퍼(10) 및 브랜치 실행 장치(20)의 리절베이션 스테이션(reservation station)에 새로운 고유번호를 부여하여 해당 브랜치 명령 이후에 오는(그 다음 브랜치 명령전까지) 모든 명령은 같은 고유번호를 갖도록 한다. 그리고, 브랜치 고유번호는 브랜치 실행 완료까지 고유번호를 유지한다.The decoder 30 assigns a new unique number to the reservation station of the reorder buffer 10 and the branch execution device 20 each time a new branch instruction is met, and comes after the branch instruction (until the next branch instruction). All commands must have the same unique number. The branch unique number maintains the unique number until the completion of the branch.
리오더 버퍼(10)에는 여러 명령의 결과가 원 프로그램 순서에 관계없이 완료되어 저장되는데 브랜치 예측 미스 발생시에는 브랜치 실행 장치(20)로 부터의 브랜치 고유번호와 리오더 버퍼(10)에 할당된 브랜치 고유번호를 비교기(40)에서 비교하여 같지 않은 동안은 해당 명령을 완료할때까지 기다렸다가 레지스터 파일을 업데이트시키고 고유번호가 같은 명령이 나타나자마자 그 이후의 모든 명령은 완료 여부에 관계없이 디스카드시키고 리오더 버퍼를 포함한 모든 내부 장치는 클리어(clear)시킨다. 그후 정상적인 브랜치 타겟에 근거하여 새로운 실행을 하면 리커버리가 완료된다.In the reorder buffer 10, the results of various commands are completed and stored regardless of the original program order. When a branch prediction miss occurs, the branch unique number from the branch execution device 20 and the branch unique number assigned to the reorder buffer 10 are stored. Compare in the comparator 40, wait for the command to complete, update the register file, and as soon as a command with the same unique number appears, discard all subsequent commands, regardless of whether they have completed, and reorder the reorder buffer. All internal devices, including those, are cleared. After that, new execution based on the normal branch target completes the recovery.
예를 들면 제 1 도에 도시된 바와 같이 ①∼⑩까지의 명령이 프로그램 순서대로 디코딩된다고 가정할 때, ③, ⑦번 명령이 브랜치 명령이라고 하면 브랜치 실행 장치(20)와 리오더 버퍼(10)에는 아래와 같이 브랜치 고유번호가 할당될 수 있다.For example, assuming that instructions 1 to 9 are decoded in the program order as shown in FIG. 1, if instructions 3 and 7 are branch instructions, the branch execution device 20 and the reorder buffer 10 may be used. Branch unique number can be assigned as follows.
처음에는 브랜치 고유번호 = Φ으로 할당된다. ③번 명령부터는 새로운 브랜치 고유번호 = 1이 할당된다. ⑦ 번도 브랜치 명령이므로 이후는 브랜치 고유번호 = 2가 할당된다.Initially, branch number = Φ is assigned. From command ③, new branch unique number = 1 is assigned. ⑦ Since it is a branch instruction, branch unique number = 2 is assigned afterwards.
만약 ③번 명령 실행결과 예측이 맞았다면 계속 진행하다, ⑦번 브랜치 명령결과 예측 미스임이 확인되면 이 브랜치의 고유번호인 2와 리오더 버퍼의 브랜치 고유번호를 비교하여 다른 동안(⑥번까지)은 실행을 완료시켜 레지스터 파일로 리타이얼(retire)시키고 고유번호가 같아지면(⑧번 명령)즉시 모든 버퍼와 실행 장치를 클리어시키고 리커버리를 시작한다.If the prediction of the execution result of instruction ③ is correct, proceed to proceed. If you complete the retries to register file and the unique number is the same (command 8), all buffers and execution devices are cleared immediately and recovery starts.
본 발명의 일실시예에서는 각 실행 장치가 리절베이션 스테이션을 가지고 있을 경우를 기준으로 설명하였는데, 이런 경우외에 모든 실행 장치가 공동으로 사용하는 센터럴 윈도우(central window)방식을 사용하는 프로세서에서도 마찬가지로 브랜치에 고유번호를 할당하고 브랜치 실행 수행동안 그 고유번호를 계속 유지하는 것은 마찬가지이다.One embodiment of the present invention has been described based on the case where each execution device has a isolation station. In addition to this case, a processor using a central window method that is shared by all execution devices is similarly used. The same is true for assigning a unique number to and maintaining that unique number during the execution of a branch.
본 발명은 디코더, 브랜치 실행 장치의 리절베이션 스테이션 및 리오더 버퍼에 간단한 로직 추가만으로 쉽게 브랜치 예측 미스시 리커버리 처리를 할 수 있으며 비교 로직 하나만으로 완성해야할 명령들과 무효화할 명령의 경계를 아주 빠르게 알 수 있다.The present invention can easily recover branch prediction misses simply by adding simple logic to the decoder, the recovery station of the branch execution device, and the reorder buffer, and can quickly determine the boundary between the instructions to be completed and the instructions to be invalidated by only one comparison logic. have.
제 1 도는 브랜치 처리를 위한 본 발명에 따른 장치 구성도.1 is a block diagram of an apparatus according to the present invention for branch processing.
* 도면의 주요부분에 대한 부호의 설명** Explanation of symbols for the main parts of the drawings *
10: 리오더 버퍼10: Reorder Buffer
20: 브랜치 실행 장치20: branch execution unit
30: 디코더30: decoder
40: 비교기40: comparator
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1019960026521A KR100445054B1 (en) | 1996-06-29 | 1996-06-29 | Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1019960026521A KR100445054B1 (en) | 1996-06-29 | 1996-06-29 | Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state |
Publications (2)
Publication Number | Publication Date |
---|---|
KR980004023A KR980004023A (en) | 1998-03-30 |
KR100445054B1 true KR100445054B1 (en) | 2004-11-02 |
Family
ID=37362286
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1019960026521A KR100445054B1 (en) | 1996-06-29 | 1996-06-29 | Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state |
Country Status (1)
Country | Link |
---|---|
KR (1) | KR100445054B1 (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4847753A (en) * | 1986-10-07 | 1989-07-11 | Mitsubishi Denki K.K. | Pipelined computer |
US5072364A (en) * | 1989-05-24 | 1991-12-10 | Tandem Computers Incorporated | Method and apparatus for recovering from an incorrect branch prediction in a processor that executes a family of instructions in parallel |
US5210831A (en) * | 1989-10-30 | 1993-05-11 | International Business Machines Corporation | Methods and apparatus for insulating a branch prediction mechanism from data dependent branch table updates that result from variable test operand locations |
JPH05143336A (en) * | 1991-04-18 | 1993-06-11 | Internatl Business Mach Corp <Ibm> | Digital computer and branching-instruction executing method |
US5313634A (en) * | 1992-07-28 | 1994-05-17 | International Business Machines Corporation | Computer system branch prediction of subroutine returns |
-
1996
- 1996-06-29 KR KR1019960026521A patent/KR100445054B1/en not_active IP Right Cessation
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4847753A (en) * | 1986-10-07 | 1989-07-11 | Mitsubishi Denki K.K. | Pipelined computer |
US5072364A (en) * | 1989-05-24 | 1991-12-10 | Tandem Computers Incorporated | Method and apparatus for recovering from an incorrect branch prediction in a processor that executes a family of instructions in parallel |
US5210831A (en) * | 1989-10-30 | 1993-05-11 | International Business Machines Corporation | Methods and apparatus for insulating a branch prediction mechanism from data dependent branch table updates that result from variable test operand locations |
JPH05143336A (en) * | 1991-04-18 | 1993-06-11 | Internatl Business Mach Corp <Ibm> | Digital computer and branching-instruction executing method |
US5313634A (en) * | 1992-07-28 | 1994-05-17 | International Business Machines Corporation | Computer system branch prediction of subroutine returns |
Also Published As
Publication number | Publication date |
---|---|
KR980004023A (en) | 1998-03-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP0661625B1 (en) | Method and apparatus for implementing a four stage branch resolution system in a computer processor | |
US5768576A (en) | Method and apparatus for predicting and handling resolving return from subroutine instructions in a computer processor | |
KR100234648B1 (en) | Method and system instruction execution for processor and data processing system | |
KR100819232B1 (en) | In order multithreading recycle and dispatch mechanism | |
US7809933B2 (en) | System and method for optimizing branch logic for handling hard to predict indirect branches | |
JP3548255B2 (en) | Branch instruction prediction mechanism and prediction method | |
US5584038A (en) | Entry allocation in a circular buffer using wrap bits indicating whether a queue of the circular buffer has been traversed | |
EP0448499B1 (en) | Instruction prefetch method and system for branch-with-execute instructions | |
US5692170A (en) | Apparatus for detecting and executing traps in a superscalar processor | |
US20070043934A1 (en) | Early misprediction recovery through periodic checkpoints | |
EP2159689A1 (en) | Instruction execution controller and instruction execution control method | |
JP2008530713A (en) | System and method for correcting branch misprediction | |
TWI506551B (en) | A microprocessor, an execution method thereof, and computer program product | |
US7363477B2 (en) | Method and apparatus to reduce misprediction penalty by exploiting exact convergence | |
US7711932B2 (en) | Scalable rename map table recovery | |
EP1323033B1 (en) | A pipelined microprocessor and a method relating thereto | |
KR100445054B1 (en) | Method and a device for processing a branch of a microprocessor, particularly capable of easily recovering a wrongly predicted branch to a previous state | |
US10929144B2 (en) | Speculatively releasing store data before store instruction completion in a processor | |
US6473850B1 (en) | System and method for handling instructions occurring after an ISYNC instruction | |
US20050138333A1 (en) | Thread switching mechanism | |
JPH09274565A (en) | Pipelined microprocessor with no interruption caused by branch and operating method for the same | |
US10909034B2 (en) | Issue queue snooping for asynchronous flush and restore of distributed history buffer | |
US6880067B2 (en) | Retiring instructions that meet the early-retirement criteria to improve computer operation throughput | |
WO2012132214A1 (en) | Processor and instruction processing method thereof | |
US10996995B2 (en) | Saving and restoring a transaction memory state |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A201 | Request for examination | ||
E902 | Notification of reason for refusal | ||
E701 | Decision to grant or registration of patent right | ||
GRNT | Written decision to grant | ||
FPAY | Annual fee payment |
Payment date: 20130425 Year of fee payment: 10 |
|
FPAY | Annual fee payment |
Payment date: 20140609 Year of fee payment: 11 |
|
FPAY | Annual fee payment |
Payment date: 20150701 Year of fee payment: 12 |
|
EXPY | Expiration of term |