1package xiangshan 2 3import chisel3._ 4import chisel3.util._ 5import bus.simplebus._ 6import xiangshan.backend.brq.BrqPtr 7import xiangshan.backend.rename.FreeListPtr 8 9// Fetch FetchWidth x 32-bit insts from Icache 10class FetchPacket extends XSBundle { 11 val instrs = Vec(FetchWidth, UInt(32.W)) 12 val mask = UInt((FetchWidth*2).W) 13 val pc = UInt(VAddrBits.W) // the pc of first inst in the fetch group 14 val pnpc = Vec(FetchWidth, UInt(VAddrBits.W)) 15} 16 17class BranchPrediction extends XSBundle { 18 // mask off all the instrs after the first redirect instr 19 val instrValid = Vec(FetchWidth, Bool()) 20 // target and BTBtype of the first redirect instr in a fetch package 21 val target = UInt(VAddrBits.W) 22 val _type = UInt(2.W) 23 val hist = Vec(FetchWidth, UInt(HistoryLength.W)) 24} 25 26// Save predecode info in icache 27class Predecode extends XSBundle { 28 val fuTypes = Vec(FetchWidth, FuType()) 29 val fuOpTypes = Vec(FetchWidth, FuOpType()) 30} 31 32// Dequeue DecodeWidth insts from Ibuffer 33class CtrlFlow extends XSBundle { 34 val instr = UInt(32.W) 35 val pc = UInt(VAddrBits.W) 36 val pnpc = UInt(VAddrBits.W) 37 val exceptionVec = Vec(16, Bool()) 38 val intrVec = Vec(12, Bool()) 39 val isRVC = Bool() 40 val isBr = Bool() 41} 42 43// Decode DecodeWidth insts at Decode Stage 44class CtrlSignals extends XSBundle { 45 val src1Type, src2Type, src3Type = SrcType() 46 val lsrc1, lsrc2, lsrc3 = UInt(5.W) 47 val ldest = UInt(5.W) 48 val fuType = FuType() 49 val fuOpType = FuOpType() 50 val rfWen = Bool() 51 val fpWen = Bool() 52 val isXSTrap = Bool() 53 val noSpecExec = Bool() // This inst can not be speculated 54 val isBlocked = Bool() // This inst requires pipeline to be blocked 55 val isRVF = Bool() 56 val imm = UInt(XLEN.W) 57} 58 59class CfCtrl extends XSBundle { 60 val cf = new CtrlFlow 61 val ctrl = new CtrlSignals 62 val brTag = new BrqPtr 63} 64 65// CfCtrl -> MicroOp at Rename Stage 66class MicroOp extends CfCtrl { 67 68 val psrc1, psrc2, psrc3, pdest, old_pdest = UInt(PhyRegIdxWidth.W) 69 val src1State, src2State, src3State = SrcState() 70 val freelistAllocPtr = new FreeListPtr 71 val roqIdx = UInt(RoqIdxWidth.W) 72} 73 74class Redirect extends XSBundle { 75 val pc = UInt(VAddrBits.W) // wrongly predicted pc 76 val target = UInt(VAddrBits.W) 77 val brTarget = UInt(VAddrBits.W) 78 val brTag = new BrqPtr 79 val _type = UInt(2.W) 80 val isCall = Bool() 81 val taken = Bool() 82 val hist = UInt(HistoryLength.W) 83 val isException = Bool() 84 val roqIdx = UInt(RoqIdxWidth.W) 85 val freelistAllocPtr = new FreeListPtr 86} 87 88class Dp1ToDp2IO extends XSBundle { 89 val intDqToDp2 = Vec(IntDqDeqWidth, DecoupledIO(new MicroOp)) 90 val fpDqToDp2 = Vec(FpDqDeqWidth, DecoupledIO(new MicroOp)) 91 val lsDqToDp2 = Vec(LsDqDeqWidth, DecoupledIO(new MicroOp)) 92} 93 94class DebugBundle extends XSBundle{ 95 val isMMIO = Bool() 96} 97 98class ExuInput extends XSBundle { 99 val uop = new MicroOp 100 val src1, src2, src3 = UInt(XLEN.W) 101} 102 103class ExuOutput extends XSBundle { 104 val uop = new MicroOp 105 val data = UInt(XLEN.W) 106 val redirectValid = Bool() 107 val redirect = new Redirect 108 val debug = new DebugBundle 109} 110 111class ExuIO extends XSBundle { 112 val in = Flipped(DecoupledIO(new ExuInput)) 113 val redirect = Flipped(ValidIO(new Redirect)) 114 val out = DecoupledIO(new ExuOutput) 115 116 // for Lsu 117 val dmem = new SimpleBusUC 118 val scommit = Input(UInt(3.W)) 119} 120 121class RoqCommit extends XSBundle { 122 val uop = new MicroOp 123 val isWalk = Bool() 124} 125 126class FrontendToBackendIO extends XSBundle { 127 // to backend end 128 val cfVec = Vec(DecodeWidth, DecoupledIO(new CtrlFlow)) 129 // from backend 130 val redirect = Flipped(ValidIO(new Redirect)) 131 val commits = Vec(CommitWidth, Flipped(ValidIO(new RoqCommit))) // update branch pred 132} 133