Method and apparatus for implementing a set-associative branch target buffer
First Claim
1. A branch instruction prediction mechanism, said branch instruction prediction mechanism predicting a plurality of branch instructions within a stream of computer instructions, said branch instruction prediction mechanism comprising:
- an instruction pointer for identifying an instruction address in a memory, said instruction pointer having a set of branch target buffer set address bits and a set of branch target buffer tag address bits;
a branch target buffer cache, said branch target buffer cache comprising a plurality of branch set entries, each of said branch set entries comprising a set of branch instruction entries, each branch instruction entry storing information about an associated branch instruction including a position with a memory block, all branch instruction entries within a particular branch set entry storing branch instructions having identical branch target buffer set address bits; and
a branch target buffer circuit, said branch target buffer circuit receiving said instruction pointer, said branch target buffer circuit indexing into said branch target buffer cache with said set of branch target buffer set address bits of said instruction pointer to select a branch set entry, said branch target buffer circuit selecting at least one branch instruction entry in said branch set entry using said branch target buffer tag address bits of said instruction pointer.
1 Assignment
0 Petitions
Accused Products
Abstract
A Branch Target Buffer Circuit in a computer processor that predicts branch instructions with a stream of computer instructions is disclosed. The Branch Target Buffer Circuit uses a Branch Target Buffer Cache that stores branch information about previously executed branch instructions. The branch information stored in the Branch Target Buffer Cache is addressed by the last byte of each branch instruction. When an Instruction Fetch Unit in the computer processor fetches a block of instructions it sends the Branch Target Buffer Circuit an instruction pointer. Based on the instruction pointer, the Branch Target Buffer Circuit looks in the Branch Target Buffer Cache to see if any of the instructions in the block being fetched is a branch instruction. When the Branch Target Buffer Circuit finds an upcoming branch instruction in the Branch Target Buffer Cache, the Branch Target Buffer Circuit informs an Instruction Fetch Unit about the upcoming branch instruction.
-
Citations
17 Claims
-
1. A branch instruction prediction mechanism, said branch instruction prediction mechanism predicting a plurality of branch instructions within a stream of computer instructions, said branch instruction prediction mechanism comprising:
-
an instruction pointer for identifying an instruction address in a memory, said instruction pointer having a set of branch target buffer set address bits and a set of branch target buffer tag address bits; a branch target buffer cache, said branch target buffer cache comprising a plurality of branch set entries, each of said branch set entries comprising a set of branch instruction entries, each branch instruction entry storing information about an associated branch instruction including a position with a memory block, all branch instruction entries within a particular branch set entry storing branch instructions having identical branch target buffer set address bits; and a branch target buffer circuit, said branch target buffer circuit receiving said instruction pointer, said branch target buffer circuit indexing into said branch target buffer cache with said set of branch target buffer set address bits of said instruction pointer to select a branch set entry, said branch target buffer circuit selecting at least one branch instruction entry in said branch set entry using said branch target buffer tag address bits of said instruction pointer. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
-
-
15. A method of updating a branch target buffer cache, said method comprising the steps of:
-
executing a branch instruction to determine a final branch outcome and a final branch target address for said branch instruction; finding a branch set entry in said branch target buffer cache by indexing into said branch target buffer using an address of a last byte of said branch instruction; finding a branch instruction entry associated with said branch instruction in said branch set entry; updating a branch target address in said branch instruction entry associated with said branch instruction using said final branch target address; updating a branch pattern table associated with said branch set entry in said branch target buffer if said branch instruction is a conditional branch instruction; updating a branch history associated with said branch instruction entry if said branch instruction is a conditional branch instruction; matching a subset of most significant bits from said address of a last byte of said branch instruction with a tag field in said branch entry. - View Dependent Claims (16)
-
-
17. A method of creating a branch instruction entry in a branch target buffer cache to store information about a discovered branch instruction, said branch target buffer cache organized into a plurality of branch set entries, each branch set entry comprising a set of branch instruction entries, said method comprising the steps of:
-
executing said discovered branch instruction to determine a final branch outcome and a final branch target address for said discovered branch instruction; determining if said discovered branch instruction was mispredicted by comparing said final branch outcome and said final branch target address to a predicted branch outcome and a predicted branch target address; allocating a branch instruction entry in said branch target buffer cache if said discovered branch instruction was mispredicted or if said final branch outcome of said discovered branch instruction was taken, said step of allocating a branch instruction entry comprising the substeps of; reading a least recently replaced value from a least recently replaced field associated branch set entry; replacing a branch instruction entry indicated by said least recently replaced value if said first branch entry does not have a matching tag address field; incrementing said least recently replaced value and repeating said step until all branch instruction entries have been examined if said branch entry has a matching tag address field; and replacing a branch instruction entry pointed to by said least recently replaced value as originally read from said least recently replaced field if all branch instruction entries have matching tag address fields.
-
Specification