Skip to content

Commit

Permalink
Update branch predictor skeleton code
Browse files Browse the repository at this point in the history
  • Loading branch information
minseongg committed Sep 3, 2024
1 parent 6d71918 commit 2a49f16
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions hazardflow-designs/src/cpu/branch_predictor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,34 @@ pub const BHT_ENTRIES: usize = 128;
/// Number of BTB entries.
pub const BTB_ENTRIES: usize = 32;

/// Branch prediction info.
/// Branch prediction results.
#[derive(Debug, Clone, Copy)]
pub struct BpInfo {
pub struct BpResult {
/// Pre-decode result.
pub pre_decoded: PreDecodeResp,
pub pre_decode: PreDecodeResp,

/// Branch was taken or not?
pub is_taken: bool,
/// Predicted branch direction (used for branch instructions).
pub bht: bool,

/// Target address.
pub target: u32,
/// Predicted target address (used for JALR instruction).
pub btb: u32,
}

/// Branch prediction update.
#[derive(Debug, Clone, Copy)]
pub enum BpUpdate {
/// Updates BHT. Contains PC.
/// Updates BHT.
///
/// It contains the mispredicted PC.
Bht(u32),

/// Updates BTB. Contains (PC, target).
Btb(u32, u32),
/// Updates BTB.
///
/// It contains the mispredicted PC and the correct target address.
Btb {
/// Mispredicted PC.
pc: u32,
/// Correct target address.
target: u32,
},
}

0 comments on commit 2a49f16

Please sign in to comment.