BPU Global Interface

This section introduces the definition of the overall external interaction interface of the Xiangshan Branch Prediction Unit, including the presentation of global branch prediction results and single pipeline stage prediction results.

BPU Module Overall External Interface (PredirectIO)

Interface definition: src/main/scala/xiangshan/frontend/BPU.scala

PredirectIO is the overall external interface of the branch predictor (BPU). It mainly handles the interaction between the branch predictor (BPU) and the fetch target queue (FTQ), which includes the following parts:

  • bpu_to_ftq: Information sent from BPU to FTQ, mainly for sending branch prediction results from BPU to FTQ
    • Interface type: BpuToFtqIO
    • Interface type:
      • resp: Global branch prediction information sent from BPU to FTQ
        • Interface type:DecoupledIO(new BpuToFtqBundle())
          • BpuToFtqBundle inherits from BranchPredictionResp,without additional signals
        • Interface type:See (BranchPredictionResp)
  • ftq_to_bpu: Information sent from FTQ to BPU, mainly for handling redirect and update requests
    • Interface type: FtqToBpuIO
    • Interface type:
      • redirect: Redirect request sent from FTQ to BPU
        • Interface type: Valid(new BranchPredictionRedirect)
        • Interface list:See (BranchPredictionRedirect
      • update: Update request sent from FTQ to BPU
        • Interface type:Valid(new BranchPredictionUpdate)
        • Interface list:See (BranchPredictionUpdate
      • enq_ptr: FTQ pointer sent to BPU, indicating which FTQ entry to write to next
        • Interface type:FtqPtr
  • ctrl: BPU control signals, mainly for enabling various predictors
    • Interface type:BPUCtrl
    • Interface list:
      • ubtb_enable: UBTB predictor enable
        • Interface type:Bool()
      • btb_enable: BTB predictor enable
        • Interface type:Bool()
      • bim_enable: BIM predictor enable
        • Interface type:Bool()
      • tage_enable: TAGE predictor enable
        • Interface type:Bool()
      • sc_enable: SC predictor enable
        • Interface type:Bool()
      • ras_enable: RAS predictor enable
        • Interface type:Bool()
      • loop_enable: LOOP predictor enable
        • Interface type:Bool()
  • reset_vector: Reset vector, which the BPU’s PC will be reset to upon reset
    • Interface type:UInt(PAddrBits.W)

Global Branch Prediction Information (BranchPredictionResp)

Interface definition: src/main/scala/xiangshan/frontend/FrontendBundle.scala

This interface defines all the prediction result information of the branch predictor, including the prediction results of each stage and the related information output by the last pipeline stage.

  • s1 Branch prediction result of the s1 pipeline stage
  • s2 Branch prediction result of the s2 pipeline stage
  • s3 Branch prediction result of the s3 pipeline stage
    • Interface type:BranchPredictionBundle
    • Interface type:See (BranchPredictionBundle
  • last_stage_meta Metadata of the prediction result output by the last pipeline stage. It is a bit vector output by each predictor and combined by the Composer.
    • Interface type:UInt(MaxMetaLength.W)
  • last_stage_spec_info Related information of the prediction result output by the last pipeline stage
    • Interface type:Ftq_Redirect_SRAMEntry
    • Interface list:
      • folded_hist Global folded history
        • Interface type:AllFoldedHistories(foldedGHistInfos)
      • afhob Global branch history oldest bit
        • Interface type:AllAheadFoldedHistoryOldestBits(foldedGHistInfos)
      • lastBrNumOH Last branch position
        • Interface type:UInt((numBr+1).W)
      • histPtr Global branch history pointer
        • Interface type:CGHPtr
      • ssp RAS speculation stack pointer at commit stack position
        • Interface type:UInt(log2Up(RasSize).W)
      • sctr RAS speculation stack recursion counter
        • Interface type:UInt(log2Up(RasCtrSize).W)
      • TOSW RAS speculation stack (queue) write pointer
        • Interface type:CGHPtr
      • TOSR RAS speculation stack (queue) read pointer
        • Interface type:CGHPtr
      • NOS RAS stack top counter
        • Interface type:CGHPtr
      • topAddr RAS stack top return address
        • Interface type:UInt(VAddrBits.W)
  • last_stage_ftb_entry FTB entry output by the last pipeline stage
    • Interface type:FtqEntry
    • Interface list:See(FtqEntry

FTB entry output by the last pipeline stage

Interface definition: src/main/scala/xiangshan/frontend/FrontendBundle.scala

This interface defines the branch prediction result information output by each pipeline stage,

  • pc Starting PC of the predicted block
    • Interface type: Vec(numDup, UInt(VAddrBits.W)) numDup is only for register replication, with identical signals
  • valid Whether the prediction result is valid
    • Interface type: Vec(numDup, Bool())
  • hasRedirect Whether a redirect is needed
    • Interface description: Only the s2 and s3 stages will redirect, and the prediction result of this stage will override the previous pipeline stage’s result when a redirect occurs
    • Interface type: Vec(numDup, Bool())
  • ftq_idx FTQ pointer, pointing to the FTQ entry corresponding to the prediction information of this stage
    • Interface type: new FtqPtr
  • full_pred Complete branch prediction result
    • Interface type: Vec(numDup, new FullBranchPrediction)
    • Interface list: See (FullBranchPrediction)
Last modified September 13, 2024: Update the picture of BPU Top. (431c050)