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