xref: /XiangShan/src/main/scala/xiangshan/frontend/RAS.scala (revision cf7d6b7a1a781c73aeb87de112de2e7fe5ea3b7c)
109c6f1ddSLingrui98/***************************************************************************************
209c6f1ddSLingrui98* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
309c6f1ddSLingrui98* Copyright (c) 2020-2021 Peng Cheng Laboratory
409c6f1ddSLingrui98*
509c6f1ddSLingrui98* XiangShan is licensed under Mulan PSL v2.
609c6f1ddSLingrui98* You can use this software according to the terms and conditions of the Mulan PSL v2.
709c6f1ddSLingrui98* You may obtain a copy of Mulan PSL v2 at:
809c6f1ddSLingrui98*          http://license.coscl.org.cn/MulanPSL2
909c6f1ddSLingrui98*
1009c6f1ddSLingrui98* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
1109c6f1ddSLingrui98* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
1209c6f1ddSLingrui98* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
1309c6f1ddSLingrui98*
1409c6f1ddSLingrui98* See the Mulan PSL v2 for more details.
1509c6f1ddSLingrui98***************************************************************************************/
16c89b4642SGuokai Chen/*
1709c6f1ddSLingrui98package xiangshan.frontend
1809c6f1ddSLingrui98
19*8891a219SYinan Xuimport org.chipsalliance.cde.config.Parameters
2009c6f1ddSLingrui98import chisel3._
2109c6f1ddSLingrui98import chisel3.util._
2209c6f1ddSLingrui98import utils._
233c02ee8fSwakafaimport utility._
2409c6f1ddSLingrui98import xiangshan._
2509c6f1ddSLingrui98
26adc0b8dfSGuokai Chenimport scala.{Tuple2 => &}
27adc0b8dfSGuokai Chen
28adc0b8dfSGuokai Chen
2909c6f1ddSLingrui98class RASEntry()(implicit p: Parameters) extends XSBundle {
3009c6f1ddSLingrui98    val retAddr = UInt(VAddrBits.W)
3109c6f1ddSLingrui98    val ctr = UInt(8.W) // layer of nested call functions
3209c6f1ddSLingrui98}
3309c6f1ddSLingrui98
3409c6f1ddSLingrui98class RAS(implicit p: Parameters) extends BasePredictor {
3509c6f1ddSLingrui98  object RASEntry {
3609c6f1ddSLingrui98    def apply(retAddr: UInt, ctr: UInt): RASEntry = {
3709c6f1ddSLingrui98      val e = Wire(new RASEntry)
3809c6f1ddSLingrui98      e.retAddr := retAddr
3909c6f1ddSLingrui98      e.ctr := ctr
4009c6f1ddSLingrui98      e
4109c6f1ddSLingrui98    }
4209c6f1ddSLingrui98  }
4309c6f1ddSLingrui98
4409c6f1ddSLingrui98  class RASStack(val rasSize: Int) extends XSModule {
4509c6f1ddSLingrui98    val io = IO(new Bundle {
4609c6f1ddSLingrui98      val push_valid = Input(Bool())
4709c6f1ddSLingrui98      val pop_valid = Input(Bool())
4809c6f1ddSLingrui98      val spec_new_addr = Input(UInt(VAddrBits.W))
4909c6f1ddSLingrui98
5009c6f1ddSLingrui98      val recover_sp = Input(UInt(log2Up(rasSize).W))
5109c6f1ddSLingrui98      val recover_top = Input(new RASEntry)
5209c6f1ddSLingrui98      val recover_valid = Input(Bool())
5309c6f1ddSLingrui98      val recover_push = Input(Bool())
5409c6f1ddSLingrui98      val recover_pop = Input(Bool())
5509c6f1ddSLingrui98      val recover_new_addr = Input(UInt(VAddrBits.W))
5609c6f1ddSLingrui98
5709c6f1ddSLingrui98      val sp = Output(UInt(log2Up(rasSize).W))
5809c6f1ddSLingrui98      val top = Output(new RASEntry)
5909c6f1ddSLingrui98    })
6009c6f1ddSLingrui98
6109c6f1ddSLingrui98    val debugIO = IO(new Bundle{
627e8709feSLingrui98        val spec_push_entry = Output(new RASEntry)
637e8709feSLingrui98        val spec_alloc_new = Output(Bool())
647e8709feSLingrui98        val recover_push_entry = Output(new RASEntry)
657e8709feSLingrui98        val recover_alloc_new = Output(Bool())
6609c6f1ddSLingrui98        val sp = Output(UInt(log2Up(rasSize).W))
6709c6f1ddSLingrui98        val topRegister = Output(new RASEntry)
6809c6f1ddSLingrui98        val out_mem = Output(Vec(RasSize, new RASEntry))
6909c6f1ddSLingrui98    })
7009c6f1ddSLingrui98
7109c6f1ddSLingrui98    val stack = Mem(RasSize, new RASEntry)
7209c6f1ddSLingrui98    val sp = RegInit(0.U(log2Up(rasSize).W))
738088cde1SGuokai Chen    val top = RegInit(0.U.asTypeOf(new RASEntry()))
7409c6f1ddSLingrui98    val topPtr = RegInit(0.U(log2Up(rasSize).W))
7509c6f1ddSLingrui98
76d0a8077aSLingrui98    val wen = WireInit(false.B)
778088cde1SGuokai Chen    val write_bypass_entry = RegInit(0.U.asTypeOf(new RASEntry()))
78eb6496c5SLingrui98    val write_bypass_ptr = RegInit(0.U(log2Up(rasSize).W))
79eb6496c5SLingrui98    val write_bypass_valid = RegInit(false.B)
80d0a8077aSLingrui98    when (wen) {
81d0a8077aSLingrui98      write_bypass_valid := true.B
82d0a8077aSLingrui98    }.elsewhen (write_bypass_valid) {
83d0a8077aSLingrui98      write_bypass_valid := false.B
84d0a8077aSLingrui98    }
85d0a8077aSLingrui98
86d0a8077aSLingrui98    when (write_bypass_valid) {
87d0a8077aSLingrui98      stack(write_bypass_ptr) := write_bypass_entry
88d0a8077aSLingrui98    }
89d0a8077aSLingrui98
9009c6f1ddSLingrui98    def ptrInc(ptr: UInt) = Mux(ptr === (rasSize-1).U, 0.U, ptr + 1.U)
9109c6f1ddSLingrui98    def ptrDec(ptr: UInt) = Mux(ptr === 0.U, (rasSize-1).U, ptr - 1.U)
9209c6f1ddSLingrui98
937e8709feSLingrui98    val spec_alloc_new = io.spec_new_addr =/= top.retAddr || top.ctr.andR
9409c6f1ddSLingrui98    val recover_alloc_new = io.recover_new_addr =/= io.recover_top.retAddr || io.recover_top.ctr.andR
9509c6f1ddSLingrui98
9609c6f1ddSLingrui98    // TODO: fix overflow and underflow bugs
9709c6f1ddSLingrui98    def update(recover: Bool)(do_push: Bool, do_pop: Bool, do_alloc_new: Bool,
9809c6f1ddSLingrui98                              do_sp: UInt, do_top_ptr: UInt, do_new_addr: UInt,
9909c6f1ddSLingrui98                              do_top: RASEntry) = {
10009c6f1ddSLingrui98      when (do_push) {
10109c6f1ddSLingrui98        when (do_alloc_new) {
10209c6f1ddSLingrui98          sp     := ptrInc(do_sp)
10309c6f1ddSLingrui98          topPtr := do_sp
10409c6f1ddSLingrui98          top.retAddr := do_new_addr
1057e8709feSLingrui98          top.ctr := 0.U
106d0a8077aSLingrui98          // write bypass
107d0a8077aSLingrui98          wen := true.B
108d0a8077aSLingrui98          write_bypass_entry := RASEntry(do_new_addr, 0.U)
109d0a8077aSLingrui98          write_bypass_ptr := do_sp
11009c6f1ddSLingrui98        }.otherwise {
11109c6f1ddSLingrui98          when (recover) {
11209c6f1ddSLingrui98            sp := do_sp
11309c6f1ddSLingrui98            topPtr := do_top_ptr
11409c6f1ddSLingrui98            top.retAddr := do_top.retAddr
11509c6f1ddSLingrui98          }
11609c6f1ddSLingrui98          top.ctr := do_top.ctr + 1.U
117d0a8077aSLingrui98          // write bypass
118d0a8077aSLingrui98          wen := true.B
119d0a8077aSLingrui98          write_bypass_entry := RASEntry(do_new_addr, do_top.ctr + 1.U)
120d0a8077aSLingrui98          write_bypass_ptr := do_top_ptr
12109c6f1ddSLingrui98        }
12209c6f1ddSLingrui98      }.elsewhen (do_pop) {
1237e8709feSLingrui98        when (do_top.ctr === 0.U) {
12409c6f1ddSLingrui98          sp     := ptrDec(do_sp)
12509c6f1ddSLingrui98          topPtr := ptrDec(do_top_ptr)
126d0a8077aSLingrui98          // read bypass
127d0a8077aSLingrui98          top :=
128d0a8077aSLingrui98            Mux(ptrDec(do_top_ptr) === write_bypass_ptr && write_bypass_valid,
129d0a8077aSLingrui98              write_bypass_entry,
130d0a8077aSLingrui98              stack.read(ptrDec(do_top_ptr))
131d0a8077aSLingrui98            )
13209c6f1ddSLingrui98        }.otherwise {
13309c6f1ddSLingrui98          when (recover) {
13409c6f1ddSLingrui98            sp := do_sp
13509c6f1ddSLingrui98            topPtr := do_top_ptr
13609c6f1ddSLingrui98            top.retAddr := do_top.retAddr
13709c6f1ddSLingrui98          }
13809c6f1ddSLingrui98          top.ctr := do_top.ctr - 1.U
139d0a8077aSLingrui98          // write bypass
140d0a8077aSLingrui98          wen := true.B
141d0a8077aSLingrui98          write_bypass_entry := RASEntry(do_top.retAddr, do_top.ctr - 1.U)
142d0a8077aSLingrui98          write_bypass_ptr := do_top_ptr
14309c6f1ddSLingrui98        }
14409c6f1ddSLingrui98      }.otherwise {
14509c6f1ddSLingrui98        when (recover) {
14609c6f1ddSLingrui98          sp := do_sp
14709c6f1ddSLingrui98          topPtr := do_top_ptr
14809c6f1ddSLingrui98          top := do_top
149d0a8077aSLingrui98          // write bypass
150d0a8077aSLingrui98          wen := true.B
151d0a8077aSLingrui98          write_bypass_entry := do_top
152d0a8077aSLingrui98          write_bypass_ptr := do_top_ptr
15309c6f1ddSLingrui98        }
15409c6f1ddSLingrui98      }
15509c6f1ddSLingrui98    }
15609c6f1ddSLingrui98
157d717fd1eSLingrui98
15809c6f1ddSLingrui98    update(io.recover_valid)(
15909c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_push,     io.push_valid),
16009c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_pop,      io.pop_valid),
1617e8709feSLingrui98      Mux(io.recover_valid, recover_alloc_new,   spec_alloc_new),
16209c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_sp,       sp),
16309c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_sp - 1.U, topPtr),
16409c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_new_addr, io.spec_new_addr),
16509c6f1ddSLingrui98      Mux(io.recover_valid, io.recover_top,      top))
16609c6f1ddSLingrui98
16709c6f1ddSLingrui98    io.sp := sp
16809c6f1ddSLingrui98    io.top := top
16909c6f1ddSLingrui98
1706fe623afSLingrui98    val resetIdx = RegInit(0.U(log2Ceil(RasSize).W))
1716fe623afSLingrui98    val do_reset = RegInit(true.B)
1726fe623afSLingrui98    when (do_reset) {
1736fe623afSLingrui98      stack.write(resetIdx, RASEntry(0x80000000L.U, 0.U))
1746fe623afSLingrui98    }
1756fe623afSLingrui98    resetIdx := resetIdx + do_reset
1766fe623afSLingrui98    when (resetIdx === (RasSize-1).U) {
1776fe623afSLingrui98      do_reset := false.B
1786fe623afSLingrui98    }
1796fe623afSLingrui98
1807e8709feSLingrui98    debugIO.spec_push_entry := RASEntry(io.spec_new_addr, Mux(spec_alloc_new, 1.U, top.ctr + 1.U))
1817e8709feSLingrui98    debugIO.spec_alloc_new := spec_alloc_new
1827e8709feSLingrui98    debugIO.recover_push_entry := RASEntry(io.recover_new_addr, Mux(recover_alloc_new, 1.U, io.recover_top.ctr + 1.U))
1837e8709feSLingrui98    debugIO.recover_alloc_new := recover_alloc_new
18409c6f1ddSLingrui98    debugIO.sp := sp
18509c6f1ddSLingrui98    debugIO.topRegister := top
18609c6f1ddSLingrui98    for (i <- 0 until RasSize) {
187d0a8077aSLingrui98        debugIO.out_mem(i) := Mux(i.U === write_bypass_ptr && write_bypass_valid, write_bypass_entry, stack.read(i.U))
18809c6f1ddSLingrui98    }
18909c6f1ddSLingrui98  }
19009c6f1ddSLingrui98
19109c6f1ddSLingrui98  val spec = Module(new RASStack(RasSize))
19209c6f1ddSLingrui98  val spec_ras = spec.io
193cb4f77ceSLingrui98  val spec_top_addr = spec_ras.top.retAddr
19409c6f1ddSLingrui98
19509c6f1ddSLingrui98
196cb4f77ceSLingrui98  val s2_spec_push = WireInit(false.B)
197cb4f77ceSLingrui98  val s2_spec_pop = WireInit(false.B)
198f4ebc4b2SLingrui98  val s2_full_pred = io.in.bits.resp_in(0).s2.full_pred
199f4ebc4b2SLingrui98  // when last inst is an rvi call, fall through address would be set to the middle of it, so an addition is needed
200adc0b8dfSGuokai Chen  val s2_spec_new_addr = s2_full_pred(2).fallThroughAddr + Mux(s2_full_pred(2).last_may_be_rvi_call, 2.U, 0.U)
201cb4f77ceSLingrui98  spec_ras.push_valid := s2_spec_push
202cb4f77ceSLingrui98  spec_ras.pop_valid  := s2_spec_pop
203cb4f77ceSLingrui98  spec_ras.spec_new_addr := s2_spec_new_addr
20409c6f1ddSLingrui98
20509c6f1ddSLingrui98  // confirm that the call/ret is the taken cfi
206adc0b8dfSGuokai Chen  s2_spec_push := io.s2_fire(2) && s2_full_pred(2).hit_taken_on_call && !io.s3_redirect(2)
207adc0b8dfSGuokai Chen  s2_spec_pop  := io.s2_fire(2) && s2_full_pred(2).hit_taken_on_ret  && !io.s3_redirect(2)
20809c6f1ddSLingrui98
209adc0b8dfSGuokai Chen  val s2_jalr_target_dup = io.out.s2.full_pred.map(_.jalr_target)
210adc0b8dfSGuokai Chen  val s2_last_target_in_dup = s2_full_pred.map(_.targets.last)
211adc0b8dfSGuokai Chen  val s2_last_target_out_dup = io.out.s2.full_pred.map(_.targets.last)
212adc0b8dfSGuokai Chen  val s2_is_jalr_dup = s2_full_pred.map(_.is_jalr)
213adc0b8dfSGuokai Chen  val s2_is_ret_dup = s2_full_pred.map(_.is_ret)
214b30c10d6SLingrui98  // assert(is_jalr && is_ret || !is_ret)
215adc0b8dfSGuokai Chen  val ras_enable_dup = dup(RegNext(io.ctrl.ras_enable))
216adc0b8dfSGuokai Chen  for (ras_enable & s2_is_ret & s2_jalr_target <-
217adc0b8dfSGuokai Chen    ras_enable_dup zip s2_is_ret_dup zip s2_jalr_target_dup) {
218adc0b8dfSGuokai Chen      when(s2_is_ret && ras_enable) {
219cb4f77ceSLingrui98        s2_jalr_target := spec_top_addr
220b30c10d6SLingrui98        // FIXME: should use s1 globally
22109c6f1ddSLingrui98      }
222adc0b8dfSGuokai Chen    }
223adc0b8dfSGuokai Chen  for (s2_lto & s2_is_jalr & s2_jalr_target & s2_lti <-
224adc0b8dfSGuokai Chen    s2_last_target_out_dup zip s2_is_jalr_dup zip s2_jalr_target_dup zip s2_last_target_in_dup) {
225adc0b8dfSGuokai Chen      s2_lto := Mux(s2_is_jalr, s2_jalr_target, s2_lti)
226adc0b8dfSGuokai Chen    }
22709c6f1ddSLingrui98
228adc0b8dfSGuokai Chen  val s3_top_dup = io.s2_fire.map(f => RegEnable(spec_ras.top, f))
229adc0b8dfSGuokai Chen  val s3_sp = RegEnable(spec_ras.sp, io.s2_fire(2))
230adc0b8dfSGuokai Chen  val s3_spec_new_addr = RegEnable(s2_spec_new_addr, io.s2_fire(2))
231cb4f77ceSLingrui98
232adc0b8dfSGuokai Chen  val s3_full_pred = io.in.bits.resp_in(0).s3.full_pred
233adc0b8dfSGuokai Chen  val s3_jalr_target_dup = io.out.s3.full_pred.map(_.jalr_target)
234adc0b8dfSGuokai Chen  val s3_last_target_in_dup = s3_full_pred.map(_.targets.last)
235adc0b8dfSGuokai Chen  val s3_last_target_out_dup = io.out.s3.full_pred.map(_.targets.last)
236adc0b8dfSGuokai Chen  val s3_is_jalr_dup = s3_full_pred.map(_.is_jalr)
237adc0b8dfSGuokai Chen  val s3_is_ret_dup = s3_full_pred.map(_.is_ret)
238cb4f77ceSLingrui98  // assert(is_jalr && is_ret || !is_ret)
239adc0b8dfSGuokai Chen
240adc0b8dfSGuokai Chen  for (ras_enable & s3_is_ret & s3_jalr_target & s3_top <-
241adc0b8dfSGuokai Chen    ras_enable_dup zip s3_is_ret_dup zip s3_jalr_target_dup zip s3_top_dup) {
242adc0b8dfSGuokai Chen      when(s3_is_ret && ras_enable) {
243cb4f77ceSLingrui98        s3_jalr_target := s3_top.retAddr
244cb4f77ceSLingrui98        // FIXME: should use s1 globally
245cb4f77ceSLingrui98      }
246adc0b8dfSGuokai Chen    }
247adc0b8dfSGuokai Chen  for (s3_lto & s3_is_jalr & s3_jalr_target & s3_lti <-
248adc0b8dfSGuokai Chen    s3_last_target_out_dup zip s3_is_jalr_dup zip s3_jalr_target_dup zip s3_last_target_in_dup) {
249adc0b8dfSGuokai Chen      s3_lto := Mux(s3_is_jalr, s3_jalr_target, s3_lti)
250adc0b8dfSGuokai Chen    }
251cb4f77ceSLingrui98
252adc0b8dfSGuokai Chen  val s3_pushed_in_s2 = RegEnable(s2_spec_push, io.s2_fire(2))
253adc0b8dfSGuokai Chen  val s3_popped_in_s2 = RegEnable(s2_spec_pop,  io.s2_fire(2))
254adc0b8dfSGuokai Chen  val s3_push = io.in.bits.resp_in(0).s3.full_pred(2).hit_taken_on_call
255adc0b8dfSGuokai Chen  val s3_pop  = io.in.bits.resp_in(0).s3.full_pred(2).hit_taken_on_ret
256cb4f77ceSLingrui98
257adc0b8dfSGuokai Chen  val s3_recover = io.s3_fire(2) && (s3_pushed_in_s2 =/= s3_push || s3_popped_in_s2 =/= s3_pop)
258c2d1ec7dSLingrui98  io.out.last_stage_spec_info.rasSp  := s3_sp
259adc0b8dfSGuokai Chen  io.out.last_stage_spec_info.rasTop := s3_top_dup(2)
26009c6f1ddSLingrui98
26109c6f1ddSLingrui98
26209c6f1ddSLingrui98  val redirect = RegNext(io.redirect)
263cb4f77ceSLingrui98  val do_recover = redirect.valid || s3_recover
26409c6f1ddSLingrui98  val recover_cfi = redirect.bits.cfiUpdate
26509c6f1ddSLingrui98
26609c6f1ddSLingrui98  val retMissPred  = do_recover && redirect.bits.level === 0.U && recover_cfi.pd.isRet
26709c6f1ddSLingrui98  val callMissPred = do_recover && redirect.bits.level === 0.U && recover_cfi.pd.isCall
26809c6f1ddSLingrui98  // when we mispredict a call, we must redo a push operation
26909c6f1ddSLingrui98  // similarly, when we mispredict a return, we should redo a pop
27009c6f1ddSLingrui98  spec_ras.recover_valid := do_recover
2715df98e43SLingrui98  spec_ras.recover_push := Mux(redirect.valid, callMissPred, s3_push)
2725df98e43SLingrui98  spec_ras.recover_pop  := Mux(redirect.valid, retMissPred, s3_pop)
27309c6f1ddSLingrui98
274cb4f77ceSLingrui98  spec_ras.recover_sp  := Mux(redirect.valid, recover_cfi.rasSp, s3_sp)
275adc0b8dfSGuokai Chen  spec_ras.recover_top := Mux(redirect.valid, recover_cfi.rasEntry, s3_top_dup(2))
276cb4f77ceSLingrui98  spec_ras.recover_new_addr := Mux(redirect.valid, recover_cfi.pc + Mux(recover_cfi.pd.isRVC, 2.U, 4.U), s3_spec_new_addr)
27709c6f1ddSLingrui98
278cb4f77ceSLingrui98
279cb4f77ceSLingrui98  XSPerfAccumulate("ras_s3_recover", s3_recover)
280cb4f77ceSLingrui98  XSPerfAccumulate("ras_redirect_recover", redirect.valid)
281cb4f77ceSLingrui98  XSPerfAccumulate("ras_s3_and_redirect_recover_at_the_same_time", s3_recover && redirect.valid)
28209c6f1ddSLingrui98  // TODO: back-up stack for ras
28309c6f1ddSLingrui98  // use checkpoint to recover RAS
28409c6f1ddSLingrui98
28509c6f1ddSLingrui98  val spec_debug = spec.debugIO
28609c6f1ddSLingrui98  XSDebug("----------------RAS----------------\n")
28709c6f1ddSLingrui98  XSDebug(" TopRegister: 0x%x   %d \n",spec_debug.topRegister.retAddr,spec_debug.topRegister.ctr)
28809c6f1ddSLingrui98  XSDebug("  index       addr           ctr \n")
28909c6f1ddSLingrui98  for(i <- 0 until RasSize){
29009c6f1ddSLingrui98      XSDebug("  (%d)   0x%x      %d",i.U,spec_debug.out_mem(i).retAddr,spec_debug.out_mem(i).ctr)
29109c6f1ddSLingrui98      when(i.U === spec_debug.sp){XSDebug(false,true.B,"   <----sp")}
29209c6f1ddSLingrui98      XSDebug(false,true.B,"\n")
29309c6f1ddSLingrui98  }
2947e8709feSLingrui98  XSDebug(s2_spec_push, "s2_spec_push  inAddr: 0x%x  inCtr: %d |  allocNewEntry:%d |   sp:%d \n",
2957e8709feSLingrui98  s2_spec_new_addr,spec_debug.spec_push_entry.ctr,spec_debug.spec_alloc_new,spec_debug.sp.asUInt)
296adc0b8dfSGuokai Chen  XSDebug(s2_spec_pop, "s2_spec_pop  outAddr: 0x%x \n",io.out.s2.getTarget(2))
2977e8709feSLingrui98  val s3_recover_entry = spec_debug.recover_push_entry
2987e8709feSLingrui98  XSDebug(s3_recover && s3_push, "s3_recover_push  inAddr: 0x%x  inCtr: %d |  allocNewEntry:%d |   sp:%d \n",
2997e8709feSLingrui98    s3_recover_entry.retAddr, s3_recover_entry.ctr, spec_debug.recover_alloc_new, s3_sp.asUInt)
300adc0b8dfSGuokai Chen  XSDebug(s3_recover && s3_pop, "s3_recover_pop  outAddr: 0x%x \n",io.out.s3.getTarget(2))
30109c6f1ddSLingrui98  val redirectUpdate = redirect.bits.cfiUpdate
3027e8709feSLingrui98  XSDebug(do_recover && callMissPred, "redirect_recover_push\n")
3037e8709feSLingrui98  XSDebug(do_recover && retMissPred, "redirect_recover_pop\n")
3047e8709feSLingrui98  XSDebug(do_recover, "redirect_recover(SP:%d retAddr:%x ctr:%d) \n",
3057e8709feSLingrui98      redirectUpdate.rasSp,redirectUpdate.rasEntry.retAddr,redirectUpdate.rasEntry.ctr)
3064813e060SLingrui98
3074813e060SLingrui98  generatePerfEvent()
30809c6f1ddSLingrui98}
309c89b4642SGuokai Chen */
310