Processor Branch Prediction Error Detection and Pipeline Flush

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing processor architectures face inefficiencies due to the latency and penalties associated with branch prediction errors, particularly when dealing with non-fix length instructions, which can lead to increased processing time and resource wastage.

Innovation Solution

A method and processor architecture that enable earlier detection of branch prediction errors by writing the instruction stream into both the instruction data cache and a branch prediction error determination unit in parallel, allowing for immediate correction and flushing of incorrectly fetched instructions.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If branch prediction is used to improve instruction fetch efficiency, then processor throughput is improved, but when a branch prediction error occurs, significant latency and performance penalties are incurred

Engineering Contradiction:
Improveprocessor throughputVSAvoidbranch prediction error latency
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent applies preliminary action by performing branch prediction and fetching instructions speculatively before the actual branch outcome is known. The instruction fetch unit predicts branch targets and pre-fetches instructions from predicted paths, so that when the prediction is correct, execution can proceed without interruption. This speculative pre-fetching improves throughput while the prediction mechanism is designed to minimize the impact of errors.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent implements skipping by using multiple instruction buffers (first instruction buffer and second instruction buffer) that can be independently accessed. When a branch prediction error is detected, the system can quickly switch to the correct instruction buffer without flushing the entire pipeline, effectively skipping over the incorrectly fetched instructions and resuming execution with minimal latency.

Inventive Principle:
Principle #21Skipping (Rushing through)

2Device complexity

If traditional sequential branch prediction checking is used, then detection logic is simple, but error detection occurs too late to minimize pipeline flush penalties

Engineering Contradiction:
Improvedetection logic complexityVSAvoiderror detection delay
Core Design Contradiction:
Device complexityVSLoss of time

Solution Approach 1:

The patent performs branch prediction validation in advance by comparing the actual branch outcome with the predicted branch outcome before instruction execution completes. The branch prediction checking unit validates predictions during the instruction fetch and decode stages, allowing early detection of prediction errors before they propagate deep into the execution pipeline, thereby minimizing flush penalties.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent segments the instruction fetch and validation process into separate functional units: an instruction fetch unit that performs speculative fetching, a branch prediction checking unit that validates predictions, and instruction buffers that store fetched instructions. This segmentation allows parallel execution of fetch and validation operations, enabling timely error detection without significantly increasing overall system complexity.

Inventive Principle:
Principle #1Segmentation

3Loss of time

If parallel writing to instruction cache and branch prediction unit is implemented, then error detection timing is improved, but additional hardware resources are required

Engineering Contradiction:
Improveerror detection timingVSAvoidhardware resources
Core Design Contradiction:
Loss of timeVSDevice complexity

Solution Approach 1:

The patent merges the branch prediction functionality with the instruction cache structure by implementing a unified branch prediction checking unit that operates in parallel with the instruction fetch unit. The branch prediction tags and instruction cache entries are coordinated through shared control signals and status flags, allowing simultaneous validation of branch predictions and caching of instructions without requiring completely separate hardware subsystems.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent designs the branch prediction checking unit to serve multiple functions: it validates branch predictions, identifies prediction errors, and triggers appropriate pipeline control signals. The instruction buffers are designed to handle both correctly fetched instructions and potentially incorrect instructions, with validity tags that indicate whether instructions should be executed or flushed. This multi-functionality reduces the need for dedicated specialized hardware for each function.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS20250147769A1Method for processing instruction, processor, electronic apparatus and storage medium
Publication Date: 2025.05.08 BEIJING ESWIN COMPUTING TECH CO LTD
  • US20250147769A1 patent drawing
  • US20250147769A1 patent drawing
  • US20250147769A1 patent drawing

AI summary

A method for processing an instruction, a processor, an electronic apparatus and a storage medium are provided. The method for processing the instruction includes: writing an instruction stream into an instruction data cache and a branch prediction error determination unit in parallel in an instruction processing pipeline, and determining a branch instruction in the instruction stream and whether a branch prediction error exists for the branch instruction in the branch prediction error determination unit; and in response to the branch prediction error existing for the branch instruction, performing a flush operation on an object instruction in the instruction processing pipeline that is fetched due to the branch prediction error.