KR19980084635A - Branch prediction method - Google Patents

Branch prediction method Download PDF

Info

Publication number
KR19980084635A
KR19980084635A KR1019970020473A KR19970020473A KR19980084635A KR 19980084635 A KR19980084635 A KR 19980084635A KR 1019970020473 A KR1019970020473 A KR 1019970020473A KR 19970020473 A KR19970020473 A KR 19970020473A KR 19980084635 A KR19980084635 A KR 19980084635A
Authority
KR
South Korea
Prior art keywords
branch
stage
instruction
branch prediction
btb
Prior art date
Application number
KR1019970020473A
Other languages
Korean (ko)
Other versions
KR100265332B1 (en
Inventor
안문원
김현은
Original Assignee
김영환
현대전자산업 주식회사
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 김영환, 현대전자산업 주식회사 filed Critical 김영환
Priority to KR1019970020473A priority Critical patent/KR100265332B1/en
Publication of KR19980084635A publication Critical patent/KR19980084635A/en
Application granted granted Critical
Publication of KR100265332B1 publication Critical patent/KR100265332B1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3885Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units
    • G06F9/3889Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units controlled by multiple instructions, e.g. MIMD, decoupled access or execute
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/22Microcontrol or microprogram arrangements
    • G06F9/26Address formation of the next micro-instruction ; Microprogram storage or retrieval arrangements
    • G06F9/262Arrangements for next microinstruction selection

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

1. 청구범위에 기재된 발명이 속한 기술분야1. TECHNICAL FIELD OF THE INVENTION

마이크로프로세서.Microprocessor.

2. 발명이 해결하고자 하는 기술적 과제2. Technical problem to be solved by the invention

듀얼 파이프라인 구조와 분기 내용이 저장되어 분기 예측의 근거로 이용되는 BTB를 갖는 마이크로프로세서에서, 분기 예측에 따라 프로그램을 수행할 때에 분기 예측과 분기 검증을 수행하는 분기 예측 방법을 제공하고자 함.In a microprocessor with a BTB where a dual pipeline structure and branch contents are stored and used as a basis for branch prediction, a branch prediction method for performing branch prediction and branch verification when performing a program according to branch prediction is provided.

3. 발명의 해결 방법의 요지3. Summary of the Solution of the Invention

분기 예측에 따라 프로그램을 수행할 때에 BTB 조회와 분기 명령의 다음 명령어의 가져오기를 2 스테이지로 나눠서 진행하는 분기 예측 방법과 듀얼 파이프 모두의 검증을 WB 스테이지에서 분기 검증을 하는 방법을 포함하는 분기 예측 방법을 제공하고자 함.The branch prediction method includes branch prediction method that divides the BTB query and the import of the next instruction of the branch instruction into two stages when performing the program according to the branch prediction, and the branch verification method in the WB stage for the verification of both dual pipes. To provide a way.

4. 발명의 중요한 용도4. Important uses of the invention

분기 예측 장치를 가진 모든 마이크로프로세서 칩 설계에 이용됨.Used in all microprocessor chip designs with branch prediction devices.

Description

분기 예측 방법Branch prediction method

본 발명은 마이크로프로세서 내 분기 예측 구조(Branch Prediction Scheme)에서의 효과적인 분기 예측과 분기 검증을 위한 분기 예측 방법에 관한 것으로서 분기 예측 구조를 갖는 모든 마이크로프로세서에서 적용될 수 있다.The present invention relates to a branch prediction method for effective branch prediction and branch verification in a branch prediction structure in a microprocessor, and can be applied to all microprocessors having a branch prediction structure.

프로그램 수행 중 분기 명령이 나올 경우 저장되어져 있는 이전까지의 프로그램 수행 기록에 따라서 분기 다음에 수행될 명령어를 예측하여 미리 가져와서 수행하는 분기 예측과 예측되어진 분기의 검증을 수행한다.When a branch instruction is issued during program execution, the branch prediction that is executed after the branch is predicted and the predicted branch is verified according to the stored program execution records up to the previous time.

종래에는 분기 예측 시 BTB 조회와 분기 명령의 다음 명령어의 가져오기를 하나의 스테이지에서 수행하였기 때문에 빠른 클럭속도를 가지는 경우는 처리가 불가능해지는 문제점이 있다. 또한, 분기 검증은 듀얼 파이프 구조에서 X 파이프는 EX 스테이지에서, Y 파이프는 WB 스테이지에서 각기 따로이 검증을 진행하였기 때문에 분기 예측 회로가 복잡해지고,복잡한 제어회로가 소요되는 문제점이 있다.Conventionally, since the BTB query and the next instruction of the branch instruction are fetched in one stage during the branch prediction, there is a problem in that processing is impossible when the clock speed is high. In addition, branch verification has a problem in that the branch prediction circuit is complicated and complicated control circuits are required because the X pipe is independently examined at the EX stage and the Y pipe is at the WB stage in the dual pipe structure.

본 발명은 상기와 같은 문제점을 해결하기 위하여 안출된 것으로서, 듀얼 파이프라인 구조와 분기 내용이 저장되어 분기 예측의 근거로 이용되는 BTB를 갖는 마이크로프로세서에서, 분기 예측에 따라 프로그램을 수행할 때에 빠른 클럭속도에서도 분기 예측이 가능하고, 또한 효율적인 분기의 검증을 진행하는 분기 예측 방법을 제공하는데 그 목적이 있다.SUMMARY OF THE INVENTION The present invention has been made to solve the above problems, and in a microprocessor having a dual pipeline structure and a BTB in which branch contents are stored and used as a basis for branch prediction, a fast clock when executing a program according to branch prediction It is an object of the present invention to provide a branch prediction method capable of branch prediction at a speed and efficient branch verification.

도1은 본 발명의 파이프라인된 분기 예측 블록도.1 is a pipelined branch prediction block diagram of the present invention.

도2는 본 발명의 분기 예측 방법.2 is a branch prediction method of the present invention.

상기 목적을 달성하기 위한 본 발명은 다수의 스테이지를 가진 제1 파이프 및 제2 파이프의 듀얼 파이프 마이크로프로세서에서, 수행할 명령어를 미리 캐쉬에서 가져오는 제1스테이지, 페치한 명령어의 길이를 계산하는 제2스테이지, 명령어를 디코딩하는 제3스테이지, 데이터 캐쉬에서 가져올 데이터의 주소를 계산하는 제4스테이지, 명령어를 수행하는 제5스테이지, 수행한 결과를 메모리나 레지스터에 쓰는 제6스테이지로 이루어져 분기 예측에 따라 프로그램을 수행할 때에 브렌치타겟버퍼(BTB) 조회와 분기 명령의 다음 명령어 가져오기를 두개의 스테이지로 나누어 처리하는 분기 예측 방법을 포함하는 것을 특징으로 한다.The present invention for achieving the above object is a dual-pipe microprocessor of the first pipe and the second pipe having a plurality of stages, the first stage to fetch the instructions to be executed in the cache, the first stage to calculate the length of the fetched instructions It consists of two stages, a third stage for decoding the instruction, a fourth stage for calculating the address of the data to be retrieved from the data cache, a fifth stage for performing the instruction, and a sixth stage for writing the result to memory or a register. According to the present invention, a branch prediction method for processing a branch target buffer (BTB) and obtaining a next instruction of a branch instruction is divided into two stages.

또한, 다수의 스테이지를 가진 제1 파이프 및 제2 파이프의 듀얼 파이프 마이크로프로세서에서, 수행할 명령어를 미리 캐쉬에서 가져오는 제1스테이지, 페치한 명령어의 길이를 계산하는 제2스테이지, 명령어를 디코딩하는 제3스테이지, 데이터 캐쉬에서 가져올 데이터의 주소를 계산하는 제4스테이지, 명령어를 수행하는 제5스테이지, 수행한 결과를 메모리나 레지스터에 쓰는 제6스테이지로 이루어진 제1 파이프 및 제2 파이프의 듀얼 파이프라인 구조와 분기 내용이 저장되어 분기 예측의 근거로 이용되는 브렌치타겟버퍼(BTB)를 갖는 마이크로프로세서에서, 분기 예측에 따라 다음에 수행될 명령어를 예측하여 미리 가져와서 수행하는 동작이 맞았는지 틀렸는지를 확인하는 분기 검증을 제1 파이프, 제2 파이프 모두 제6스테이지에서 처리하는 분기 예측 방법을 포함하는 것을 특징으로 한다.In addition, in a dual pipe microprocessor of a first pipe and a second pipe having a plurality of stages, a first stage that obtains instructions to be executed from the cache in advance, a second stage that calculates the length of the fetched instructions, and decodes the instructions. Dual pipe of the first and second pipes, consisting of a third stage, a fourth stage for calculating the address of data to be fetched from the data cache, a fifth stage for executing instructions, a sixth stage for writing the result to memory or a register In a microprocessor with a branch target buffer (BTB) where the line structure and branch contents are stored and used as the basis of branch prediction, whether the operation to predict and execute the next instruction according to the branch prediction is correct or incorrect. Branch prediction, in which the first pipe and the second pipe are both processed by the sixth stage It comprises a method.

이하, 첨부된 도면을 참조하여 본 발명을 상세히 살펴본다.Hereinafter, the present invention will be described in detail with reference to the accompanying drawings.

프로그램 수행 중 분기 명령이 나올 경우 이 분기를 수행한 후에야 다음에 수행될 명령을 알 수 있어 그 동안 명령어의 가져오기가 중단되는 데 분기 예측(Branch Prediction)은 이러한 성능 저하를 막기 위해 명령어를 가지고 올 때에 이전까지의 프로그램 수행 기록에 따라 분기 명령 다음에 수행될 명령어를 예측하여 미리 가져와서 수행하는 동작을 말한다. 분기단(Branch Unit)을 두어 이 역할을 수행하는데 이 분기단은 BTB(Branch Target Buffer)가 구비되며,프리페치(Prefetch),명령어 페치와 밀접하게 연관되어 동작한다. 이때, 분기 예측에 따라 프로그램을 수행할 때에는 분기 명령 다음에 수행될 명령어를 예측하여 미리 가져와서 수행하는 동작이 맞았는지 틀렸는지를 확인해야 하는데, 이 과정을 분기 검증이라 한다.If a branch instruction is issued while the program is running, the branch instruction is stopped only after this branch is executed. In the meantime, the instruction is interrupted while Branch Prediction brings the instruction to prevent such performance degradation. In this case, it refers to an operation of predicting and executing the instruction to be executed after the branch instruction according to the previous program execution record. It has a branch unit to perform this role. This branch stage is equipped with a branch target buffer (BTB), and is closely related to prefetch and instruction fetch. At this time, when the program is executed according to the branch prediction, the instruction to be executed after the branch instruction must be predicted to confirm whether or not the operation to be performed in advance is correct or incorrect. This process is called branch verification.

본 발명은 이러한 분기 예측과 분기 검증을 수행하기 위한 장치를 제공하는 것으로 도1은 본 발명에 따른 실시예로 파이프라인된 분기 예측의 블록도를 보여준다. 도1은 수행할 명령어를 미리 캐쉬에서 가져오는 PF(Prefetch,100), 페치한 명령어의 길이를 계산하는 IA(Instruction Addressing,200),명령어를 디코딩하는 ID(Instruction Decoding,300), 데이터 캐쉬에서 가져올 데이터의 주소를 계산하는 AG(Address Generation,400), 명령어를 수행하는 EX(Excution,500), 수행한 결과를 메모리나 레지스터에 쓰는 WB(Write Back,600)의 스테이지를 갖는 X,Y 듀얼 파이프라인 구조와 분기 내용이 저장되어 분기 예측의 근거로 이용되는 BTB(700) 및 분기 검증 시 참조하기 위해 분기 내용을 저장하는 분기 쉬프터로 이루어진다. 상기 분기 쉬프터는 IA 스테이지에서 X 파이프의 주소와 타겟 명령어의 주소, BTB 조회 내용 등을 저장하는 제1 분기 쉬프터(10), 제1 분기 쉬프터의 내용이 한 사이클동안 지연되어 그대로 저장되는 제2 분기 쉬프터(20), 제2 분기 쉬프터의 내용과 함께 ID 스테이지에서 나온 분기 정보가 저장되는 제3 분기 쉬프터(30), 제3 분기 쉬프터의 내용과 함께 AG 스테이지에서 나온 분기 정보가 저장되는 제4 분기 쉬프터(40), 제4 분기 쉬프터의 내용과 함께 EX 스테이지에서 나온 분기 정보가 저장되는 제5 분기 쉬프터(50), 제5 분기 쉬프터 내용 중 분기 검증에 필요한 일부와 WB 스테이지에서 나온 분기 정보가 저장되는 제6 분기 쉬프터(60)로 이루어지며, 상기 제6 분기 쉬프터의 내용으로 BTB 변경을 하고(70) 분기 예측을 잘못한 경우 보정 주소로 다시 프리페치를 하도록(80) 구성되어진다.The present invention provides an apparatus for performing such branch prediction and branch verification. FIG. 1 shows a block diagram of a branch prediction pipelined to an embodiment according to the present invention. 1 is a PF (Prefetch, 100) for prefetching instructions to be executed from a cache, IA (Instruction Addressing, 200) for calculating the length of a fetched instruction, ID (Instruction Decoding, 300) for decoding an instruction, and a data cache. X, Y dual with AG (Address Generation, 400) to calculate the address of the data to be imported, EX (Excution, 500) to execute the instruction, and WB (Write Back, 600) to write the result to memory or register The pipeline structure and branch contents are stored, and are used as a BTB 700 used as a basis for branch prediction, and a branch shifter for storing branch contents for reference during branch verification. The branch shifter may include a first branch shifter 10 for storing an address of an X pipe, an address of a target instruction, a BTB inquiry, and the like in the IA stage, and a second branch in which the contents of the first branch shifter are delayed and stored for one cycle. Third branch shifter 30 in which branch information from the ID stage is stored together with the contents of the shifter 20 and the second branch shifter, and fourth branch in which branch information from the AG stage is stored together with the contents of the third branch shifter. The fifth branch shifter 50 in which the branch information from the EX stage is stored along with the contents of the shifter 40 and the fourth branch shifter, and the branch information from the WB stage is stored. And a sixth branch shifter 60 to change the BTB to the contents of the sixth branch shifter (70) and to prefetch back to the correction address if the branch prediction is incorrect (80). It is composed.

상기 스테이지별 파이프라인 진행에서 분기 예측시 필요한 BTB 조회는 IA 스테이지에서 진행하고, 분기 명령의 다음 명령어의 가져오기는 ID 스테이지에서 나누어 진행한다. 이와 같이 BTB 조회와 다음 명령어의 가져오기를 나누어 진행하면서 분기 명령어 자체 주소로 분기 예측을 할 경우에는 1사이클의 공백이 발생하게 된다. 도2는 본 발명에 따른 분기 예측 방법을 개념적으로 도식한 것으로서, 상기 발생한 공백을 제거하기 위해 분기 명령어가 수행되는 사이클의 이전 사이클에서 수행되는 명령어의 주소로 BTB조회를 하고,듀얼 파이프에서 진행하는 명령어의 연관성에 따르는 문제를 없애기 위해 항상 X파이프에서 수행되는 명령의 주소를 가지고 BTB 조회를 한다. 분기 명령의 전 사이클에 수행되는 명령어인 이전 명령의 IA 스테이지에서 BTB를 조회하여 분기 명령에 대한 예측을 시도한다. 이에 따라 다음 사이클에서는 분기의 예상되는 타겟 어드레스를 가지고 타겟을 프리페치한다. 도2에서 다음 명령은 분기가 BTB의 내용대로 진행되지 않았을 경우에 분기 다음에 수행되어야할 명령어로, WB에서 분기 검증 후 예측이 틀렸을 경우에는 파이프라인을 모두 비우고(pipeline flush) 분기 전 상태로 돌려놓은 후 분기 다음부터 수행해야 할 명령어이다. 도면에서 분기 예측이 틀렸을 때 보정 수행이 분기 예측을 잘못한 후 다음 명령을 수행하는 것이다.The BTB inquiry necessary for branch prediction in the pipeline progress by stage is performed in the IA stage, and the import of the next instruction of the branch instruction is performed in the ID stage. As described above, when branch prediction is performed by the branch instruction itself address while dividing the BTB inquiry and the import of the next instruction, one cycle of white space occurs. 2 is a conceptual diagram illustrating a branch prediction method according to the present invention, in which a BTB query is performed to an address of an instruction performed in a previous cycle of a cycle in which a branch instruction is performed to remove the generated space, and proceeds in a dual pipe. To avoid problems associated with instruction associations, always perform a BTB query with the address of the instruction executed in the Xpipe. The BTB is retrieved from the IA stage of the previous instruction, which is the instruction executed in the entire cycle of the branch instruction, and attempts to predict the branch instruction. The next cycle thus prefetches the target with the expected target address of the branch. In FIG. 2, the next command is a command to be performed after the branch when the branch does not proceed as described in the BTB. If the prediction is incorrect after the branch verification in WB, the pipeline flushes all pipelines and returns to the state before the branch. This command should be executed after the branch after release. When the branch prediction is wrong in the drawing, the correction is performed after the wrong branch prediction is executed.

도1을 참조해 스테이지별로 상세히 살펴보면, 먼저 PF 스테이지에서는 실제 프로그램 진행과 무관하게 미리 수행할 명령어를 캐시에서 가져오고, 분기에 따른 추가 지연없이 프로그램을 수행하기 위해 분기 명령 이전의 명령어 주소로 분기 예측을 한다.Referring to Figure 1 in detail by stage, first, in the PF stage, the instruction to be executed in advance is retrieved from the cache irrespective of the actual program progress, and the branch prediction is performed by the instruction address before the branch instruction to execute the program without additional delay according to the branch. Do it.

IA 스테이지에서는 X 파이프 주소를 인텍스 주소 필드에 쓰며, 이때 X의 명령이 받아들여지지 않을 경우에는 인덱스 무효를 표시해야 한다. 지연 스테이지는 파이프라인 스테이지는 아니고, 분기 명령의 이전 명령어 주소로 예측하기 때문에 생기는 지연을 보정하기 위하여 IA에서 넘어온 정보를 그냥 1 사이클 지연시킨다. ID 스테이지에서는 X 또는 Y 파이프의 명령이 분기인가를 체크하여 이를 분기 쉬프터에 쓰며, 이와함께 명령어의 유효 여부도 알 수 있어 함께 분기 쉬프터에 저장한다. 분기 검증시 IA에서 유효로 받아들여지고, ID에서 유효 분기라고 판정된 명령어에 한하여 BTB 변경을 수행한다. AG 스테이지에서는 데이터 캐쉬에서 가져올 데이터의 주소를 계산하며, 타겟 주소가 맞았는지를 확인할 수 있다. EX 스테이지에서는 명령어를 처리하고, 분기 조건을 체크한다. WB 스테이지에서는 분기를 처리하고 분기 쉬프터의 내용을 참조하여 모든 경우에 대해 분기검증을 한다.The IA stage writes the X pipe address into the index address field, which must indicate index invalidness if the X command is not accepted. The delay stage is not a pipeline stage, but just one cycle of information passed from the IA to compensate for the delay caused by predicting the previous instruction address of the branch instruction. In the ID stage, it checks whether an instruction of an X or Y pipe is a branch and writes it to the branch shifter. It also knows whether the instruction is valid and stores it in the branch shifter. Only the instructions that are accepted as valid by the IA at the time of branch verification and are determined to be valid branches by the ID will perform the BTB change. The AG stage calculates the address of the data to retrieve from the data cache and checks if the target address is correct. The EX stage processes the instruction and checks for branch conditions. In the WB stage, branch processing is performed and branch verification is performed for all cases by referring to the contents of the branch shifter.

이 분기 검증을 X,Y 파이프에 관계없이 WB 스테이지에서 수행하는데, 분기 검증은 첫째,BTB 히트/미스 여부, 둘째,분기 명령 여부 확인, 셋째,분기 타겟이 맞는가 확인, 넷째,분기 예측 여부(Taken/not-taken) 확인 등의 내용을 검증한다. 먼저,BTB 히트/미스 여부는 분기 검증의 가장 기본으로 이 분기가 예상되어 졌는가를 확인하는 것이다. 히트가 났다는 것은 이 분기 명령 이전에 분기 명령으로 취해져 수행된 적이 있다는 것이다. 두 번째 검증 내용인 분기 명령 여부 확인은 IA 스테이지에서 분기 예측을 위해 BTB를 조회하여 BTB 히트가 났다면 그 다음 X 파이프 혹은 Y 파이프에 오는 명령어에는 분기 명령이 있어야 한다. BTB 히트임에도 다음에 분기 명령이 오지 않으면 해당 BTB 내용을 무효화시켜야 한다. BTB 미스의 경우는 기본으로 분기를 하지 않는 걸로 가정하여 프로그램을 수행하고 분기 검증 시 분기가 취해 졌을 경우에만 BTB 엔트리를 할당하게 된다. 세 번째 검증 내용은 BTB 히트 시 BTB에 저장되어 있는 타겟 주소 값으로 내부의 프로그램 카운터를 바꾸어 놓고 프리페치를 다시 하게 되고, 분기 명령의 AG 스테이지에서 실제 타겟 주소를 구하여 예측되었던 타겟 주소와 비교해 분기 타겟이 맞았는 지를 확인하는 것이다. 비교한 타겟 주소가 서로 다를 경우에는 BTB의 타겟 주소 필드의 내용을 수정하여야 한다. 마지막 네 번째 검증 내용인 분기 예측 여부(Taken/not-taken) 확인은 예측된 분기 예측 여부와 실제를 비교하여 그 결과에 따라 프로그램을 다시 수행할 것인지를 결정하는 것이다.This branch verification is performed at the WB stage regardless of the X and Y pipes.The branch verification is performed in the following ways: first, BTB hit / miss, second, branch instruction check, third, branch target fit, fourth, branch prediction (Taken) / not-taken) to verify the contents of the check. First, BTB hits / misses are the basis of branch verification, to see if this branch is expected. A hit has been taken and executed as a branch instruction before this branch instruction. In the second verification, the branch instruction check, if the BTB hit is made by querying the BTB for branch prediction at the IA stage, the instruction coming to the next X pipe or Y pipe must have a branch instruction. If the next branch instruction is not a BTB hit, the contents of the BTB must be invalidated. In the case of a BTB miss, the program is assumed to not branch by default, and the BTB entry is allocated only when a branch is taken during branch verification. The third verification is to replace the internal program counter with the target address value stored in the BTB at the time of the BTB hit and prefetch again, and obtain the actual target address from the AG stage of the branch instruction and compare the branch target with the predicted target address. Is to check if this is correct. If the compared target addresses are different, the contents of the target address field of the BTB should be modified. The fourth and final verification, the Taken / not-taken check, compares the predicted branch prediction with the actual to determine whether to rerun the program based on the result.

분기 검증을 WB 스테이지에서 할 때 같은 사이클에 분기 다음 명령이 EX 스테이지에서 수행된다. 만약 검증 결과 진행의 보정이 필요하다고 판단되면 이 실행은 수행되어서는 안되는 것이 된다. 특히 이 명령이 메모리 쓰기(memory write)같은 명령이면 복구할 수 없으므로 빨리 수행하여 그 다음의 실행을 즉시 중지시킬 수 있어야 한다.When performing branch verification at the WB stage, the next branch instruction in the same cycle is performed at the EX stage. If the verification indicates that correction of the progress is necessary, this implementation should not be performed. In particular, if the command is a command such as memory write, it cannot be recovered, so it must be executed quickly and immediately stop the next execution.

사실 분기가 X 파이프에서 수행될 때는 EX 스테이지에서 예측의 히트/미스 여부를 알 수 있지만 설계의 일관성과 간단한 회로 구성을 위해 WB 스테이지에서 같이 검증을 한다.In fact, when the branch is performed on the X pipe, we know whether the hit hits or misses in the EX stage, but we also validate it in the WB stage for design consistency and simple circuit configuration.

이를 위해서 초기에 BTB에서 조회한 내용과 분기 예측 내용을 검증 시점인 WB 스테이지까지 계속 유지해 검증하는 데 사용한다. 이것은 파이프라인의 진행과 함께 분기 예측 내용을 쉬프트 시켜 그 내용을 저장하는 분기 쉬프터의 내용을 참조하여 이루어진다. 분기 쉬프터의 내용을 참조하여 프리페치 로직에서 캐쉬를 조회하여 분기 타겟 명령어를 가져오고 또 IA 스테이지에서 프리페치 큐(Prefetch Queue)로부터 명령어를 가져오게 된다. 또 예측을 잘못해서 보정 명령어를 프리페치하는 경우도 이 분기 쉬프터의 내용을 참조하게 된다.To this end, the initial query and branch predictions from the BTB are maintained and verified until the WB stage, which is the verification point. This is done with reference to the branch shifter, which shifts branch predictions and stores them as the pipeline progresses. Refer to the branch shifter to retrieve the cache from the prefetch logic to retrieve branch target instructions and to retrieve instructions from the prefetch queue at the IA stage. In addition, if the prediction is incorrectly prefetched, the branch shifter is referred to.

상기의 분기 예측은 모든 명령을 캐시에서 찾을 수 있다는 가정 하에서 이루어져야 하므로 항상 이전 사이클과 분기 사이클과의 관계만으로 BTB 변경 및 조회를 하도록 하는 것이 정상적이 분기 예측 방법이다.Since the above branch prediction must be performed under the assumption that all instructions can be found in the cache, it is normal to make the BTB change and inquiry only by the relationship between the previous cycle and the branch cycle.

이상에서 설명한 본 발명은 전술한 실시예 및 첨부된 도면에 의해 한정되는 것이 아니고, 본 발명의 기술적 사상을 벗어나지 않는 범위 내에서 여러 가지 치환, 변형 및 변경이 가능하다는 것이 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 있어 명백할 것이다.The present invention described above is not limited to the above-described embodiments and the accompanying drawings, and various substitutions, modifications, and changes can be made in the art without departing from the technical spirit of the present invention. It will be apparent to those of ordinary knowledge.

상기와 같이 이루어지는 본 발명은 듀얼 파이프라인 구조와 분기 내용이 저장되어 분기 예측의 근거로 이용되는 BTB를 갖는 마이크로프로세서에서의 분기 예측을 위해, 분기 프로그램을 수행할 때 BTB 조회와 분기 명령의 다음 명령어의 가져오기를 2 스테이지로 나눠서 진행하여 빠른 클럭속도에서의 분기 예측을 가능하게 한다. 또한 분기 검증을 위해 쉬프트 레지스터를 스테이지 별로 따로 두어 파이프라인 진행과 함께 분기 내용을 저장, 쉬프트시켜 WB 스테이지에서 분기 검증을 하도록하여 분기 예측 구조의 일관성 있는 설계가 가능해지고, 제어회로가 간단해져 종래 방식에 비해 더 나은 성능 향상을 가져오는 효과가 있다.According to the present invention made as described above, the branch instruction of a BTB query and a branch instruction when executing a branch program for branch prediction in a microprocessor having a dual pipeline structure and a BTB in which branch contents are stored and used as a basis for branch prediction. The import of is divided into two stages to enable branch prediction at fast clock speeds. In addition, shift registers are set by stage for branch verification, and branch contents are stored and shifted as the pipeline progresses, so that branch verification is performed at the WB stage to enable consistent design of the branch prediction structure, and simplify the control circuit. Compared to the above, it has a better performance improvement.

Claims (6)

다수의 스테이지를 가진 제1 파이프 및 제2 파이프의 듀얼 파이프 마이크로프로세서에서, 수행할 명령어를 미리 캐쉬에서 가져오는 제1스테이지, 페치한 명령어의 길이를 계산하는 제2스테이지, 명령어를 디코딩하는 제3스테이지, 데이터 캐쉬에서 가져올 데이터의 주소를 계산하는 제4스테이지, 명령어를 수행하는 제5스테이지, 수행한 결과를 메모리나 레지스터에 쓰는 제6스테이지로 각각 수행하고, 분기 예측에 따라 프로그램을 수행할 때 브렌치타겟버퍼(BTB) 조회와 분기 명령의 다음 명령어 가져오기를 상기 각각 제2스테이지와 제3스테이지로 나누어 처리하는 분기 예측 방법.In a dual-pipe microprocessor of a first pipe and a second pipe having a plurality of stages, a first stage that prefetches instructions to be executed from the cache, a second stage that calculates the length of the fetched instructions, and a third that decodes the instructions. The stage, the fourth stage of calculating the address of data to be obtained from the data cache, the fifth stage of executing the instruction, the sixth stage of writing the result to memory or a register, and the program according to the branch prediction. A branch prediction method for processing a branch target buffer (BTB) query and obtaining a next instruction of a branch instruction by dividing the second stage and the third stage, respectively. 제 1 항에 있어서,The method of claim 1, 상기 분기 예측에 따라 프로그램을 수행할 때 상기 브렌치타겟버퍼(BTB) 조회와 상기 다음 명령어의 가져오기를 상기 제2 스테이지와 제3 스테이지로 나누어 처리하면서, 상기 분기 명령어의 자체 주소로 분기 예측을 했을 때 생성되는 1사이클의 공백을 제거하기 위해, 상기 분기 명령어가 수행되는 사이클의 이전 사이클에서 수행되는 명령어의 주소로 브렌치타겟버퍼(BTB)조회를 하는 것을 특징으로 하는 분기 예측 방법.When executing the program according to the branch prediction, the branch target buffer (BTB) inquiry and the import of the next instruction are divided into the second stage and the third stage, and the branch prediction is performed by the own address of the branch instruction. The branch prediction method of claim 1, wherein a branch target buffer (BTB) is queried with the address of the instruction executed in the previous cycle of the cycle in which the branch instruction is executed to remove the space of one cycle. 제 2 항에 있어서,The method of claim 2, 상기 듀얼 파이프에서 진행하는 명령어의 연관성에 따르는 문제를 없애기 위해 상기 분기 명령어가 수행되는 사이클의 이전 사이클에서 수행되는 명령어 중 항상 제1 파이프에서 수행되는 명령어의 주소를 가지고 브렌치타겟버퍼(BTB)조회를 하는 것을 특징으로 하는 분기 예측 방법.In order to eliminate the problem caused by the correlation of the instruction proceeding in the dual pipe, the branch target buffer (BTB) lookup is always performed with the address of the instruction executed in the first pipe among the instructions executed in the previous cycle of the cycle in which the branch instruction is executed. Branch prediction method characterized in that. 각각 다수의 스테이지를 가지고, 분기 내용이 저장되어 분기 예측의 근거로 이용되는 브렌치타겟버퍼(BTB)를 갖는 듀얼 파이프 마이크로프로세서에서,In a dual pipe microprocessor with a branch target buffer (BTB) each having a number of stages, the branch content being stored and used as the basis for branch prediction, 수행할 명령어를 미리 캐쉬에서 가져오는 제1스테이지, 페치한 명령어의 길이를 계산하는 제2스테이지,명령어를 디코딩하는 제3스테이지, 데이터 캐쉬에서 가져올 데이터의 주소를 계산하는 제4스테이지, 명령어를 수행하는 제5스테이지, 수행한 결과를 메모리나 레지스터에 쓰는 제6스테이지로 각각 수행하고, 분기 예측에 따라 다음에 수행될 명령어를 예측하여 미리 가져와서 수행하는 동작이 맞았는지 틀렸는지를 확인하는 분기 검증을 제1 파이프,제2 파이프 모두 제6스테이지에서 처리하는 분기 예측 방법.A first stage to get the instruction to execute from the cache in advance, a second stage to calculate the length of the fetched instruction, a third stage to decode the instruction, a fourth stage to calculate the address of the data to be retrieved from the data cache, and perform the instruction The fifth stage, and the sixth stage to write the result to memory or register, respectively, and perform branch verification to predict whether the next instruction to be executed according to branch prediction is correct or wrong. A branch prediction method in which both the first pipe and the second pipe are processed in the sixth stage. 제 4 항에 있어서,The method of claim 4, wherein 상기 제6스테이지에서 분기 검증을 처리하기 위해 분기 예측시 상기 브렌치타겟버퍼(BTB)에서 조회한 내용과 분기 예측 내용을 검증 시점인 상기 제6스테이지까지 계속 유지하여 상기 검증에 사용하는 것을 특징으로 하는 분기 예측 방법.In order to process branch verification in the sixth stage, the branch target buffer (BTB) and the contents of the inquiry in the branch prediction content is maintained until the sixth stage at the time of verification, characterized in that it is used for the verification Branch prediction method. 제 5 항에 있어서,The method of claim 5, 상기 조회 내용을 검증 시점인 상기 제6스테이지까지 게속 유지하여 상기 검증에서 사용하기 위해, 스테이지별로 분기 쉬프터를 두어 파이프라인의 진행과 함께 상기 분기 예측 내용을 쉬프트,저장하는 것을 특징으로 하는 분기 예측 방법.A branch prediction method of shifting and storing the branch prediction content as the pipeline progresses by providing a branch shifter for each stage to keep the inquiry contents up to the sixth stage, which is a verification point, for use in the verification. .
KR1019970020473A 1997-05-23 1997-05-23 Branch prediction method KR100265332B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1019970020473A KR100265332B1 (en) 1997-05-23 1997-05-23 Branch prediction method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1019970020473A KR100265332B1 (en) 1997-05-23 1997-05-23 Branch prediction method

Publications (2)

Publication Number Publication Date
KR19980084635A true KR19980084635A (en) 1998-12-05
KR100265332B1 KR100265332B1 (en) 2000-09-15

Family

ID=19506978

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1019970020473A KR100265332B1 (en) 1997-05-23 1997-05-23 Branch prediction method

Country Status (1)

Country Link
KR (1) KR100265332B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100468618B1 (en) * 2002-03-28 2005-01-31 매그나칩 반도체 유한회사 Apparatus for branch prediction in superscalar processor with variable length instruction

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07262007A (en) * 1994-03-16 1995-10-13 Hitachi Ltd Information processor

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100468618B1 (en) * 2002-03-28 2005-01-31 매그나칩 반도체 유한회사 Apparatus for branch prediction in superscalar processor with variable length instruction

Also Published As

Publication number Publication date
KR100265332B1 (en) 2000-09-15

Similar Documents

Publication Publication Date Title
JP5722396B2 (en) Method and apparatus for emulating branch prediction behavior of explicit subroutine calls
KR100411529B1 (en) A method and apparatus for branch prediction using a second level branch prediction table
JP5357017B2 (en) Fast and inexpensive store-load contention scheduling and transfer mechanism
JP5089186B2 (en) Data cache miss prediction and scheduling
US20090006803A1 (en) L2 Cache/Nest Address Translation
US20060200655A1 (en) Forward looking branch target address caching
US7680985B2 (en) Method and apparatus for accessing a split cache directory
US7444501B2 (en) Methods and apparatus for recognizing a subroutine call
US20070288736A1 (en) Local and Global Branch Prediction Information Storage
JP5734945B2 (en) Sliding window block based branch target address cache
KR19980034443A (en) Efficient BTB Method of Super Scalar Microprocessor
US7937530B2 (en) Method and apparatus for accessing a cache with an effective address
US6205544B1 (en) Decomposition of instructions into branch and sequential code sections
JP5415268B2 (en) Method and apparatus for reducing lookup in branch target address cache
KR100265332B1 (en) Branch prediction method
US20220137974A1 (en) Branch density detection for prefetcher
KR100251992B1 (en) Branch prediction device
US7343481B2 (en) Branch prediction in a data processing system utilizing a cache of previous static predictions
KR20000003930A (en) Instruction patch apparatus for decreasing loss when being instruction cache miss
Shih et al. CS152 Spring 2004 Final Project Report
JP2000029693A (en) Instruction cache device and control method therefor

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: 20050524

Year of fee payment: 6

LAPS Lapse due to unpaid annual fee