# US 6,965,983 B2 · Simultaneously setting prefetch address and fetch address pipelined stages upon branch

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 6,965,983 B2
- Document ID: US6965983B2
- Status: Granted
- Kind: B2
- Application number: 10/248,769
- Filed: 2003-02-16
- Published: 2004-08-26
- Granted: 2005-11-15
- Earliest claimed: 2003-02-16
- Assignees: Faraday Technology Corp.
- Inventors: Hung-Yu Lin
- Web page: https://patentgrep.com/patent/US6965983B2

## CPC

- G06F 9/3867: {using instruction pipelines}
- G06F 9/3804: {for branches, e.g. hedging, branch folding}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A pipelined CPU includes a pre-fetch (PF) stage for performing branch prediction, and an instruction fetch (IF) stage for fetching instructions that are to be later processed by an execution (EX) stage. The PF stage has a PF address (PFA) register for storing the address of an instruction being processed by the PF stage, and the IF stage has an IF address (IFA) register for storing the address of an instruction to be fetched for later execution. The CPU also includes address register control (ARC) circuitry for setting the contents of the PFA and the IFA. The ARC accepts branch-prediction results from the PF stage to determine the subsequent contents of the PFA and the IFA. If the PF stage predicts a branch, then the ARC sets the next address of the PFA to be sequentially after a predicted branch address, and simultaneously sets the next address of the IFA to be the predicted branch address.

## Claims

### Claim 1

A pipelined central processing unit (CPU) comprising:
a pre-fetch (PF) stage for performing branch prediction, the PF stage comprising a PF address (PFA) register for storing the address of an instruction being processed by the PF stage;
an instruction fetch (IF) stage for fetching instructions that are to be later processed by an execution (EX) stage, the IF stage comprising an IF address (IFA) register for storing the address of an instruction to be fetched for later execution, and accepting a branch prediction result from the PF stage; and
address register control (ARC) circuitry for setting the contents of the PFA and the IFA, the ARC utilizing the branch prediction result held in the IF stage to determine the contents of the PFA and the IFA;
wherein if the branch prediction result held in the IF stage predicts no branching, then the ARC sets a next address of the PFA to be sequentially after a current address of the PFA and a next address of the IFA to be the current address of the PFA, and if the branch prediction result held in the IF stage predicts a branch, then the ARC sets the next address of the PFA to be sequentially after a predicted branch address and simultaneously sets the next address of the IFA to be the predicted branch address.

### Claim 2 (depends on 1)

The pipelined CPU of claim 1 wherein the ARC comprises masking circuitry for ignoring a branch prediction result from the PF stage when the branch prediction result held in the IF stage predicts a branch.

### Claim 3 (depends on 1)

The pipelined CPU of claim 1 wherein the PF stage immediately precedes the IF stage, and the EX stage is subsequent the IF stage.

### Claim 4 (depends on 3)

The pipelined CPU of claim 3 wherein the ARC further accepts a result from the EX stage to set the contents of the IFA and the PFA, wherein if the EX stage determines that an executed instruction has an incorrect branch-prediction result, the ARC sets the next address of the IFA to be sequentially after the executed instruction and simultaneously sets the next address of the PFA to sequentially after the next address of the IFA.

### Claim 5 (depends on 3)

The pipelined CPU of claim 3 wherein the ARC further accepts a result from the EX stage to set the contents of the IFA and the PFA, wherein if the EX stage determines that an executed instruction has an incorrect branch-prediction result, the ARC sets the next address of the IFA to a target instruction address as determined by the EX stage, and simultaneously sets the next address of the PFA to sequentially after the next address of the IFA.

### Claim 6 (depends on 4)

The pipelined CPU of claim 4 wherein the ARC comprises masking circuitry for ignoring a branch prediction result from the PF stage when the EX stage contains an executed instruction having an incorrect branch-prediction result.

### Claim 7

A method for pipelining instructions in a central processing unit (CPU), the method comprising:
providing a pre-fetch (PF) stage for performing branch prediction of an instruction pointed to by a pre-fetch address (PFA) register;
providing an instruction fetch (IF) stage for fetching an instruction pointed to by an instruction fetch address (IFA) register that is to be later executed by an execution (EX) stage;
providing a branch prediction result obtained by the PF stage to the IF stage;
setting a next address of the PFA register to be sequentially after a current address of the PFA register, and setting a next address of the IFA register to be the current address of the PFA register, if the branch prediction result predicts no branching; and
setting the next address of the PFA register to be sequentially after a predicted branch address, and simultaneously setting the next address of the IFA register to be the predicted branch address, if the branch prediction result predicts a branch.

### Claim 8 (depends on 7)

The method of claim 7 further comprising ignoring a current branch prediction result from the PF stage when the previous branch prediction result predicts a branch.

### Claim 9 (depends on 7)

The method of claim 7 wherein the PF stage immediately precedes the IF stage, and the EX stage is subsequent the IF stage.

### Claim 10 (depends on 9)

The method of claim 9 further comprising:
if the EX stage determines that an executed instruction at a first address was incorrectly branch-predicted, setting the next address of the IFA register to a second address that is sequentially alter the first address, and simultaneously setting the next address of the PFA register to a third address that is sequentially after the second address.

### Claim 11 (depends on 10)

The method claim 10 further comprising ignoring a current branch prediction result from the PF stage when the EX stage determines that the executed instruction at the first address was incorrectly branch-predicted.

### Claim 12 (depends on 9)

The method of claim 9 further comprising:
if the EX stage determines that an executed instruction at a first address was incorrectly branch-predicted, setting the next address of the IFA register to a second address that is a target address as determined by the EX stage, and simultaneously setting the next address of the PFA register to a third address that is sequentially after the second address.

### Claim 13 (depends on 12)

The method claim 12 further comprising ignoring a current branch prediction result from the PF stage when the EX stage determines that the executed instruction at the first address was incorrectly branch-predicted.

### Claim 14 (depends on 7)

An electronic circuit for implementing the method of claim 7.
