xref: /XiangShan/src/main/scala/xiangshan/backend/decode/DecodeUnitComp.scala (revision b50f8ede77ba32d89e12467f43cd7c59e091a131)
1d91483a6Sfdy/***************************************************************************************
2d91483a6Sfdy  * Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3d91483a6Sfdy  * Copyright (c) 2020-2021 Peng Cheng Laboratory
4d91483a6Sfdy  *
5d91483a6Sfdy  * XiangShan is licensed under Mulan PSL v2.
6d91483a6Sfdy  * You can use this software according to the terms and conditions of the Mulan PSL v2.
7d91483a6Sfdy  * You may obtain a copy of Mulan PSL v2 at:
8d91483a6Sfdy  *          http://license.coscl.org.cn/MulanPSL2
9d91483a6Sfdy  *
10d91483a6Sfdy  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11d91483a6Sfdy  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12d91483a6Sfdy  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13d91483a6Sfdy  *
14d91483a6Sfdy  * See the Mulan PSL v2 for more details.
15d91483a6Sfdy  ***************************************************************************************/
16d91483a6Sfdy
17d91483a6Sfdypackage xiangshan.backend.decode
18d91483a6Sfdy
1983ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters
20d91483a6Sfdyimport chisel3._
21d91483a6Sfdyimport chisel3.util._
22d91483a6Sfdyimport freechips.rocketchip.rocket.Instructions
23d91483a6Sfdyimport freechips.rocketchip.util.uintToBitPat
24d91483a6Sfdyimport utils._
25d91483a6Sfdyimport utility._
26d91483a6Sfdyimport xiangshan.ExceptionNO.illegalInstr
27d91483a6Sfdyimport xiangshan._
28d91483a6Sfdyimport xiangshan.backend.fu.fpu.FPU
29d91483a6Sfdyimport xiangshan.backend.fu.FuType
30d91483a6Sfdyimport freechips.rocketchip.rocket.Instructions._
31d91483a6Sfdyimport xiangshan.backend.Bundles.{DecodedInst, StaticInst}
3298cfe81bSxgkiriimport xiangshan.backend.decode.isa.bitfield.XSInstBitFields
33582849ffSxiaofeibao-xjtuimport xiangshan.backend.fu.vector.Bundles.{VSew, VType, VLmul}
34d91483a6Sfdyimport yunsuan.VpermType
35d91483a6Sfdyimport scala.collection.Seq
36c4501a6fSZiyue-Zhangimport chisel3.util.experimental.decode.{QMCMinimizer, TruthTable, decoder}
37c4501a6fSZiyue-Zhang
38c4501a6fSZiyue-Zhangclass indexedLSUopTable(uopIdx:Int) extends Module {
3955f7bedaSZiyue Zhang  val src = IO(Input(UInt(4.W)))
40c4501a6fSZiyue-Zhang  val outOffsetVs2 = IO(Output(UInt(3.W)))
41c4501a6fSZiyue-Zhang  val outOffsetVd = IO(Output(UInt(3.W)))
4255f7bedaSZiyue Zhang  def genCsBundle_VEC_INDEXED_LDST(lmul:Int, emul:Int, uopIdx:Int): (Int, Int) ={
4355f7bedaSZiyue Zhang    // only consider non segment indexed load/store
44c4501a6fSZiyue-Zhang    if (lmul < emul) {    // lmul < emul, uop num is depend on emul * nf
45c4501a6fSZiyue-Zhang      var offset = 1 << (emul - lmul)
46de785770Szhanglinjuan      for (i <- 0 until (1 << emul)) {
4755f7bedaSZiyue Zhang        if (uopIdx == i) {
4855f7bedaSZiyue Zhang          return (i, i / offset)
49c4501a6fSZiyue-Zhang        }
50c4501a6fSZiyue-Zhang      }
51c379dcbeSZiyue-Zhang    } else {              // lmul > emul, uop num is depend on lmul * nf
52c4501a6fSZiyue-Zhang      var offset = 1 << (lmul - emul)
53de785770Szhanglinjuan      for (i <- 0 until (1 << lmul)) {
5455f7bedaSZiyue Zhang        if (uopIdx == i) {
5555f7bedaSZiyue Zhang          return (i / offset, i)
56c4501a6fSZiyue-Zhang        }
57c4501a6fSZiyue-Zhang      }
58c4501a6fSZiyue-Zhang    }
5955f7bedaSZiyue Zhang    return (0, 0)
60c4501a6fSZiyue-Zhang  }
61c4501a6fSZiyue-Zhang  // strided load/store
6255f7bedaSZiyue Zhang  var combVemulNf : Seq[(Int, Int, Int, Int)] = Seq()
63c4501a6fSZiyue-Zhang  for (emul <- 0 until 4) {
64c4501a6fSZiyue-Zhang    for (lmul <- 0 until 4) {
6555f7bedaSZiyue Zhang      var offset = genCsBundle_VEC_INDEXED_LDST(lmul, emul, uopIdx)
66c4501a6fSZiyue-Zhang      var offsetVs2 = offset._1
67c4501a6fSZiyue-Zhang      var offsetVd = offset._2
6855f7bedaSZiyue Zhang      combVemulNf :+= (emul, lmul, offsetVs2, offsetVd)
69c4501a6fSZiyue-Zhang    }
70c4501a6fSZiyue-Zhang  }
710cd00663SzhanglyGit  val out = decoder(QMCMinimizer, src, TruthTable(combVemulNf.map {
7255f7bedaSZiyue Zhang    case (emul, lmul, offsetVs2, offsetVd) =>
7355f7bedaSZiyue Zhang      (BitPat((emul << 2 | lmul).U(4.W)), BitPat((offsetVs2 << 3 | offsetVd).U(6.W)))
7455f7bedaSZiyue Zhang  }, BitPat.N(6)))
75c4501a6fSZiyue-Zhang  outOffsetVs2 := out(5, 3)
76c4501a6fSZiyue-Zhang  outOffsetVd := out(2, 0)
77c4501a6fSZiyue-Zhang}
78d91483a6Sfdy
79d91483a6Sfdytrait VectorConstants {
80d91483a6Sfdy  val MAX_VLMUL = 8
81d91483a6Sfdy  val FP_TMP_REG_MV = 32
82189ec863SzhanglyGit  val VECTOR_TMP_REG_LMUL = 33 // 33~47  ->  15
83c4501a6fSZiyue-Zhang  val MAX_INDEXED_LS_UOPNUM = 64
84d91483a6Sfdy}
85d91483a6Sfdy
86d91483a6Sfdyclass DecodeUnitCompIO(implicit p: Parameters) extends XSBundle {
87e25c13faSXuan Hu  val redirect = Input(Bool())
88d91483a6Sfdy  val csrCtrl = Input(new CustomCSRCtrlIO)
8996a12457Ssinsanction  val vtypeBypass = Input(new VType)
90e25c13faSXuan Hu  // When the first inst in decode vector is complex inst, pass it in
91e25c13faSXuan Hu  val in = Flipped(DecoupledIO(new Bundle {
92e25c13faSXuan Hu    val simpleDecodedInst = new DecodedInst
93e25c13faSXuan Hu    val uopInfo = new UopInfo
94e25c13faSXuan Hu  }))
95e25c13faSXuan Hu  val out = new Bundle {
96e25c13faSXuan Hu    val complexDecodedInsts = Vec(RenameWidth, DecoupledIO(new DecodedInst))
97e25c13faSXuan Hu  }
98e25c13faSXuan Hu  val complexNum = Output(UInt(3.W))
99d91483a6Sfdy}
10017ec87f2SXuan Hu
101d91483a6Sfdy/**
102d91483a6Sfdy  * @author zly
103d91483a6Sfdy  */
104d91483a6Sfdyclass DecodeUnitComp()(implicit p : Parameters) extends XSModule with DecodeUnitConstants with VectorConstants {
105d91483a6Sfdy  val io = IO(new DecodeUnitCompIO)
106d91483a6Sfdy
107e25c13faSXuan Hu  // alias
108e25c13faSXuan Hu  private val inReady = io.in.ready
109e25c13faSXuan Hu  private val inValid = io.in.valid
110e25c13faSXuan Hu  private val inDecodedInst = WireInit(io.in.bits.simpleDecodedInst)
111229ab603SXuan Hu  private val inInstFields = io.in.bits.simpleDecodedInst.instr.asTypeOf(new XSInstBitFields)
112e25c13faSXuan Hu  private val inUopInfo = io.in.bits.uopInfo
113e25c13faSXuan Hu  private val outValids = io.out.complexDecodedInsts.map(_.valid)
114e25c13faSXuan Hu  private val outReadys = io.out.complexDecodedInsts.map(_.ready)
115e25c13faSXuan Hu  private val outDecodedInsts = io.out.complexDecodedInsts.map(_.bits)
116e25c13faSXuan Hu  private val outComplexNum = io.complexNum
117e25c13faSXuan Hu
118d91483a6Sfdy  val maxUopSize = MaxUopSize
119229ab603SXuan Hu  when (io.in.fire && io.in.bits.simpleDecodedInst.isVset) {
120229ab603SXuan Hu    when(inInstFields.RD === 0.U && inInstFields.RS1 === 0.U) {
121229ab603SXuan Hu      inDecodedInst.fuOpType := VSETOpType.keepVl(io.in.bits.simpleDecodedInst.fuOpType)
122229ab603SXuan Hu    }.elsewhen(inInstFields.RS1 === 0.U) {
123229ab603SXuan Hu      inDecodedInst.fuOpType := VSETOpType.setVlmax(io.in.bits.simpleDecodedInst.fuOpType)
124229ab603SXuan Hu    }
125229ab603SXuan Hu  }
126229ab603SXuan Hu
127e25c13faSXuan Hu  val latchedInst = RegEnable(inDecodedInst, inValid && inReady)
128e25c13faSXuan Hu  val latchedUopInfo = RegEnable(inUopInfo, inValid && inReady)
129d91483a6Sfdy  //input bits
130e25c13faSXuan Hu  private val instFields: XSInstBitFields = latchedInst.instr.asTypeOf(new XSInstBitFields)
131d91483a6Sfdy
132e25c13faSXuan Hu  val src1 = Cat(0.U(1.W), instFields.RS1)
133e25c13faSXuan Hu  val src2 = Cat(0.U(1.W), instFields.RS2)
134e25c13faSXuan Hu  val dest = Cat(0.U(1.W), instFields.RD)
1357f9f0a79SzhanglyGit
136e25c13faSXuan Hu  val nf    = instFields.NF
137e25c13faSXuan Hu  val width = instFields.WIDTH(1, 0)
138d91483a6Sfdy
139d91483a6Sfdy  //output of DecodeUnit
140e25c13faSXuan Hu  val numOfUop = Wire(UInt(log2Up(maxUopSize).W))
141e25c13faSXuan Hu  val numOfWB = Wire(UInt(log2Up(maxUopSize).W))
1427f9f0a79SzhanglyGit  val lmul = Wire(UInt(4.W))
143189ec863SzhanglyGit  val isVsetSimple = Wire(Bool())
144d91483a6Sfdy
14555f7bedaSZiyue Zhang  val indexedLSRegOffset = Seq.tabulate(MAX_VLMUL)(i => Module(new indexedLSUopTable(i)))
146c4501a6fSZiyue-Zhang  indexedLSRegOffset.map(_.src := 0.U)
147c4501a6fSZiyue-Zhang
148d91483a6Sfdy  //pre decode
149e25c13faSXuan Hu  lmul := latchedUopInfo.lmul
150e25c13faSXuan Hu  isVsetSimple := latchedInst.isVset
151e25c13faSXuan Hu  val vlmulReg = latchedInst.vpu.vlmul
152e25c13faSXuan Hu  val vsewReg = latchedInst.vpu.vsew
153229ab603SXuan Hu
154d91483a6Sfdy  //Type of uop Div
155e25c13faSXuan Hu  val typeOfSplit = latchedInst.uopSplitType
156e25c13faSXuan Hu  val src1Type = latchedInst.srcType(0)
157d6059658SZiyue Zhang  val src1IsImm = src1Type === SrcType.imm
158395c8649SZiyue-Zhang  val src1IsFp = src1Type === SrcType.fp
159d91483a6Sfdy
1607635b2a1SZiyue Zhang  val isVstore = FuType.isVStore(latchedInst.fuType)
1617635b2a1SZiyue Zhang
162e25c13faSXuan Hu  numOfUop := latchedUopInfo.numOfUop
163e25c13faSXuan Hu  numOfWB := latchedUopInfo.numOfWB
164e25c13faSXuan Hu
165e25c13faSXuan Hu  //uops dispatch
166e25c13faSXuan Hu  val s_idle :: s_active :: Nil = Enum(2)
167e25c13faSXuan Hu  val state = RegInit(s_idle)
168e25c13faSXuan Hu  val stateNext = WireDefault(state)
169e25c13faSXuan Hu  val numDecodedUop = RegInit(0.U(log2Up(maxUopSize).W))
170e25c13faSXuan Hu  val uopRes = RegInit(0.U(log2Up(maxUopSize).W))
171e25c13faSXuan Hu  val uopResNext = WireInit(uopRes)
172964d9a87SZiyue Zhang  val e64 = 3.U(2.W)
1734aa00286SXuan Hu  val isUsSegment = instFields.MOP === 0.U && nf =/= 0.U && (instFields.LUMOP === 0.U || instFields.LUMOP === "b10000".U)
1744aa00286SXuan Hu  val isIxSegment = instFields.MOP(0) === 1.U && nf =/= 0.U
1754aa00286SXuan Hu  val isSdSegment = instFields.MOP === "b10".U && nf =/= 0.U
1767f9f0a79SzhanglyGit
177d91483a6Sfdy  //uop div up to maxUopSize
178d91483a6Sfdy  val csBundle = Wire(Vec(maxUopSize, new DecodedInst))
179e25c13faSXuan Hu  csBundle.foreach { case dst =>
180e25c13faSXuan Hu    dst := latchedInst
181e25c13faSXuan Hu    dst.numUops := latchedUopInfo.numOfUop
182e25c13faSXuan Hu    dst.numWB := latchedUopInfo.numOfWB
183d91483a6Sfdy    dst.firstUop := false.B
184d91483a6Sfdy    dst.lastUop := false.B
18531c51290Szhanglinjuan    dst.vlsInstr := false.B
186d91483a6Sfdy  }
187d91483a6Sfdy
188d91483a6Sfdy  csBundle(0).firstUop := true.B
189d91483a6Sfdy  csBundle(numOfUop - 1.U).lastUop := true.B
190d91483a6Sfdy
191189ec863SzhanglyGit  switch(typeOfSplit) {
192e25c13faSXuan Hu    is(UopSplitType.VSET) {
1934cdab2a9SXuan Hu      // In simple decoder, rfWen and vecWen are not set
194189ec863SzhanglyGit      when(isVsetSimple) {
1954cdab2a9SXuan Hu        // Default
1964cdab2a9SXuan Hu        // uop0 set rd, never flushPipe
197d91483a6Sfdy        csBundle(0).fuType := FuType.vsetiwi.U
198d91483a6Sfdy        csBundle(0).flushPipe := false.B
199d91483a6Sfdy        csBundle(0).rfWen := true.B
2004cdab2a9SXuan Hu        // uop1 set vl, vsetvl will flushPipe
201cb10a55bSXuan Hu        csBundle(1).ldest := VCONFIG_IDX.U
202fe60541bSXuan Hu        csBundle(1).vecWen := true.B
2034cdab2a9SXuan Hu        when(VSETOpType.isVsetvli(latchedInst.fuOpType) && dest === 0.U && src1 === 0.U) {
204d8ceb649SZiyue Zhang          // write nothing, uop0 is a nop instruction
205d8ceb649SZiyue Zhang          csBundle(0).rfWen := false.B
206d8ceb649SZiyue Zhang          csBundle(0).fpWen := false.B
207d8ceb649SZiyue Zhang          csBundle(0).vecWen := false.B
2084cdab2a9SXuan Hu          csBundle(1).fuType := FuType.vsetfwf.U
2094cdab2a9SXuan Hu          csBundle(1).srcType(0) := SrcType.vp
2104cdab2a9SXuan Hu          csBundle(1).lsrc(0) := VCONFIG_IDX.U
2114cdab2a9SXuan Hu        }.elsewhen(VSETOpType.isVsetvl(latchedInst.fuOpType) && dest === 0.U && src1 === 0.U) {
2124cdab2a9SXuan Hu          // uop0: mv vtype gpr to vector region
2134cdab2a9SXuan Hu          csBundle(0).srcType(0) := SrcType.xp
2144cdab2a9SXuan Hu          csBundle(0).srcType(1) := SrcType.no
215d91483a6Sfdy          csBundle(0).lsrc(1) := 0.U
216d91483a6Sfdy          csBundle(0).ldest := FP_TMP_REG_MV.U
217964d9a87SZiyue Zhang          csBundle(0).fuType := FuType.i2v.U
218964d9a87SZiyue Zhang          csBundle(0).fuOpType := Cat(IF2VectorType.i2Vec(2, 0), e64)
219964d9a87SZiyue Zhang          csBundle(0).rfWen := false.B
220d91483a6Sfdy          csBundle(0).fpWen := true.B
221964d9a87SZiyue Zhang          csBundle(0).vecWen := false.B
222d91483a6Sfdy          csBundle(0).flushPipe := false.B
2234cdab2a9SXuan Hu          // uop1: uvsetvcfg_vv
224d91483a6Sfdy          csBundle(1).fuType := FuType.vsetfwf.U
2254cdab2a9SXuan Hu          // vl
226d91483a6Sfdy          csBundle(1).srcType(0) := SrcType.vp
227cb10a55bSXuan Hu          csBundle(1).lsrc(0) := VCONFIG_IDX.U
2284cdab2a9SXuan Hu          // vtype
229d91483a6Sfdy          csBundle(1).srcType(1) := SrcType.fp
230d91483a6Sfdy          csBundle(1).lsrc(1) := FP_TMP_REG_MV.U
2314cdab2a9SXuan Hu          csBundle(1).vecWen := true.B
232cb10a55bSXuan Hu          csBundle(1).ldest := VCONFIG_IDX.U
23317d9db4eSZiyue Zhang        }.elsewhen(dest === 0.U) {
23417d9db4eSZiyue Zhang          // write nothing, uop0 is a nop instruction
23517d9db4eSZiyue Zhang          csBundle(0).rfWen := false.B
23617d9db4eSZiyue Zhang          csBundle(0).fpWen := false.B
23717d9db4eSZiyue Zhang          csBundle(0).vecWen := false.B
238d91483a6Sfdy        }
23996a12457Ssinsanction        // use bypass vtype from vtypeGen
24096a12457Ssinsanction        csBundle(0).vpu.connectVType(io.vtypeBypass)
24196a12457Ssinsanction        csBundle(1).vpu.connectVType(io.vtypeBypass)
242d91483a6Sfdy      }
243d91483a6Sfdy    }
24417ec87f2SXuan Hu    is(UopSplitType.VEC_VVV) {
245d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
246d91483a6Sfdy        csBundle(i).lsrc(0) := src1 + i.U
247d91483a6Sfdy        csBundle(i).lsrc(1) := src2 + i.U
248d91483a6Sfdy        csBundle(i).lsrc(2) := dest + i.U
249d91483a6Sfdy        csBundle(i).ldest := dest + i.U
250d91483a6Sfdy        csBundle(i).uopIdx := i.U
251d91483a6Sfdy      }
252d91483a6Sfdy    }
253684d7aceSxiaofeibao-xjtu    is(UopSplitType.VEC_VFV) {
254395c8649SZiyue-Zhang      /*
255*b50f8edeSsinsanction      f to vector move
256395c8649SZiyue-Zhang       */
257395c8649SZiyue-Zhang      csBundle(0).srcType(0) := SrcType.fp
258395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
259*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
260395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
261395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
262395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
263395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
264395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
265783a1d5fSlewislzh      csBundle(0).vpu.isReverse := false.B
266395c8649SZiyue-Zhang      /*
267395c8649SZiyue-Zhang      LMUL
268395c8649SZiyue-Zhang       */
269684d7aceSxiaofeibao-xjtu      for (i <- 0 until MAX_VLMUL) {
270395c8649SZiyue-Zhang        csBundle(i + 1).srcType(0) := SrcType.vp
271395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
272395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(1) := src2 + i.U
273395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(2) := dest + i.U
274395c8649SZiyue-Zhang        csBundle(i + 1).ldest := dest + i.U
275395c8649SZiyue-Zhang        csBundle(i + 1).uopIdx := i.U
276684d7aceSxiaofeibao-xjtu      }
277684d7aceSxiaofeibao-xjtu    }
27817ec87f2SXuan Hu    is(UopSplitType.VEC_EXT2) {
279d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
280d91483a6Sfdy        csBundle(2 * i).lsrc(1) := src2 + i.U
281d91483a6Sfdy        csBundle(2 * i).lsrc(2) := dest + (2 * i).U
282d91483a6Sfdy        csBundle(2 * i).ldest := dest + (2 * i).U
283d91483a6Sfdy        csBundle(2 * i).uopIdx := (2 * i).U
284d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
285d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i + 1).U
286d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + (2 * i + 1).U
287d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i + 1).U
288d91483a6Sfdy      }
289d91483a6Sfdy    }
29017ec87f2SXuan Hu    is(UopSplitType.VEC_EXT4) {
291d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 4) {
292d91483a6Sfdy        csBundle(4 * i).lsrc(1) := src2 + i.U
293d91483a6Sfdy        csBundle(4 * i).lsrc(2) := dest + (4 * i).U
294d91483a6Sfdy        csBundle(4 * i).ldest := dest + (4 * i).U
295d91483a6Sfdy        csBundle(4 * i).uopIdx := (4 * i).U
296d91483a6Sfdy        csBundle(4 * i + 1).lsrc(1) := src2 + i.U
297d91483a6Sfdy        csBundle(4 * i + 1).lsrc(2) := dest + (4 * i + 1).U
298d91483a6Sfdy        csBundle(4 * i + 1).ldest := dest + (4 * i + 1).U
299d91483a6Sfdy        csBundle(4 * i + 1).uopIdx := (4 * i + 1).U
300d91483a6Sfdy        csBundle(4 * i + 2).lsrc(1) := src2 + i.U
301d91483a6Sfdy        csBundle(4 * i + 2).lsrc(2) := dest + (4 * i + 2).U
302d91483a6Sfdy        csBundle(4 * i + 2).ldest := dest + (4 * i + 2).U
303d91483a6Sfdy        csBundle(4 * i + 2).uopIdx := (4 * i + 2).U
304d91483a6Sfdy        csBundle(4 * i + 3).lsrc(1) := src2 + i.U
305d91483a6Sfdy        csBundle(4 * i + 3).lsrc(2) := dest + (4 * i + 3).U
306d91483a6Sfdy        csBundle(4 * i + 3).ldest := dest + (4 * i + 3).U
307d91483a6Sfdy        csBundle(4 * i + 3).uopIdx := (4 * i + 3).U
308d91483a6Sfdy      }
309d91483a6Sfdy    }
31017ec87f2SXuan Hu    is(UopSplitType.VEC_EXT8) {
311d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
312d91483a6Sfdy        csBundle(i).lsrc(1) := src2
313d91483a6Sfdy        csBundle(i).lsrc(2) := dest + i.U
314d91483a6Sfdy        csBundle(i).ldest := dest + i.U
315d91483a6Sfdy        csBundle(i).uopIdx := i.U
316d91483a6Sfdy      }
317d91483a6Sfdy    }
31817ec87f2SXuan Hu    is(UopSplitType.VEC_0XV) {
319d91483a6Sfdy      /*
320395c8649SZiyue-Zhang      i/f to vector move
321d91483a6Sfdy       */
322395c8649SZiyue-Zhang      csBundle(0).srcType(0) := Mux(src1IsFp, SrcType.fp, SrcType.reg)
323d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
324*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
325d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
3267c67deccSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
327395c8649SZiyue-Zhang      csBundle(0).fuType := Mux(src1IsFp, FuType.f2v.U, FuType.i2v.U)
328395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsFp, IF2VectorType.fDup2Vec(2, 0), IF2VectorType.i2Vec(2, 0)), vsewReg)
329d91483a6Sfdy      csBundle(0).rfWen := false.B
3307c67deccSZiyue Zhang      csBundle(0).fpWen := false.B
3317c67deccSZiyue Zhang      csBundle(0).vecWen := true.B
332d91483a6Sfdy      /*
3337c67deccSZiyue Zhang      vmv.s.x
334d91483a6Sfdy       */
3357c67deccSZiyue Zhang      csBundle(1).srcType(0) := SrcType.vp
3367c67deccSZiyue Zhang      csBundle(1).srcType(1) := SrcType.imm
337d91483a6Sfdy      csBundle(1).srcType(2) := SrcType.vp
3387c67deccSZiyue Zhang      csBundle(1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
339d91483a6Sfdy      csBundle(1).lsrc(1) := 0.U
340d91483a6Sfdy      csBundle(1).lsrc(2) := dest
341d91483a6Sfdy      csBundle(1).ldest := dest
342d91483a6Sfdy      csBundle(1).rfWen := false.B
343d91483a6Sfdy      csBundle(1).fpWen := false.B
344d91483a6Sfdy      csBundle(1).vecWen := true.B
3457c67deccSZiyue Zhang      csBundle(1).uopIdx := 0.U
346d91483a6Sfdy    }
34717ec87f2SXuan Hu    is(UopSplitType.VEC_VXV) {
348d91483a6Sfdy      /*
349d6059658SZiyue Zhang      i to vector move
350d91483a6Sfdy       */
351d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
352d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
353*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
354d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
355fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
356fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
357b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.immDup2Vec(2, 0), IF2VectorType.iDup2Vec(2, 0)), vsewReg)
358fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
359783a1d5fSlewislzh      csBundle(0).vpu.isReverse := false.B
360fc85f18fSZiyue Zhang      /*
361fc85f18fSZiyue Zhang      LMUL
362fc85f18fSZiyue Zhang       */
363fc85f18fSZiyue Zhang      for (i <- 0 until MAX_VLMUL) {
364fc85f18fSZiyue Zhang        csBundle(i + 1).srcType(0) := SrcType.vp
365fc85f18fSZiyue Zhang        csBundle(i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
366d91483a6Sfdy        csBundle(i + 1).lsrc(1) := src2 + i.U
367d91483a6Sfdy        csBundle(i + 1).lsrc(2) := dest + i.U
368d91483a6Sfdy        csBundle(i + 1).ldest := dest + i.U
369d91483a6Sfdy        csBundle(i + 1).uopIdx := i.U
370d91483a6Sfdy      }
371d91483a6Sfdy    }
37217ec87f2SXuan Hu    is(UopSplitType.VEC_VVW) {
373d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
374d91483a6Sfdy        csBundle(2 * i).lsrc(0) := src1 + i.U
375d91483a6Sfdy        csBundle(2 * i).lsrc(1) := src2 + i.U
376d91483a6Sfdy        csBundle(2 * i).lsrc(2) := dest + (2 * i).U
377d91483a6Sfdy        csBundle(2 * i).ldest := dest + (2 * i).U
378d91483a6Sfdy        csBundle(2 * i).uopIdx := (2 * i).U
379d91483a6Sfdy        csBundle(2 * i + 1).lsrc(0) := src1 + i.U
380d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
381d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i + 1).U
382d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + (2 * i + 1).U
383d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i + 1).U
384d91483a6Sfdy      }
385d91483a6Sfdy    }
3863748ec56Sxiaofeibao-xjtu    is(UopSplitType.VEC_VFW) {
387395c8649SZiyue-Zhang      /*
388395c8649SZiyue-Zhang      f to vector move
389395c8649SZiyue-Zhang       */
390395c8649SZiyue-Zhang      csBundle(0).srcType(0) := SrcType.fp
391395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
392*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
393395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
394395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
395395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
396395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
397395c8649SZiyue-Zhang      csBundle(0).rfWen := false.B
398395c8649SZiyue-Zhang      csBundle(0).fpWen := false.B
399395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
400395c8649SZiyue-Zhang
4013748ec56Sxiaofeibao-xjtu      for (i <- 0 until MAX_VLMUL / 2) {
402395c8649SZiyue-Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
403395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
4043748ec56Sxiaofeibao-xjtu        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
405395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i).U
406395c8649SZiyue-Zhang        csBundle(2 * i + 1).ldest := dest + (2 * i).U
407395c8649SZiyue-Zhang        csBundle(2 * i + 1).uopIdx := (2 * i).U
408395c8649SZiyue-Zhang        csBundle(2 * i + 2).srcType(0) := SrcType.vp
409395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
410395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(1) := src2 + i.U
411395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(2) := dest + (2 * i + 1).U
412395c8649SZiyue-Zhang        csBundle(2 * i + 2).ldest := dest + (2 * i + 1).U
413395c8649SZiyue-Zhang        csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
4143748ec56Sxiaofeibao-xjtu      }
4153748ec56Sxiaofeibao-xjtu    }
41617ec87f2SXuan Hu    is(UopSplitType.VEC_WVW) {
417d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
418d91483a6Sfdy        csBundle(2 * i).lsrc(0) := src1 + i.U
419d91483a6Sfdy        csBundle(2 * i).lsrc(1) := src2 + (2 * i).U
420d91483a6Sfdy        csBundle(2 * i).lsrc(2) := dest + (2 * i).U
421d91483a6Sfdy        csBundle(2 * i).ldest := dest + (2 * i).U
422d91483a6Sfdy        csBundle(2 * i).uopIdx := (2 * i).U
423d91483a6Sfdy        csBundle(2 * i + 1).lsrc(0) := src1 + i.U
424d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + (2 * i + 1).U
425d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i + 1).U
426d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + (2 * i + 1).U
427d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i + 1).U
428d91483a6Sfdy      }
429d91483a6Sfdy    }
43017ec87f2SXuan Hu    is(UopSplitType.VEC_VXW) {
431d91483a6Sfdy      /*
432d6059658SZiyue Zhang      i to vector move
433d91483a6Sfdy       */
434d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
435d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
436*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
437d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
438fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
439fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
440b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.iDup2Vec(2, 0), vsewReg)
441fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
442d91483a6Sfdy
443d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
444fc85f18fSZiyue Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
445fc85f18fSZiyue Zhang        csBundle(2 * i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
446d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
447d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i).U
448d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + (2 * i).U
449d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i).U
450fc85f18fSZiyue Zhang        csBundle(2 * i + 2).srcType(0) := SrcType.vp
451fc85f18fSZiyue Zhang        csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
452d91483a6Sfdy        csBundle(2 * i + 2).lsrc(1) := src2 + i.U
453d91483a6Sfdy        csBundle(2 * i + 2).lsrc(2) := dest + (2 * i + 1).U
454d91483a6Sfdy        csBundle(2 * i + 2).ldest := dest + (2 * i + 1).U
455d91483a6Sfdy        csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
456d91483a6Sfdy      }
457d91483a6Sfdy    }
45817ec87f2SXuan Hu    is(UopSplitType.VEC_WXW) {
459d91483a6Sfdy      /*
460d6059658SZiyue Zhang      i to vector move
461d91483a6Sfdy       */
462d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
463d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
464*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
465d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
466fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
467fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
468b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.iDup2Vec(2, 0), vsewReg)
469fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
470d91483a6Sfdy
471d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
472fc85f18fSZiyue Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
473fc85f18fSZiyue Zhang        csBundle(2 * i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
474d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + (2 * i).U
475d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i).U
476d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + (2 * i).U
477d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i).U
478fc85f18fSZiyue Zhang        csBundle(2 * i + 2).srcType(0) := SrcType.vp
479fc85f18fSZiyue Zhang        csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
480d91483a6Sfdy        csBundle(2 * i + 2).lsrc(1) := src2 + (2 * i + 1).U
481d91483a6Sfdy        csBundle(2 * i + 2).lsrc(2) := dest + (2 * i + 1).U
482d91483a6Sfdy        csBundle(2 * i + 2).ldest := dest + (2 * i + 1).U
483d91483a6Sfdy        csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
484d91483a6Sfdy      }
485d91483a6Sfdy    }
48617ec87f2SXuan Hu    is(UopSplitType.VEC_WVV) {
487d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
488d91483a6Sfdy
489d91483a6Sfdy        csBundle(2 * i).lsrc(0) := src1 + i.U
490d91483a6Sfdy        csBundle(2 * i).lsrc(1) := src2 + (2 * i).U
491d91483a6Sfdy        csBundle(2 * i).lsrc(2) := dest + i.U
492d6f9198fSXuan Hu        csBundle(2 * i).ldest := dest + i.U
493d91483a6Sfdy        csBundle(2 * i).uopIdx := (2 * i).U
494d91483a6Sfdy        csBundle(2 * i + 1).lsrc(0) := src1 + i.U
495d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + (2 * i + 1).U
496d6f9198fSXuan Hu        csBundle(2 * i + 1).lsrc(2) := dest + i.U
497d91483a6Sfdy        csBundle(2 * i + 1).ldest := dest + i.U
498d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i + 1).U
499d91483a6Sfdy      }
500d91483a6Sfdy    }
5013748ec56Sxiaofeibao-xjtu    is(UopSplitType.VEC_WFW) {
502395c8649SZiyue-Zhang      /*
503395c8649SZiyue-Zhang      f to vector move
504395c8649SZiyue-Zhang       */
505395c8649SZiyue-Zhang      csBundle(0).srcType(0) := SrcType.fp
506395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
507*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
508395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
509395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
510395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
511395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
512395c8649SZiyue-Zhang      csBundle(0).rfWen := false.B
513395c8649SZiyue-Zhang      csBundle(0).fpWen := false.B
514395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
515395c8649SZiyue-Zhang
5163748ec56Sxiaofeibao-xjtu      for (i <- 0 until MAX_VLMUL / 2) {
517395c8649SZiyue-Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
518395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
519395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(1) := src2 + (2 * i).U
520395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(2) := dest + (2 * i).U
521395c8649SZiyue-Zhang        csBundle(2 * i + 1).ldest := dest + (2 * i).U
522395c8649SZiyue-Zhang        csBundle(2 * i + 1).uopIdx := (2 * i).U
523395c8649SZiyue-Zhang        csBundle(2 * i + 2).srcType(0) := SrcType.vp
524395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
525395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(1) := src2 + (2 * i + 1).U
526395c8649SZiyue-Zhang        csBundle(2 * i + 2).lsrc(2) := dest + (2 * i + 1).U
527395c8649SZiyue-Zhang        csBundle(2 * i + 2).ldest := dest + (2 * i + 1).U
528395c8649SZiyue-Zhang        csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
5293748ec56Sxiaofeibao-xjtu      }
5303748ec56Sxiaofeibao-xjtu    }
53117ec87f2SXuan Hu    is(UopSplitType.VEC_WXV) {
532d91483a6Sfdy      /*
533d6059658SZiyue Zhang      i to vector move
534d91483a6Sfdy       */
535d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
536d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
537*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
538d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
539fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
540fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
541b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.immDup2Vec(2, 0), IF2VectorType.iDup2Vec(2, 0)), vsewReg)
542fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
543d91483a6Sfdy
544d91483a6Sfdy      for (i <- 0 until MAX_VLMUL / 2) {
545fc85f18fSZiyue Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
546fc85f18fSZiyue Zhang        csBundle(2 * i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
547d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + (2 * i).U
548d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + i.U
549d6f9198fSXuan Hu        csBundle(2 * i + 1).ldest := dest + i.U
550d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i).U
551fc85f18fSZiyue Zhang        csBundle(2 * i + 2).srcType(0) := SrcType.vp
552fc85f18fSZiyue Zhang        csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
553d91483a6Sfdy        csBundle(2 * i + 2).lsrc(1) := src2 + (2 * i + 1).U
554d6f9198fSXuan Hu        csBundle(2 * i + 2).lsrc(2) := dest + i.U
555d91483a6Sfdy        csBundle(2 * i + 2).ldest := dest + i.U
556d91483a6Sfdy        csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
557d91483a6Sfdy      }
558d91483a6Sfdy    }
55917ec87f2SXuan Hu    is(UopSplitType.VEC_VVM) {
560d91483a6Sfdy      csBundle(0).lsrc(2) := dest
561d6f9198fSXuan Hu      csBundle(0).ldest := dest
562d91483a6Sfdy      csBundle(0).uopIdx := 0.U
563d91483a6Sfdy      for (i <- 1 until MAX_VLMUL) {
564d91483a6Sfdy        csBundle(i).lsrc(0) := src1 + i.U
565d91483a6Sfdy        csBundle(i).lsrc(1) := src2 + i.U
566d6f9198fSXuan Hu        csBundle(i).lsrc(2) := dest
567d6f9198fSXuan Hu        csBundle(i).ldest := dest
568d91483a6Sfdy        csBundle(i).uopIdx := i.U
569d91483a6Sfdy      }
570d91483a6Sfdy    }
571f06d6d60Sxiaofeibao-xjtu    is(UopSplitType.VEC_VFM) {
572395c8649SZiyue-Zhang      /*
573395c8649SZiyue-Zhang      f to vector move
574395c8649SZiyue-Zhang       */
575395c8649SZiyue-Zhang      csBundle(0).srcType(0) := SrcType.fp
576395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
577*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
578395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
579395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
580395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
581395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
582395c8649SZiyue-Zhang      csBundle(0).rfWen := false.B
583395c8649SZiyue-Zhang      csBundle(0).fpWen := false.B
584395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
585395c8649SZiyue-Zhang      //LMUL
586395c8649SZiyue-Zhang      csBundle(1).srcType(0) := SrcType.vp
587395c8649SZiyue-Zhang      csBundle(1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
588395c8649SZiyue-Zhang      csBundle(1).lsrc(2) := dest
589395c8649SZiyue-Zhang      csBundle(1).ldest := dest
590395c8649SZiyue-Zhang      csBundle(1).uopIdx := 0.U
591f06d6d60Sxiaofeibao-xjtu      for (i <- 1 until MAX_VLMUL) {
592395c8649SZiyue-Zhang        csBundle(i + 1).srcType(0) := SrcType.vp
593395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
594395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(1) := src2 + i.U
595395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(2) := dest
596395c8649SZiyue-Zhang        csBundle(i + 1).ldest := dest
597395c8649SZiyue-Zhang        csBundle(i + 1).uopIdx := i.U
598f06d6d60Sxiaofeibao-xjtu      }
599f06d6d60Sxiaofeibao-xjtu      csBundle(numOfUop - 1.U).ldest := dest
600f06d6d60Sxiaofeibao-xjtu    }
60117ec87f2SXuan Hu    is(UopSplitType.VEC_VXM) {
602d91483a6Sfdy      /*
603d6059658SZiyue Zhang      i to vector move
604d91483a6Sfdy       */
605d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
606d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
607*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
608d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
609fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
610fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
611b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.immDup2Vec(2, 0), IF2VectorType.iDup2Vec(2, 0)), vsewReg)
612fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
613d91483a6Sfdy      //LMUL
614fc85f18fSZiyue Zhang      csBundle(1).srcType(0) := SrcType.vp
615fc85f18fSZiyue Zhang      csBundle(1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
616d91483a6Sfdy      csBundle(1).lsrc(2) := dest
617d6f9198fSXuan Hu      csBundle(1).ldest := dest
618d91483a6Sfdy      csBundle(1).uopIdx := 0.U
619d91483a6Sfdy      for (i <- 1 until MAX_VLMUL) {
620fc85f18fSZiyue Zhang        csBundle(i + 1).srcType(0) := SrcType.vp
621fc85f18fSZiyue Zhang        csBundle(i + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
622d91483a6Sfdy        csBundle(i + 1).lsrc(1) := src2 + i.U
623d6f9198fSXuan Hu        csBundle(i + 1).lsrc(2) := dest
624d6f9198fSXuan Hu        csBundle(i + 1).ldest := dest
625d91483a6Sfdy        csBundle(i + 1).uopIdx := i.U
626d91483a6Sfdy      }
627d91483a6Sfdy      csBundle(numOfUop - 1.U).ldest := dest
628d91483a6Sfdy    }
62917ec87f2SXuan Hu    is(UopSplitType.VEC_SLIDE1UP) {
630d91483a6Sfdy      /*
631d6059658SZiyue Zhang      i to vector move
632d91483a6Sfdy       */
633d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
634d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
635*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
636d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
637fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
638fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
639b8505463SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.iDup2Vec(2, 0), vsewReg)
640fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
641d91483a6Sfdy      //LMUL
642fc85f18fSZiyue Zhang      csBundle(1).srcType(0) := SrcType.vp
643fc85f18fSZiyue Zhang      csBundle(1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
644d91483a6Sfdy      csBundle(1).lsrc(2) := dest
645d91483a6Sfdy      csBundle(1).ldest := dest
646d91483a6Sfdy      csBundle(1).uopIdx := 0.U
647d91483a6Sfdy      for (i <- 1 until MAX_VLMUL) {
648d91483a6Sfdy        csBundle(i + 1).srcType(0) := SrcType.vp
649d91483a6Sfdy        csBundle(i + 1).lsrc(0) := src2 + (i - 1).U
650d91483a6Sfdy        csBundle(i + 1).lsrc(1) := src2 + i.U
651d91483a6Sfdy        csBundle(i + 1).lsrc(2) := dest + i.U
652d91483a6Sfdy        csBundle(i + 1).ldest := dest + i.U
653d91483a6Sfdy        csBundle(i + 1).uopIdx := i.U
654d91483a6Sfdy      }
655d91483a6Sfdy    }
65617ec87f2SXuan Hu    is(UopSplitType.VEC_FSLIDE1UP) {
657395c8649SZiyue-Zhang      /*
658*b50f8edeSsinsanction      f to vector move
659395c8649SZiyue-Zhang       */
660d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.fp
661395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
662*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
663395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
664395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
665395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
666395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
667395c8649SZiyue-Zhang      csBundle(0).rfWen := false.B
668395c8649SZiyue-Zhang      csBundle(0).fpWen := false.B
669395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
670395c8649SZiyue-Zhang      //LMUL
671395c8649SZiyue-Zhang      csBundle(1).srcType(0) := SrcType.vp
672395c8649SZiyue-Zhang      csBundle(1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
673395c8649SZiyue-Zhang      csBundle(1).lsrc(1) := src2
674395c8649SZiyue-Zhang      csBundle(1).lsrc(2) := dest
675395c8649SZiyue-Zhang      csBundle(1).ldest := dest
676395c8649SZiyue-Zhang      csBundle(1).uopIdx := 0.U
677d91483a6Sfdy      for (i <- 1 until MAX_VLMUL) {
678395c8649SZiyue-Zhang        csBundle(i + 1).srcType(0) := SrcType.vp
679395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(0) := src2 + (i - 1).U
680395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(1) := src2 + i.U
681395c8649SZiyue-Zhang        csBundle(i + 1).lsrc(2) := dest + i.U
682395c8649SZiyue-Zhang        csBundle(i + 1).ldest := dest + i.U
683395c8649SZiyue-Zhang        csBundle(i + 1).uopIdx := i.U
684d91483a6Sfdy      }
685d91483a6Sfdy    }
68617ec87f2SXuan Hu    is(UopSplitType.VEC_SLIDE1DOWN) { // lmul+lmul = 16
687d91483a6Sfdy      /*
688d6059658SZiyue Zhang      i to vector move
689d91483a6Sfdy       */
690d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
691d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
692*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
693d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
694fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
695fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
696b8505463SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.iDup2Vec(2, 0), vsewReg)
697fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
698d91483a6Sfdy      //LMUL
699d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
700d91483a6Sfdy        csBundle(2 * i + 1).srcType(0) := SrcType.vp
701d91483a6Sfdy        csBundle(2 * i + 1).srcType(1) := SrcType.vp
702d91483a6Sfdy        csBundle(2 * i + 1).lsrc(0) := src2 + (i + 1).U
703d91483a6Sfdy        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
704d91483a6Sfdy        csBundle(2 * i + 1).lsrc(2) := dest + i.U
705fc85f18fSZiyue Zhang        csBundle(2 * i + 1).ldest := VECTOR_TMP_REG_LMUL.U + 1.U
706d91483a6Sfdy        csBundle(2 * i + 1).uopIdx := (2 * i).U
707d91483a6Sfdy        if (2 * i + 2 < MAX_VLMUL * 2) {
708fc85f18fSZiyue Zhang          csBundle(2 * i + 2).srcType(0) := SrcType.vp
709fc85f18fSZiyue Zhang          csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
710d91483a6Sfdy          // csBundle(2 * i + 2).lsrc(1) := src2 + i.U         // DontCare
711fc85f18fSZiyue Zhang          csBundle(2 * i + 2).lsrc(2) := VECTOR_TMP_REG_LMUL.U + 1.U
712d91483a6Sfdy          csBundle(2 * i + 2).ldest := dest + i.U
713d91483a6Sfdy          csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
714d91483a6Sfdy        }
715d91483a6Sfdy      }
7168cbcda9aSZiyue Zhang      csBundle(numOfUop - 1.U).srcType(0) := SrcType.vp
7178cbcda9aSZiyue Zhang      csBundle(numOfUop - 1.U).lsrc(0) := VECTOR_TMP_REG_LMUL.U
718d91483a6Sfdy      csBundle(numOfUop - 1.U).ldest := dest + lmul - 1.U
719d91483a6Sfdy    }
72017ec87f2SXuan Hu    is(UopSplitType.VEC_FSLIDE1DOWN) {
721395c8649SZiyue-Zhang      /*
722*b50f8edeSsinsanction      f to vector move
723395c8649SZiyue-Zhang       */
724395c8649SZiyue-Zhang      csBundle(0).srcType(0) := SrcType.fp
725395c8649SZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
726*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
727395c8649SZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
728395c8649SZiyue-Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
729395c8649SZiyue-Zhang      csBundle(0).fuType := FuType.f2v.U
730395c8649SZiyue-Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.fDup2Vec(2, 0), vsewReg)
731395c8649SZiyue-Zhang      csBundle(0).rfWen := false.B
732395c8649SZiyue-Zhang      csBundle(0).fpWen := false.B
733395c8649SZiyue-Zhang      csBundle(0).vecWen := true.B
734d91483a6Sfdy      //LMUL
735d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
736395c8649SZiyue-Zhang        csBundle(2 * i + 1).srcType(0) := SrcType.vp
737395c8649SZiyue-Zhang        csBundle(2 * i + 1).srcType(1) := SrcType.vp
738395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(0) := src2 + (i + 1).U
739395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(1) := src2 + i.U
740395c8649SZiyue-Zhang        csBundle(2 * i + 1).lsrc(2) := dest + i.U
741395c8649SZiyue-Zhang        csBundle(2 * i + 1).ldest := VECTOR_TMP_REG_LMUL.U + 1.U
742395c8649SZiyue-Zhang        csBundle(2 * i + 1).uopIdx := (2 * i).U
743395c8649SZiyue-Zhang        if (2 * i + 2 < MAX_VLMUL * 2) {
744395c8649SZiyue-Zhang          csBundle(2 * i + 2).srcType(0) := SrcType.vp
745395c8649SZiyue-Zhang          csBundle(2 * i + 2).lsrc(0) := VECTOR_TMP_REG_LMUL.U
746395c8649SZiyue-Zhang          // csBundle(2 * i + 2).lsrc(1) := src2 + i.U         // DontCare
747395c8649SZiyue-Zhang          csBundle(2 * i + 2).lsrc(2) := VECTOR_TMP_REG_LMUL.U + 1.U
748395c8649SZiyue-Zhang          csBundle(2 * i + 2).ldest := dest + i.U
749395c8649SZiyue-Zhang          csBundle(2 * i + 2).uopIdx := (2 * i + 1).U
750d91483a6Sfdy        }
751395c8649SZiyue-Zhang      }
752395c8649SZiyue-Zhang      csBundle(numOfUop - 1.U).srcType(0) := SrcType.vp
753395c8649SZiyue-Zhang      csBundle(numOfUop - 1.U).lsrc(0) := VECTOR_TMP_REG_LMUL.U
754d91483a6Sfdy      csBundle(numOfUop - 1.U).ldest := dest + lmul - 1.U
755d91483a6Sfdy    }
75617ec87f2SXuan Hu    is(UopSplitType.VEC_VRED) {
757aaa08c5aSxiaofeibao-xjtu      when(vlmulReg === "b001".U) {
758d91483a6Sfdy        csBundle(0).srcType(2) := SrcType.DC
759d91483a6Sfdy        csBundle(0).lsrc(0) := src2 + 1.U
760d91483a6Sfdy        csBundle(0).lsrc(1) := src2
761d91483a6Sfdy        csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
762d91483a6Sfdy        csBundle(0).uopIdx := 0.U
763d91483a6Sfdy      }
764aaa08c5aSxiaofeibao-xjtu      when(vlmulReg === "b010".U) {
765d91483a6Sfdy        csBundle(0).srcType(2) := SrcType.DC
766d91483a6Sfdy        csBundle(0).lsrc(0) := src2 + 1.U
767d91483a6Sfdy        csBundle(0).lsrc(1) := src2
768d91483a6Sfdy        csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
769d91483a6Sfdy        csBundle(0).uopIdx := 0.U
770d91483a6Sfdy
771d91483a6Sfdy        csBundle(1).srcType(2) := SrcType.DC
772d91483a6Sfdy        csBundle(1).lsrc(0) := src2 + 3.U
773d91483a6Sfdy        csBundle(1).lsrc(1) := src2 + 2.U
774d91483a6Sfdy        csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
775d91483a6Sfdy        csBundle(1).uopIdx := 1.U
776d91483a6Sfdy
777d91483a6Sfdy        csBundle(2).srcType(2) := SrcType.DC
778d91483a6Sfdy        csBundle(2).lsrc(0) := (VECTOR_TMP_REG_LMUL + 1).U
779d91483a6Sfdy        csBundle(2).lsrc(1) := VECTOR_TMP_REG_LMUL.U
780d91483a6Sfdy        csBundle(2).ldest := (VECTOR_TMP_REG_LMUL + 2).U
781d91483a6Sfdy        csBundle(2).uopIdx := 2.U
782d91483a6Sfdy      }
783aaa08c5aSxiaofeibao-xjtu      when(vlmulReg === "b011".U) {
784d91483a6Sfdy        for (i <- 0 until MAX_VLMUL) {
785d91483a6Sfdy          if (i < MAX_VLMUL - MAX_VLMUL / 2) {
786d91483a6Sfdy            csBundle(i).lsrc(0) := src2 + (i * 2 + 1).U
787d91483a6Sfdy            csBundle(i).lsrc(1) := src2 + (i * 2).U
788d91483a6Sfdy            csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
789d91483a6Sfdy          } else if (i < MAX_VLMUL - MAX_VLMUL / 4) {
790d91483a6Sfdy            csBundle(i).lsrc(0) := (VECTOR_TMP_REG_LMUL + (i - MAX_VLMUL / 2) * 2 + 1).U
791d91483a6Sfdy            csBundle(i).lsrc(1) := (VECTOR_TMP_REG_LMUL + (i - MAX_VLMUL / 2) * 2).U
792d91483a6Sfdy            csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
793d91483a6Sfdy          } else if (i < MAX_VLMUL - MAX_VLMUL / 8) {
794d91483a6Sfdy            csBundle(6).lsrc(0) := (VECTOR_TMP_REG_LMUL + 5).U
795d91483a6Sfdy            csBundle(6).lsrc(1) := (VECTOR_TMP_REG_LMUL + 4).U
796d91483a6Sfdy            csBundle(6).ldest := (VECTOR_TMP_REG_LMUL + 6).U
797d91483a6Sfdy          }
798d91483a6Sfdy          csBundle(i).srcType(2) := SrcType.DC
799d91483a6Sfdy          csBundle(i).uopIdx := i.U
800d91483a6Sfdy        }
801d91483a6Sfdy      }
802caa15984SZiyue Zhang      when(vlmulReg(2) === 0.U && vlmulReg(1, 0).orR) {
803caa15984SZiyue Zhang        /*
804caa15984SZiyue Zhang         * 2 <= vlmul <= 8
805caa15984SZiyue Zhang         */
806d91483a6Sfdy        csBundle(numOfUop - 1.U).srcType(2) := SrcType.vp
807d91483a6Sfdy        csBundle(numOfUop - 1.U).lsrc(0) := src1
808d91483a6Sfdy        csBundle(numOfUop - 1.U).lsrc(1) := VECTOR_TMP_REG_LMUL.U + numOfUop - 2.U
809d91483a6Sfdy        csBundle(numOfUop - 1.U).lsrc(2) := dest
810d91483a6Sfdy        csBundle(numOfUop - 1.U).ldest := dest
811d91483a6Sfdy        csBundle(numOfUop - 1.U).uopIdx := numOfUop - 1.U
812d91483a6Sfdy      }
813d91483a6Sfdy    }
814582849ffSxiaofeibao-xjtu    is(UopSplitType.VEC_VFRED) {
815aaa08c5aSxiaofeibao-xjtu      val vlmul = vlmulReg
816aaa08c5aSxiaofeibao-xjtu      val vsew = vsewReg
817582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.m8){
818582849ffSxiaofeibao-xjtu        for (i <- 0 until 4) {
819582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(0) := src2 + (i * 2 + 1).U
820582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(1) := src2 + (i * 2).U
821582849ffSxiaofeibao-xjtu          csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
822582849ffSxiaofeibao-xjtu          csBundle(i).uopIdx := i.U
823582849ffSxiaofeibao-xjtu        }
824582849ffSxiaofeibao-xjtu        for (i <- 4 until 6) {
825582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(0) := (VECTOR_TMP_REG_LMUL + (i - 4) * 2 + 1).U
826582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(1) := (VECTOR_TMP_REG_LMUL + (i - 4) * 2).U
827582849ffSxiaofeibao-xjtu          csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
828582849ffSxiaofeibao-xjtu          csBundle(i).uopIdx := i.U
829582849ffSxiaofeibao-xjtu        }
830582849ffSxiaofeibao-xjtu        csBundle(6).lsrc(0) := (VECTOR_TMP_REG_LMUL + 5).U
831582849ffSxiaofeibao-xjtu        csBundle(6).lsrc(1) := (VECTOR_TMP_REG_LMUL + 4).U
832582849ffSxiaofeibao-xjtu        csBundle(6).ldest := (VECTOR_TMP_REG_LMUL + 6).U
833582849ffSxiaofeibao-xjtu        csBundle(6).uopIdx := 6.U
834582849ffSxiaofeibao-xjtu        when(vsew === VSew.e64) {
835582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(0) := (VECTOR_TMP_REG_LMUL + 6).U
836582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(1) := (VECTOR_TMP_REG_LMUL + 6).U
837582849ffSxiaofeibao-xjtu          csBundle(7).ldest := (VECTOR_TMP_REG_LMUL + 7).U
838582849ffSxiaofeibao-xjtu          csBundle(7).vpu.fpu.isFoldTo1_2 := true.B
839582849ffSxiaofeibao-xjtu          csBundle(7).uopIdx := 7.U
840582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(0) := src1
841582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(1) := (VECTOR_TMP_REG_LMUL + 7).U
842582849ffSxiaofeibao-xjtu          csBundle(8).ldest := dest
843582849ffSxiaofeibao-xjtu          csBundle(8).uopIdx := 8.U
844582849ffSxiaofeibao-xjtu        }
845582849ffSxiaofeibao-xjtu        when(vsew === VSew.e32) {
846582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(0) := (VECTOR_TMP_REG_LMUL + 6).U
847582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(1) := (VECTOR_TMP_REG_LMUL + 6).U
848582849ffSxiaofeibao-xjtu          csBundle(7).ldest := (VECTOR_TMP_REG_LMUL + 7).U
849582849ffSxiaofeibao-xjtu          csBundle(7).vpu.fpu.isFoldTo1_2 := true.B
850582849ffSxiaofeibao-xjtu          csBundle(7).uopIdx := 7.U
851582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(0) := (VECTOR_TMP_REG_LMUL + 7).U
852582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(1) := (VECTOR_TMP_REG_LMUL + 7).U
853582849ffSxiaofeibao-xjtu          csBundle(8).ldest := (VECTOR_TMP_REG_LMUL + 8).U
854582849ffSxiaofeibao-xjtu          csBundle(8).vpu.fpu.isFoldTo1_4 := true.B
855582849ffSxiaofeibao-xjtu          csBundle(8).uopIdx := 8.U
856582849ffSxiaofeibao-xjtu          csBundle(9).lsrc(0) := src1
857582849ffSxiaofeibao-xjtu          csBundle(9).lsrc(1) := (VECTOR_TMP_REG_LMUL + 8).U
858582849ffSxiaofeibao-xjtu          csBundle(9).ldest := dest
859582849ffSxiaofeibao-xjtu          csBundle(9).uopIdx := 9.U
860582849ffSxiaofeibao-xjtu        }
861582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
862582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(0) := (VECTOR_TMP_REG_LMUL + 6).U
863582849ffSxiaofeibao-xjtu          csBundle(7).lsrc(1) := (VECTOR_TMP_REG_LMUL + 6).U
864582849ffSxiaofeibao-xjtu          csBundle(7).ldest := (VECTOR_TMP_REG_LMUL + 7).U
865582849ffSxiaofeibao-xjtu          csBundle(7).vpu.fpu.isFoldTo1_2 := true.B
866582849ffSxiaofeibao-xjtu          csBundle(7).uopIdx := 7.U
867582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(0) := (VECTOR_TMP_REG_LMUL + 7).U
868582849ffSxiaofeibao-xjtu          csBundle(8).lsrc(1) := (VECTOR_TMP_REG_LMUL + 7).U
869582849ffSxiaofeibao-xjtu          csBundle(8).ldest := (VECTOR_TMP_REG_LMUL + 8).U
870582849ffSxiaofeibao-xjtu          csBundle(8).vpu.fpu.isFoldTo1_4 := true.B
871582849ffSxiaofeibao-xjtu          csBundle(8).uopIdx := 8.U
872582849ffSxiaofeibao-xjtu          csBundle(9).lsrc(0) := (VECTOR_TMP_REG_LMUL + 8).U
873582849ffSxiaofeibao-xjtu          csBundle(9).lsrc(1) := (VECTOR_TMP_REG_LMUL + 8).U
874582849ffSxiaofeibao-xjtu          csBundle(9).ldest := (VECTOR_TMP_REG_LMUL + 9).U
875582849ffSxiaofeibao-xjtu          csBundle(9).vpu.fpu.isFoldTo1_8 := true.B
876582849ffSxiaofeibao-xjtu          csBundle(9).uopIdx := 9.U
877582849ffSxiaofeibao-xjtu          csBundle(10).lsrc(0) := src1
878582849ffSxiaofeibao-xjtu          csBundle(10).lsrc(1) := (VECTOR_TMP_REG_LMUL + 9).U
879582849ffSxiaofeibao-xjtu          csBundle(10).ldest := dest
880582849ffSxiaofeibao-xjtu          csBundle(10).uopIdx := 10.U
881582849ffSxiaofeibao-xjtu        }
882582849ffSxiaofeibao-xjtu      }
883582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.m4) {
884582849ffSxiaofeibao-xjtu        for (i <- 0 until 2) {
885582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(0) := src2 + (i * 2 + 1).U
886582849ffSxiaofeibao-xjtu          csBundle(i).lsrc(1) := src2 + (i * 2).U
887582849ffSxiaofeibao-xjtu          csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
888582849ffSxiaofeibao-xjtu          csBundle(i).uopIdx := i.U
889582849ffSxiaofeibao-xjtu        }
890582849ffSxiaofeibao-xjtu        csBundle(2).lsrc(0) := (VECTOR_TMP_REG_LMUL + 1).U
891582849ffSxiaofeibao-xjtu        csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
892582849ffSxiaofeibao-xjtu        csBundle(2).ldest := (VECTOR_TMP_REG_LMUL + 2).U
893582849ffSxiaofeibao-xjtu        csBundle(2).uopIdx := 2.U
894582849ffSxiaofeibao-xjtu        when(vsew === VSew.e64) {
895582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := (VECTOR_TMP_REG_LMUL + 2).U
896582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
897582849ffSxiaofeibao-xjtu          csBundle(3).ldest := (VECTOR_TMP_REG_LMUL + 3).U
898582849ffSxiaofeibao-xjtu          csBundle(3).vpu.fpu.isFoldTo1_2 := true.B
899582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
900582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(0) := src1
901582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(1) := (VECTOR_TMP_REG_LMUL + 3).U
902582849ffSxiaofeibao-xjtu          csBundle(4).ldest := dest
903582849ffSxiaofeibao-xjtu          csBundle(4).uopIdx := 4.U
904582849ffSxiaofeibao-xjtu        }
905582849ffSxiaofeibao-xjtu        when(vsew === VSew.e32) {
906582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := (VECTOR_TMP_REG_LMUL + 2).U
907582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
908582849ffSxiaofeibao-xjtu          csBundle(3).ldest := (VECTOR_TMP_REG_LMUL + 3).U
909582849ffSxiaofeibao-xjtu          csBundle(3).vpu.fpu.isFoldTo1_2 := true.B
910582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
911582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(0) := (VECTOR_TMP_REG_LMUL + 3).U
912582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(1) := (VECTOR_TMP_REG_LMUL + 3).U
913582849ffSxiaofeibao-xjtu          csBundle(4).ldest := (VECTOR_TMP_REG_LMUL + 4).U
914582849ffSxiaofeibao-xjtu          csBundle(4).vpu.fpu.isFoldTo1_4 := true.B
915582849ffSxiaofeibao-xjtu          csBundle(4).uopIdx := 4.U
916582849ffSxiaofeibao-xjtu          csBundle(5).lsrc(0) := src1
917582849ffSxiaofeibao-xjtu          csBundle(5).lsrc(1) := (VECTOR_TMP_REG_LMUL + 4).U
918582849ffSxiaofeibao-xjtu          csBundle(5).ldest := dest
919582849ffSxiaofeibao-xjtu          csBundle(5).uopIdx := 5.U
920582849ffSxiaofeibao-xjtu        }
921582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
922582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := (VECTOR_TMP_REG_LMUL + 2).U
923582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
924582849ffSxiaofeibao-xjtu          csBundle(3).ldest := (VECTOR_TMP_REG_LMUL + 3).U
925582849ffSxiaofeibao-xjtu          csBundle(3).vpu.fpu.isFoldTo1_2 := true.B
926582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
927582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(0) := (VECTOR_TMP_REG_LMUL + 3).U
928582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(1) := (VECTOR_TMP_REG_LMUL + 3).U
929582849ffSxiaofeibao-xjtu          csBundle(4).ldest := (VECTOR_TMP_REG_LMUL + 4).U
930582849ffSxiaofeibao-xjtu          csBundle(4).vpu.fpu.isFoldTo1_4 := true.B
931582849ffSxiaofeibao-xjtu          csBundle(4).uopIdx := 4.U
932582849ffSxiaofeibao-xjtu          csBundle(5).lsrc(0) := (VECTOR_TMP_REG_LMUL + 4).U
933582849ffSxiaofeibao-xjtu          csBundle(5).lsrc(1) := (VECTOR_TMP_REG_LMUL + 4).U
934582849ffSxiaofeibao-xjtu          csBundle(5).ldest := (VECTOR_TMP_REG_LMUL + 5).U
935582849ffSxiaofeibao-xjtu          csBundle(5).vpu.fpu.isFoldTo1_8 := true.B
936582849ffSxiaofeibao-xjtu          csBundle(5).uopIdx := 5.U
937582849ffSxiaofeibao-xjtu          csBundle(6).lsrc(0) := src1
938582849ffSxiaofeibao-xjtu          csBundle(6).lsrc(1) := (VECTOR_TMP_REG_LMUL + 5).U
939582849ffSxiaofeibao-xjtu          csBundle(6).ldest := dest
940582849ffSxiaofeibao-xjtu          csBundle(6).uopIdx := 6.U
941582849ffSxiaofeibao-xjtu        }
942582849ffSxiaofeibao-xjtu      }
943582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.m2) {
944582849ffSxiaofeibao-xjtu        csBundle(0).lsrc(0) := src2 + 1.U
945582849ffSxiaofeibao-xjtu        csBundle(0).lsrc(1) := src2 + 0.U
946582849ffSxiaofeibao-xjtu        csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
947582849ffSxiaofeibao-xjtu        csBundle(0).uopIdx := 0.U
948582849ffSxiaofeibao-xjtu        when(vsew === VSew.e64) {
949582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
950582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
951582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
952582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_2 := true.B
953582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
954582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := src1
955582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
956582849ffSxiaofeibao-xjtu          csBundle(2).ldest := dest
957582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
958582849ffSxiaofeibao-xjtu        }
959582849ffSxiaofeibao-xjtu        when(vsew === VSew.e32) {
960582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
961582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
962582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
963582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_2 := true.B
964582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
965582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := (VECTOR_TMP_REG_LMUL + 1).U
966582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
967582849ffSxiaofeibao-xjtu          csBundle(2).ldest := (VECTOR_TMP_REG_LMUL + 2).U
968582849ffSxiaofeibao-xjtu          csBundle(2).vpu.fpu.isFoldTo1_4 := true.B
969582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
970582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := src1
971582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
972582849ffSxiaofeibao-xjtu          csBundle(3).ldest := dest
973582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
974582849ffSxiaofeibao-xjtu        }
975582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
976582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
977582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
978582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
979582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_2 := true.B
980582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
981582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := (VECTOR_TMP_REG_LMUL + 1).U
982582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
983582849ffSxiaofeibao-xjtu          csBundle(2).ldest := (VECTOR_TMP_REG_LMUL + 2).U
984582849ffSxiaofeibao-xjtu          csBundle(2).vpu.fpu.isFoldTo1_4 := true.B
985582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
986582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := (VECTOR_TMP_REG_LMUL + 2).U
987582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
988582849ffSxiaofeibao-xjtu          csBundle(3).ldest := (VECTOR_TMP_REG_LMUL + 3).U
989582849ffSxiaofeibao-xjtu          csBundle(3).vpu.fpu.isFoldTo1_8 := true.B
990582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
991582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(0) := src1
992582849ffSxiaofeibao-xjtu          csBundle(4).lsrc(1) := (VECTOR_TMP_REG_LMUL + 3).U
993582849ffSxiaofeibao-xjtu          csBundle(4).ldest := dest
994582849ffSxiaofeibao-xjtu          csBundle(4).uopIdx := 4.U
995582849ffSxiaofeibao-xjtu        }
996582849ffSxiaofeibao-xjtu      }
997582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.m1) {
998582849ffSxiaofeibao-xjtu        when(vsew === VSew.e64) {
999582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1000582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1001582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1002582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_2 := true.B
1003582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1004582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := src1
1005582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1006582849ffSxiaofeibao-xjtu          csBundle(1).ldest := dest
1007582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1008582849ffSxiaofeibao-xjtu        }
1009582849ffSxiaofeibao-xjtu        when(vsew === VSew.e32) {
1010582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1011582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1012582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1013582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_2 := true.B
1014582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1015582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
1016582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1017582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
1018582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_4 := true.B
1019582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1020582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := src1
1021582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
1022582849ffSxiaofeibao-xjtu          csBundle(2).ldest := dest
1023582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
1024582849ffSxiaofeibao-xjtu        }
1025582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
1026582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1027582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1028582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1029582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_2 := true.B
1030582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1031582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
1032582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1033582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
1034582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_4 := true.B
1035582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1036582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := (VECTOR_TMP_REG_LMUL + 1).U
1037582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
1038582849ffSxiaofeibao-xjtu          csBundle(2).ldest := (VECTOR_TMP_REG_LMUL + 2).U
1039582849ffSxiaofeibao-xjtu          csBundle(2).vpu.fpu.isFoldTo1_8 := true.B
1040582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
1041582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(0) := src1
1042582849ffSxiaofeibao-xjtu          csBundle(3).lsrc(1) := (VECTOR_TMP_REG_LMUL + 2).U
1043582849ffSxiaofeibao-xjtu          csBundle(3).ldest := dest
1044582849ffSxiaofeibao-xjtu          csBundle(3).uopIdx := 3.U
1045582849ffSxiaofeibao-xjtu        }
1046582849ffSxiaofeibao-xjtu      }
1047582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.mf2) {
1048582849ffSxiaofeibao-xjtu        when(vsew === VSew.e32) {
1049582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1050582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1051582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1052582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_4 := true.B
1053582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1054582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := src1
1055582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1056582849ffSxiaofeibao-xjtu          csBundle(1).ldest := dest
1057582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1058582849ffSxiaofeibao-xjtu        }
1059582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
1060582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1061582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1062582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1063582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_4 := true.B
1064582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1065582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := (VECTOR_TMP_REG_LMUL + 0).U
1066582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1067582849ffSxiaofeibao-xjtu          csBundle(1).ldest := (VECTOR_TMP_REG_LMUL + 1).U
1068582849ffSxiaofeibao-xjtu          csBundle(1).vpu.fpu.isFoldTo1_8 := true.B
1069582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1070582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(0) := src1
1071582849ffSxiaofeibao-xjtu          csBundle(2).lsrc(1) := (VECTOR_TMP_REG_LMUL + 1).U
1072582849ffSxiaofeibao-xjtu          csBundle(2).ldest := dest
1073582849ffSxiaofeibao-xjtu          csBundle(2).uopIdx := 2.U
1074582849ffSxiaofeibao-xjtu        }
1075582849ffSxiaofeibao-xjtu      }
1076582849ffSxiaofeibao-xjtu      when(vlmul === VLmul.mf4) {
1077582849ffSxiaofeibao-xjtu        when(vsew === VSew.e16) {
1078582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(0) := src2
1079582849ffSxiaofeibao-xjtu          csBundle(0).lsrc(1) := src2
1080582849ffSxiaofeibao-xjtu          csBundle(0).ldest := (VECTOR_TMP_REG_LMUL + 0).U
1081582849ffSxiaofeibao-xjtu          csBundle(0).vpu.fpu.isFoldTo1_8 := true.B
1082582849ffSxiaofeibao-xjtu          csBundle(0).uopIdx := 0.U
1083582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(0) := src1
1084582849ffSxiaofeibao-xjtu          csBundle(1).lsrc(1) := (VECTOR_TMP_REG_LMUL + 0).U
1085582849ffSxiaofeibao-xjtu          csBundle(1).ldest := dest
1086582849ffSxiaofeibao-xjtu          csBundle(1).uopIdx := 1.U
1087582849ffSxiaofeibao-xjtu        }
1088582849ffSxiaofeibao-xjtu      }
1089582849ffSxiaofeibao-xjtu    }
1090d91483a6Sfdy
1091b94b1889Sxiaofeibao-xjtu    is(UopSplitType.VEC_VFREDOSUM) {
1092b94b1889Sxiaofeibao-xjtu      import yunsuan.VfaluType
1093aaa08c5aSxiaofeibao-xjtu      val vlmul = vlmulReg
1094aaa08c5aSxiaofeibao-xjtu      val vsew = vsewReg
1095e25c13faSXuan Hu      val isWiden = latchedInst.fuOpType === VfaluType.vfwredosum
1096b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.m8) {
1097b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e64) {
1098b94b1889Sxiaofeibao-xjtu          val vlmax = 16
1099b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1100b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1101b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 2 == 0) src2 + (i/2).U else VECTOR_TMP_REG_LMUL.U)
1102b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 2 == 0) src2 + (i/2).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1103b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1104b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := (if (i % 2 == 0) false.B else true.B)
1105b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1106b94b1889Sxiaofeibao-xjtu          }
1107b94b1889Sxiaofeibao-xjtu        }
1108b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e32) {
1109b94b1889Sxiaofeibao-xjtu          val vlmax = 32
1110b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1111b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1112b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 4 == 0) src2 + (i/4).U else VECTOR_TMP_REG_LMUL.U)
1113b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 4 == 0) src2 + (i/4).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1114b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1115b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := (if (i % 4 == 0) false.B else true.B)
1116b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1117b94b1889Sxiaofeibao-xjtu          }
1118b94b1889Sxiaofeibao-xjtu        }
1119b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1120b94b1889Sxiaofeibao-xjtu          val vlmax = 64
1121b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1122b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1123b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1124b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1125b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1126b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := (if (i % 8 == 0) false.B else true.B)
1127b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1128b94b1889Sxiaofeibao-xjtu          }
1129b94b1889Sxiaofeibao-xjtu        }
1130b94b1889Sxiaofeibao-xjtu      }
1131b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.m4) {
1132b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e64) {
1133b94b1889Sxiaofeibao-xjtu          val vlmax = 8
1134b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1135b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1136b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 2 == 0) src2 + (i/2).U else VECTOR_TMP_REG_LMUL.U)
1137b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 2 == 0) src2 + (i/2).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1138b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1139b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := (if (i % 2 == 0) false.B else true.B)
1140b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1141b94b1889Sxiaofeibao-xjtu          }
1142b94b1889Sxiaofeibao-xjtu        }
1143b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e32) {
1144b94b1889Sxiaofeibao-xjtu          val vlmax = 16
1145b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1146b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1147b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 4 == 0) src2 + (i/4).U else VECTOR_TMP_REG_LMUL.U)
1148b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 4 == 0) src2 + (i/4).U else if (i == vlmax - 1) dest else if (i % 4 == 1) Mux(isWiden, src2 + (i/4).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1149b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1150b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := isWiden && (if (i % 4 == 0) false.B else true.B)
1151b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := !isWiden && (if (i % 4 == 0) false.B else true.B)
1152b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1153b94b1889Sxiaofeibao-xjtu          }
1154b94b1889Sxiaofeibao-xjtu        }
1155b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1156b94b1889Sxiaofeibao-xjtu          val vlmax = 32
1157b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1158b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1159b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1160b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else if (i % 8 == 1) Mux(isWiden, src2 + (i/8).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1161b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1162b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := isWiden && (if (i % 8 == 0) false.B else true.B)
1163b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := !isWiden && (if (i % 8 == 0) false.B else true.B)
1164b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1165b94b1889Sxiaofeibao-xjtu          }
1166b94b1889Sxiaofeibao-xjtu        }
1167b94b1889Sxiaofeibao-xjtu      }
1168b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.m2) {
1169b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e64) {
1170b94b1889Sxiaofeibao-xjtu          val vlmax = 4
1171b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1172b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1173b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 2 == 0) src2 + (i/2).U else VECTOR_TMP_REG_LMUL.U)
1174b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 2 == 0) src2 + (i/2).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1175b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1176b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := (if (i % 2 == 0) false.B else true.B)
1177b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1178b94b1889Sxiaofeibao-xjtu          }
1179b94b1889Sxiaofeibao-xjtu        }
1180b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e32) {
1181b94b1889Sxiaofeibao-xjtu          val vlmax = 8
1182b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1183b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1184b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 4 == 0) src2 + (i/4).U else VECTOR_TMP_REG_LMUL.U)
1185b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 4 == 0) src2 + (i/4).U else if (i == vlmax - 1) dest else if (i % 4 == 1) Mux(isWiden, src2 + (i/4).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1186b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1187b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := isWiden && (if (i % 4 == 0) false.B else true.B)
1188b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := !isWiden && (if (i % 4 == 0) false.B else true.B)
1189b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1190b94b1889Sxiaofeibao-xjtu          }
1191b94b1889Sxiaofeibao-xjtu        }
1192b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1193b94b1889Sxiaofeibao-xjtu          val vlmax = 16
1194b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1195b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1196b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1197b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else if (i % 8 == 1) Mux(isWiden, src2 + (i/8).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1198b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1199b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := isWiden && (if (i % 8 == 0) false.B else true.B)
1200b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := !isWiden && (if (i % 8 == 0) false.B else true.B)
1201b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1202b94b1889Sxiaofeibao-xjtu          }
1203b94b1889Sxiaofeibao-xjtu        }
1204b94b1889Sxiaofeibao-xjtu      }
1205b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.m1) {
1206b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e64) {
1207b94b1889Sxiaofeibao-xjtu          val vlmax = 2
1208b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1209b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1210b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 2 == 0) src2 + (i/2).U else VECTOR_TMP_REG_LMUL.U)
1211b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 2 == 0) src2 + (i/2).U else if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1212b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1213b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := (if (i % 2 == 0) false.B else true.B)
1214b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1215b94b1889Sxiaofeibao-xjtu          }
1216b94b1889Sxiaofeibao-xjtu        }
1217b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e32) {
1218b94b1889Sxiaofeibao-xjtu          val vlmax = 4
1219b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1220b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1221b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 4 == 0) src2 + (i/4).U else VECTOR_TMP_REG_LMUL.U)
1222b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 4 == 0) src2 + (i/4).U else if (i == vlmax - 1) dest else if (i % 4 == 1) Mux(isWiden, src2 + (i/4).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1223b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1224b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := isWiden && (if (i % 4 == 0) false.B else true.B)
1225b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := !isWiden && (if (i % 4 == 0) false.B else true.B)
1226b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1227b94b1889Sxiaofeibao-xjtu          }
1228b94b1889Sxiaofeibao-xjtu        }
1229b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1230b94b1889Sxiaofeibao-xjtu          val vlmax = 8
1231b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1232b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1233b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1234b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else if (i % 8 == 1) Mux(isWiden, src2 + (i/8).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1235b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1236b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := isWiden && (if (i % 8 == 0) false.B else true.B)
1237b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := !isWiden && (if (i % 8 == 0) false.B else true.B)
1238b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1239b94b1889Sxiaofeibao-xjtu          }
1240b94b1889Sxiaofeibao-xjtu        }
1241b94b1889Sxiaofeibao-xjtu      }
1242b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.mf2) {
1243b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e32) {
1244b94b1889Sxiaofeibao-xjtu          val vlmax = 2
1245b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1246b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1247b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 4 == 0) src2 + (i/4).U else VECTOR_TMP_REG_LMUL.U)
1248b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 4 == 0) src2 + (i/4).U else if (i == vlmax - 1) dest else if (i % 4 == 1) Mux(isWiden, src2 + (i/4).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1249b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1250b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_2 := isWiden && (if (i % 4 == 0) false.B else true.B)
1251b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := !isWiden && (if (i % 4 == 0) false.B else true.B)
1252b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1253b94b1889Sxiaofeibao-xjtu          }
1254b94b1889Sxiaofeibao-xjtu        }
1255b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1256b94b1889Sxiaofeibao-xjtu          val vlmax = 4
1257b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1258b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1259b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1260b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else if (i % 8 == 1) Mux(isWiden, src2 + (i/8).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1261b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1262b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := isWiden && (if (i % 8 == 0) false.B else true.B)
1263b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := !isWiden && (if (i % 8 == 0) false.B else true.B)
1264b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1265b94b1889Sxiaofeibao-xjtu          }
1266b94b1889Sxiaofeibao-xjtu        }
1267b94b1889Sxiaofeibao-xjtu      }
1268b94b1889Sxiaofeibao-xjtu      when(vlmul === VLmul.mf4) {
1269b94b1889Sxiaofeibao-xjtu        when(vsew === VSew.e16) {
1270b94b1889Sxiaofeibao-xjtu          val vlmax = 2
1271b94b1889Sxiaofeibao-xjtu          for (i <- 0 until vlmax) {
1272b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(0) := (if (i == 0) src1 else VECTOR_TMP_REG_LMUL.U)
1273b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(1) := (if (i % 8 == 0) src2 + (i/8).U else VECTOR_TMP_REG_LMUL.U)
1274b94b1889Sxiaofeibao-xjtu            csBundle(i).lsrc(2) := (if (i % 8 == 0) src2 + (i/8).U else if (i == vlmax - 1) dest else if (i % 8 == 1) Mux(isWiden, src2 + (i/8).U, VECTOR_TMP_REG_LMUL.U) else VECTOR_TMP_REG_LMUL.U)
1275b94b1889Sxiaofeibao-xjtu            csBundle(i).ldest := (if (i == vlmax - 1) dest else VECTOR_TMP_REG_LMUL.U)
1276b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_4 := isWiden && (if (i % 8 == 0) false.B else true.B)
1277b94b1889Sxiaofeibao-xjtu            csBundle(i).vpu.fpu.isFoldTo1_8 := !isWiden && (if (i % 8 == 0) false.B else true.B)
1278b94b1889Sxiaofeibao-xjtu            csBundle(i).uopIdx := i.U
1279b94b1889Sxiaofeibao-xjtu          }
1280b94b1889Sxiaofeibao-xjtu        }
1281b94b1889Sxiaofeibao-xjtu      }
1282b94b1889Sxiaofeibao-xjtu    }
1283d6059658SZiyue Zhang
128417ec87f2SXuan Hu    is(UopSplitType.VEC_SLIDEUP) {
1285d6059658SZiyue Zhang      // i to vector move
1286d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
1287d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
1288*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
1289d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
1290fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
1291fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1292b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.imm2Vec(2, 0), IF2VectorType.i2Vec(2, 0)), vsewReg)
1293fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
1294d91483a6Sfdy      // LMUL
1295d91483a6Sfdy      for (i <- 0 until MAX_VLMUL)
1296d91483a6Sfdy        for (j <- 0 to i) {
12974ee69032SzhanglyGit          val old_vd = if (j == 0) {
12984ee69032SzhanglyGit            dest + i.U
1299fc85f18fSZiyue Zhang          } else (VECTOR_TMP_REG_LMUL + j).U
13004ee69032SzhanglyGit          val vd = if (j == i) {
13014ee69032SzhanglyGit            dest + i.U
1302fc85f18fSZiyue Zhang          } else (VECTOR_TMP_REG_LMUL + j + 1).U
1303fc85f18fSZiyue Zhang          csBundle(i * (i + 1) / 2 + j + 1).srcType(0) := SrcType.vp
1304fc85f18fSZiyue Zhang          csBundle(i * (i + 1) / 2 + j + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
1305d91483a6Sfdy          csBundle(i * (i + 1) / 2 + j + 1).lsrc(1) := src2 + j.U
1306d91483a6Sfdy          csBundle(i * (i + 1) / 2 + j + 1).lsrc(2) := old_vd
1307d91483a6Sfdy          csBundle(i * (i + 1) / 2 + j + 1).ldest := vd
1308d91483a6Sfdy          csBundle(i * (i + 1) / 2 + j + 1).uopIdx := (i * (i + 1) / 2 + j).U
1309d91483a6Sfdy        }
1310d91483a6Sfdy    }
1311d91483a6Sfdy
131217ec87f2SXuan Hu    is(UopSplitType.VEC_SLIDEDOWN) {
1313d6059658SZiyue Zhang      // i to vector move
1314d91483a6Sfdy      csBundle(0).srcType(0) := SrcType.reg
1315d91483a6Sfdy      csBundle(0).srcType(1) := SrcType.imm
1316*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
1317d91483a6Sfdy      csBundle(0).lsrc(1) := 0.U
1318fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
1319fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1320b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.imm2Vec(2, 0), IF2VectorType.i2Vec(2, 0)), vsewReg)
1321fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
1322d91483a6Sfdy      // LMUL
1323d91483a6Sfdy      for (i <- 0 until MAX_VLMUL)
1324d91483a6Sfdy        for (j <- (0 to i).reverse) {
1325d91483a6Sfdy          when(i.U < lmul) {
13264ee69032SzhanglyGit            val old_vd = if (j == 0) {
13274ee69032SzhanglyGit              dest + lmul - 1.U - i.U
1328fc85f18fSZiyue Zhang            } else (VECTOR_TMP_REG_LMUL + j).U
13294ee69032SzhanglyGit            val vd = if (j == i) {
13304ee69032SzhanglyGit              dest + lmul - 1.U - i.U
1331fc85f18fSZiyue Zhang            } else (VECTOR_TMP_REG_LMUL + j + 1).U
1332fc85f18fSZiyue Zhang            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).srcType(0) := SrcType.vp
1333fc85f18fSZiyue Zhang            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).lsrc(0) := VECTOR_TMP_REG_LMUL.U
1334d91483a6Sfdy            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).lsrc(1) := src2 + lmul - 1.U - j.U
1335d91483a6Sfdy            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).lsrc(2) := old_vd
1336d91483a6Sfdy            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).ldest := vd
1337d91483a6Sfdy            csBundle(numOfUop - (i * (i + 1) / 2 + i - j + 1).U).uopIdx := numOfUop - (i * (i + 1) / 2 + i - j + 2).U
1338d91483a6Sfdy          }
1339d91483a6Sfdy        }
1340d91483a6Sfdy    }
1341d91483a6Sfdy
134217ec87f2SXuan Hu    is(UopSplitType.VEC_M0X) {
1343d91483a6Sfdy      // LMUL
1344d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
1345d91483a6Sfdy        val srcType0 = if (i == 0) SrcType.DC else SrcType.vp
1346d91483a6Sfdy        val ldest = (VECTOR_TMP_REG_LMUL + i).U
1347d91483a6Sfdy        csBundle(i).srcType(0) := srcType0
1348d91483a6Sfdy        csBundle(i).srcType(1) := SrcType.vp
1349d91483a6Sfdy        csBundle(i).rfWen := false.B
1350cd2c45feSZiyue Zhang        csBundle(i).fpWen := false.B
1351d91483a6Sfdy        csBundle(i).vecWen := true.B
1352d91483a6Sfdy        csBundle(i).lsrc(0) := (VECTOR_TMP_REG_LMUL + i - 1).U
1353d91483a6Sfdy        csBundle(i).lsrc(1) := src2
1354d91483a6Sfdy        // csBundle(i).lsrc(2) := dest + i.U  DontCare
1355d91483a6Sfdy        csBundle(i).ldest := ldest
1356d91483a6Sfdy        csBundle(i).uopIdx := i.U
1357d91483a6Sfdy      }
1358cd2c45feSZiyue Zhang      csBundle(lmul - 1.U).rfWen := true.B
1359cd2c45feSZiyue Zhang      csBundle(lmul - 1.U).fpWen := false.B
1360d91483a6Sfdy      csBundle(lmul - 1.U).vecWen := false.B
1361cd2c45feSZiyue Zhang      csBundle(lmul - 1.U).ldest := dest
1362d91483a6Sfdy    }
1363d91483a6Sfdy
136417ec87f2SXuan Hu    is(UopSplitType.VEC_MVV) {
1365d91483a6Sfdy      // LMUL
1366d91483a6Sfdy      for (i <- 0 until MAX_VLMUL) {
1367d91483a6Sfdy        val srcType0 = if (i == 0) SrcType.DC else SrcType.vp
1368d91483a6Sfdy        csBundle(i * 2 + 0).srcType(0) := srcType0
1369d91483a6Sfdy        csBundle(i * 2 + 0).srcType(1) := SrcType.vp
1370d91483a6Sfdy        csBundle(i * 2 + 0).lsrc(0) := (VECTOR_TMP_REG_LMUL + i - 1).U
1371d91483a6Sfdy        csBundle(i * 2 + 0).lsrc(1) := src2
1372d91483a6Sfdy        csBundle(i * 2 + 0).lsrc(2) := dest + i.U
1373d91483a6Sfdy        csBundle(i * 2 + 0).ldest := dest + i.U
1374d91483a6Sfdy        csBundle(i * 2 + 0).uopIdx := (i * 2 + 0).U
1375d91483a6Sfdy
1376d91483a6Sfdy        csBundle(i * 2 + 1).srcType(0) := srcType0
1377d91483a6Sfdy        csBundle(i * 2 + 1).srcType(1) := SrcType.vp
1378d91483a6Sfdy        csBundle(i * 2 + 1).lsrc(0) := (VECTOR_TMP_REG_LMUL + i - 1).U
1379d91483a6Sfdy        csBundle(i * 2 + 1).lsrc(1) := src2
1380d91483a6Sfdy        // csBundle(i).lsrc(2) := dest + i.U  DontCare
1381d91483a6Sfdy        csBundle(i * 2 + 1).ldest := (VECTOR_TMP_REG_LMUL + i).U
1382d91483a6Sfdy        csBundle(i * 2 + 1).uopIdx := (i * 2 + 1).U
1383d91483a6Sfdy      }
1384d91483a6Sfdy    }
1385d91483a6Sfdy
138617ec87f2SXuan Hu    is(UopSplitType.VEC_M0X_VFIRST) {
1387d91483a6Sfdy      // LMUL
1388cd2c45feSZiyue Zhang      csBundle(0).rfWen := true.B
1389cd2c45feSZiyue Zhang      csBundle(0).fpWen := false.B
1390cd2c45feSZiyue Zhang      csBundle(0).vecWen := false.B
1391cd2c45feSZiyue Zhang      csBundle(0).ldest := dest
1392d91483a6Sfdy    }
1393189ec863SzhanglyGit    is(UopSplitType.VEC_VWW) {
1394189ec863SzhanglyGit      for (i <- 0 until MAX_VLMUL*2) {
1395189ec863SzhanglyGit        when(i.U < lmul){
1396189ec863SzhanglyGit          csBundle(i).srcType(2) := SrcType.DC
1397189ec863SzhanglyGit          csBundle(i).lsrc(0) := src2 + i.U
1398189ec863SzhanglyGit          csBundle(i).lsrc(1) := src2 + i.U
1399189ec863SzhanglyGit          // csBundle(i).lsrc(2) := dest + (2 * i).U
1400189ec863SzhanglyGit          csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
1401189ec863SzhanglyGit          csBundle(i).uopIdx :=  i.U
1402189ec863SzhanglyGit        } otherwise {
1403189ec863SzhanglyGit          csBundle(i).srcType(2) := SrcType.DC
1404189ec863SzhanglyGit          csBundle(i).lsrc(0) := VECTOR_TMP_REG_LMUL.U + Cat((i.U-lmul),0.U(1.W)) + 1.U
1405189ec863SzhanglyGit          csBundle(i).lsrc(1) := VECTOR_TMP_REG_LMUL.U + Cat((i.U-lmul),0.U(1.W))
1406189ec863SzhanglyGit          // csBundle(i).lsrc(2) := dest + (2 * i).U
1407189ec863SzhanglyGit          csBundle(i).ldest := (VECTOR_TMP_REG_LMUL + i).U
1408189ec863SzhanglyGit          csBundle(i).uopIdx := i.U
1409189ec863SzhanglyGit        }
1410189ec863SzhanglyGit        csBundle(numOfUop-1.U).srcType(2) := SrcType.vp
1411189ec863SzhanglyGit        csBundle(numOfUop-1.U).lsrc(0) := src1
1412189ec863SzhanglyGit        csBundle(numOfUop-1.U).lsrc(2) := dest
1413189ec863SzhanglyGit        csBundle(numOfUop-1.U).ldest := dest
1414189ec863SzhanglyGit      }
1415189ec863SzhanglyGit    }
1416189ec863SzhanglyGit    is(UopSplitType.VEC_RGATHER) {
1417189ec863SzhanglyGit      def genCsBundle_VEC_RGATHER(len:Int): Unit ={
1418189ec863SzhanglyGit        for (i <- 0 until len)
1419189ec863SzhanglyGit          for (j <- 0 until len) {
1420189ec863SzhanglyGit            // csBundle(i * len + j).srcType(0) := SrcType.vp // SrcType.imm
1421189ec863SzhanglyGit            // csBundle(i * len + j).srcType(1) := SrcType.vp
1422189ec863SzhanglyGit            // csBundle(i * len + j).srcType(2) := SrcType.vp
1423189ec863SzhanglyGit            csBundle(i * len + j).lsrc(0) := src1 + i.U
1424189ec863SzhanglyGit            csBundle(i * len + j).lsrc(1) := src2 + j.U
1425189ec863SzhanglyGit            val vd_old = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j - 1).U
1426189ec863SzhanglyGit            csBundle(i * len + j).lsrc(2) := vd_old
1427189ec863SzhanglyGit            val vd = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j).U
1428189ec863SzhanglyGit            csBundle(i * len + j).ldest := vd
1429189ec863SzhanglyGit            csBundle(i * len + j).uopIdx := (i * len + j).U
1430189ec863SzhanglyGit          }
1431189ec863SzhanglyGit      }
1432aaa08c5aSxiaofeibao-xjtu      switch(vlmulReg) {
1433189ec863SzhanglyGit        is("b001".U ){
1434189ec863SzhanglyGit          genCsBundle_VEC_RGATHER(2)
1435189ec863SzhanglyGit        }
1436189ec863SzhanglyGit        is("b010".U ){
1437189ec863SzhanglyGit          genCsBundle_VEC_RGATHER(4)
1438189ec863SzhanglyGit        }
1439189ec863SzhanglyGit        is("b011".U ){
1440189ec863SzhanglyGit          genCsBundle_VEC_RGATHER(8)
1441189ec863SzhanglyGit        }
1442189ec863SzhanglyGit      }
1443189ec863SzhanglyGit    }
1444189ec863SzhanglyGit    is(UopSplitType.VEC_RGATHER_VX) {
1445189ec863SzhanglyGit      def genCsBundle_RGATHER_VX(len:Int): Unit ={
1446189ec863SzhanglyGit        for (i <- 0 until len)
1447189ec863SzhanglyGit          for (j <- 0 until len) {
1448fc85f18fSZiyue Zhang            csBundle(i * len + j + 1).srcType(0) := SrcType.vp
1449189ec863SzhanglyGit            // csBundle(i * len + j + 1).srcType(1) := SrcType.vp
1450189ec863SzhanglyGit            // csBundle(i * len + j + 1).srcType(2) := SrcType.vp
1451fc85f18fSZiyue Zhang            csBundle(i * len + j + 1).lsrc(0) := VECTOR_TMP_REG_LMUL.U
1452189ec863SzhanglyGit            csBundle(i * len + j + 1).lsrc(1) := src2 + j.U
1453fc85f18fSZiyue Zhang            val vd_old = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j).U
1454189ec863SzhanglyGit            csBundle(i * len + j + 1).lsrc(2) := vd_old
1455fc85f18fSZiyue Zhang            val vd = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j + 1).U
1456189ec863SzhanglyGit            csBundle(i * len + j + 1).ldest := vd
1457189ec863SzhanglyGit            csBundle(i * len + j + 1).uopIdx := (i * len + j).U
1458189ec863SzhanglyGit          }
1459189ec863SzhanglyGit      }
1460d6059658SZiyue Zhang      // i to vector move
1461189ec863SzhanglyGit      csBundle(0).srcType(0) := SrcType.reg
1462189ec863SzhanglyGit      csBundle(0).srcType(1) := SrcType.imm
1463*b50f8edeSsinsanction      csBundle(0).srcType(2) := SrcType.imm
1464189ec863SzhanglyGit      csBundle(0).lsrc(1) := 0.U
1465fc85f18fSZiyue Zhang      csBundle(0).ldest := VECTOR_TMP_REG_LMUL.U
1466fc85f18fSZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1467b1712600SZiyue Zhang      csBundle(0).fuOpType := Cat(Mux(src1IsImm, IF2VectorType.imm2Vec(2, 0), IF2VectorType.i2Vec(2, 0)), vsewReg)
146893a5bfb8SZiyue Zhang      csBundle(0).rfWen := false.B
146993a5bfb8SZiyue Zhang      csBundle(0).fpWen := false.B
1470fc85f18fSZiyue Zhang      csBundle(0).vecWen := true.B
1471189ec863SzhanglyGit      genCsBundle_RGATHER_VX(1)
1472783e318eSsinceforYy      switch(vlmulReg) {
1473189ec863SzhanglyGit        is("b001".U ){
1474189ec863SzhanglyGit          genCsBundle_RGATHER_VX(2)
1475189ec863SzhanglyGit        }
1476189ec863SzhanglyGit        is("b010".U ){
1477189ec863SzhanglyGit          genCsBundle_RGATHER_VX(4)
1478189ec863SzhanglyGit        }
1479189ec863SzhanglyGit        is("b011".U ){
1480189ec863SzhanglyGit          genCsBundle_RGATHER_VX(8)
1481189ec863SzhanglyGit        }
1482189ec863SzhanglyGit      }
1483189ec863SzhanglyGit    }
1484189ec863SzhanglyGit    is(UopSplitType.VEC_RGATHEREI16) {
1485189ec863SzhanglyGit      def genCsBundle_VEC_RGATHEREI16_SEW8(len:Int): Unit ={
1486189ec863SzhanglyGit        for (i <- 0 until len)
1487189ec863SzhanglyGit          for (j <- 0 until len) {
1488189ec863SzhanglyGit            val vd_old0 = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j*2-1).U
1489189ec863SzhanglyGit            val vd0 = (VECTOR_TMP_REG_LMUL + j*2 ).U
1490189ec863SzhanglyGit            csBundle((i * len + j)*2+0).lsrc(0) := src1 + (i*2+0).U
1491189ec863SzhanglyGit            csBundle((i * len + j)*2+0).lsrc(1) := src2 + j.U
1492189ec863SzhanglyGit            csBundle((i * len + j)*2+0).lsrc(2) := vd_old0
1493189ec863SzhanglyGit            csBundle((i * len + j)*2+0).ldest := vd0
1494189ec863SzhanglyGit            csBundle((i * len + j)*2+0).uopIdx := ((i * len + j)*2+0).U
1495189ec863SzhanglyGit            val vd_old1 = (VECTOR_TMP_REG_LMUL + j*2).U
1496189ec863SzhanglyGit            val vd1 = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j*2+1 ).U
1497189ec863SzhanglyGit            csBundle((i * len + j)*2+1).lsrc(0) := src1 + (i*2+1).U
1498189ec863SzhanglyGit            csBundle((i * len + j)*2+1).lsrc(1) := src2 + j.U
1499189ec863SzhanglyGit            csBundle((i * len + j)*2+1).lsrc(2) := vd_old1
1500189ec863SzhanglyGit            csBundle((i * len + j)*2+1).ldest := vd1
1501189ec863SzhanglyGit            csBundle((i * len + j)*2+1).uopIdx := ((i * len + j)*2+1).U
1502189ec863SzhanglyGit          }
1503189ec863SzhanglyGit      }
1504189ec863SzhanglyGit      def genCsBundle_VEC_RGATHEREI16(len:Int): Unit ={
1505189ec863SzhanglyGit        for (i <- 0 until len)
1506189ec863SzhanglyGit          for (j <- 0 until len) {
1507189ec863SzhanglyGit            val vd_old = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j-1).U
1508189ec863SzhanglyGit            val vd = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j).U
1509189ec863SzhanglyGit            csBundle(i * len + j).lsrc(0) := src1 + i.U
1510189ec863SzhanglyGit            csBundle(i * len + j).lsrc(1) := src2 + j.U
1511189ec863SzhanglyGit            csBundle(i * len + j).lsrc(2) := vd_old
1512189ec863SzhanglyGit            csBundle(i * len + j).ldest := vd
1513189ec863SzhanglyGit            csBundle(i * len + j).uopIdx := (i * len + j).U
1514189ec863SzhanglyGit          }
1515189ec863SzhanglyGit      }
151693a5bfb8SZiyue Zhang      def genCsBundle_VEC_RGATHEREI16_SEW32(len:Int): Unit ={
151793a5bfb8SZiyue Zhang        for (i <- 0 until len)
151893a5bfb8SZiyue Zhang          for (j <- 0 until len) {
151993a5bfb8SZiyue Zhang            val vd_old = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j-1).U
152093a5bfb8SZiyue Zhang            val vd = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j).U
152193a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(0) := src1 + (i / 2).U
152293a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(1) := src2 + j.U
152393a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(2) := vd_old
152493a5bfb8SZiyue Zhang            csBundle(i * len + j).ldest := vd
152593a5bfb8SZiyue Zhang            csBundle(i * len + j).uopIdx := (i * len + j).U
152693a5bfb8SZiyue Zhang          }
152793a5bfb8SZiyue Zhang      }
152893a5bfb8SZiyue Zhang      def genCsBundle_VEC_RGATHEREI16_SEW64(len:Int): Unit ={
152993a5bfb8SZiyue Zhang        for (i <- 0 until len)
153093a5bfb8SZiyue Zhang          for (j <- 0 until len) {
153193a5bfb8SZiyue Zhang            val vd_old = if(j==0) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j-1).U
153293a5bfb8SZiyue Zhang            val vd = if(j==len-1) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j).U
153393a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(0) := src1 + (i / 4).U
153493a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(1) := src2 + j.U
153593a5bfb8SZiyue Zhang            csBundle(i * len + j).lsrc(2) := vd_old
153693a5bfb8SZiyue Zhang            csBundle(i * len + j).ldest := vd
153793a5bfb8SZiyue Zhang            csBundle(i * len + j).uopIdx := (i * len + j).U
153893a5bfb8SZiyue Zhang          }
153993a5bfb8SZiyue Zhang      }
1540aaa08c5aSxiaofeibao-xjtu      when(!vsewReg.orR){
1541189ec863SzhanglyGit        genCsBundle_VEC_RGATHEREI16_SEW8(1)
154293a5bfb8SZiyue Zhang      }.elsewhen(vsewReg === VSew.e32){
154393a5bfb8SZiyue Zhang        genCsBundle_VEC_RGATHEREI16_SEW32(1)
154493a5bfb8SZiyue Zhang      }.elsewhen(vsewReg === VSew.e64){
154593a5bfb8SZiyue Zhang        genCsBundle_VEC_RGATHEREI16_SEW64(1)
1546189ec863SzhanglyGit      }.otherwise{
1547189ec863SzhanglyGit        genCsBundle_VEC_RGATHEREI16(1)
1548189ec863SzhanglyGit      }
154993a5bfb8SZiyue Zhang      switch(vlmulReg) {
1550189ec863SzhanglyGit        is("b001".U) {
1551aaa08c5aSxiaofeibao-xjtu          when(!vsewReg.orR) {
1552189ec863SzhanglyGit            genCsBundle_VEC_RGATHEREI16_SEW8(2)
155393a5bfb8SZiyue Zhang          }.elsewhen(vsewReg === VSew.e32){
155493a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW32(2)
155593a5bfb8SZiyue Zhang          }.elsewhen(vsewReg === VSew.e64){
155693a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW64(2)
1557189ec863SzhanglyGit          }.otherwise{
1558189ec863SzhanglyGit            genCsBundle_VEC_RGATHEREI16(2)
1559189ec863SzhanglyGit          }
1560189ec863SzhanglyGit        }
1561189ec863SzhanglyGit        is("b010".U) {
1562aaa08c5aSxiaofeibao-xjtu          when(!vsewReg.orR) {
1563189ec863SzhanglyGit            genCsBundle_VEC_RGATHEREI16_SEW8(4)
156493a5bfb8SZiyue Zhang          }.elsewhen(vsewReg === VSew.e32){
156593a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW32(4)
156693a5bfb8SZiyue Zhang          }.elsewhen(vsewReg === VSew.e64){
156793a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW64(4)
1568189ec863SzhanglyGit          }.otherwise{
1569189ec863SzhanglyGit            genCsBundle_VEC_RGATHEREI16(4)
1570189ec863SzhanglyGit          }
1571189ec863SzhanglyGit        }
1572189ec863SzhanglyGit        is("b011".U) {
157393a5bfb8SZiyue Zhang          when(vsewReg === VSew.e32){
157493a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW32(8)
157593a5bfb8SZiyue Zhang          }.elsewhen(vsewReg === VSew.e64){
157693a5bfb8SZiyue Zhang            genCsBundle_VEC_RGATHEREI16_SEW64(8)
157793a5bfb8SZiyue Zhang          }.otherwise{
1578189ec863SzhanglyGit            genCsBundle_VEC_RGATHEREI16(8)
1579189ec863SzhanglyGit          }
1580189ec863SzhanglyGit        }
1581189ec863SzhanglyGit      }
158293a5bfb8SZiyue Zhang    }
1583189ec863SzhanglyGit    is(UopSplitType.VEC_COMPRESS) {
1584189ec863SzhanglyGit      def genCsBundle_VEC_COMPRESS(len:Int): Unit = {
1585189ec863SzhanglyGit        for (i <- 0 until len) {
1586189ec863SzhanglyGit          val jlen = if (i == len-1) i+1 else i+2
1587189ec863SzhanglyGit          for (j <- 0 until jlen) {
1588189ec863SzhanglyGit            val vd_old = if(i==j) (dest + i.U) else (VECTOR_TMP_REG_LMUL + j + 1).U
1589189ec863SzhanglyGit            val vd = if(i==len-1) (dest + j.U) else {
1590189ec863SzhanglyGit              if (j == i+1) VECTOR_TMP_REG_LMUL.U else (VECTOR_TMP_REG_LMUL + j + 1).U
1591189ec863SzhanglyGit            }
15925da52072SsinceforYy            val src13Type = if (j == i+1) DontCare else SrcType.vp
15935da52072SsinceforYy            csBundle(i*(i+3)/2 + j).srcType(0) := src13Type
15945da52072SsinceforYy            csBundle(i*(i+3)/2 + j).srcType(1) := SrcType.vp
15955da52072SsinceforYy            csBundle(i*(i+3)/2 + j).srcType(2) := src13Type
15965da52072SsinceforYy            csBundle(i*(i+3)/2 + j).srcType(3) := SrcType.vp
1597189ec863SzhanglyGit            csBundle(i*(i+3)/2 + j).lsrc(0) := src1
1598189ec863SzhanglyGit            csBundle(i*(i+3)/2 + j).lsrc(1) := src2 + i.U
1599189ec863SzhanglyGit            csBundle(i*(i+3)/2 + j).lsrc(2) := vd_old
16005da52072SsinceforYy            csBundle(i*(i+3)/2 + j).lsrc(3) := VECTOR_TMP_REG_LMUL.U
1601189ec863SzhanglyGit            csBundle(i*(i+3)/2 + j).ldest := vd
1602189ec863SzhanglyGit            csBundle(i*(i+3)/2 + j).uopIdx := (i*(i+3)/2 + j).U
1603189ec863SzhanglyGit          }
1604189ec863SzhanglyGit        }
1605189ec863SzhanglyGit      }
1606aaa08c5aSxiaofeibao-xjtu      switch(vlmulReg) {
1607189ec863SzhanglyGit        is("b001".U ){
1608189ec863SzhanglyGit          genCsBundle_VEC_COMPRESS(2)
1609189ec863SzhanglyGit        }
1610189ec863SzhanglyGit        is("b010".U ){
1611189ec863SzhanglyGit          genCsBundle_VEC_COMPRESS(4)
1612189ec863SzhanglyGit        }
1613189ec863SzhanglyGit        is("b011".U ){
1614189ec863SzhanglyGit          genCsBundle_VEC_COMPRESS(8)
1615189ec863SzhanglyGit        }
1616189ec863SzhanglyGit      }
1617189ec863SzhanglyGit    }
16180a34fc22SZiyue Zhang    is(UopSplitType.VEC_MVNR) {
16190a34fc22SZiyue Zhang      for (i <- 0 until MAX_VLMUL) {
16200a34fc22SZiyue Zhang        csBundle(i).lsrc(0) := src1 + i.U
16210a34fc22SZiyue Zhang        csBundle(i).lsrc(1) := src2 + i.U
16220a34fc22SZiyue Zhang        csBundle(i).lsrc(2) := dest + i.U
16230a34fc22SZiyue Zhang        csBundle(i).ldest := dest + i.U
16240a34fc22SZiyue Zhang        csBundle(i).uopIdx := i.U
16250a34fc22SZiyue Zhang      }
16260a34fc22SZiyue Zhang    }
1627c4501a6fSZiyue-Zhang    is(UopSplitType.VEC_US_LDST) {
16284ee69032SzhanglyGit      /*
16294ee69032SzhanglyGit      FMV.D.X
16304ee69032SzhanglyGit       */
16314ee69032SzhanglyGit      csBundle(0).srcType(0) := SrcType.reg
16324ee69032SzhanglyGit      csBundle(0).srcType(1) := SrcType.imm
16334ee69032SzhanglyGit      csBundle(0).lsrc(1) := 0.U
16344ee69032SzhanglyGit      csBundle(0).ldest := FP_TMP_REG_MV.U
1635964d9a87SZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1636964d9a87SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.i2Vec(2, 0), e64)
16374ee69032SzhanglyGit      csBundle(0).rfWen := false.B
16384ee69032SzhanglyGit      csBundle(0).fpWen := true.B
16394ee69032SzhanglyGit      csBundle(0).vecWen := false.B
164031c51290Szhanglinjuan      csBundle(0).vlsInstr := true.B
16414ee69032SzhanglyGit      //LMUL
16424ee69032SzhanglyGit      for (i <- 0 until MAX_VLMUL) {
16434ee69032SzhanglyGit        csBundle(i + 1).srcType(0) := SrcType.fp
16444ee69032SzhanglyGit        csBundle(i + 1).lsrc(0) := FP_TMP_REG_MV.U
16454dfab1f2Szhanglinjuan        csBundle(i + 1).lsrc(2) := dest + i.U // old vd
16464ee69032SzhanglyGit        csBundle(i + 1).ldest := dest + i.U
16474ee69032SzhanglyGit        csBundle(i + 1).uopIdx := i.U
164831c51290Szhanglinjuan        csBundle(i + 1).vlsInstr := true.B
16494ee69032SzhanglyGit      }
16504aa00286SXuan Hu      csBundle.head.waitForward := isUsSegment
16514aa00286SXuan Hu      csBundle(numOfUop - 1.U).blockBackward := isUsSegment
16524ee69032SzhanglyGit    }
1653c4501a6fSZiyue-Zhang    is(UopSplitType.VEC_S_LDST) {
1654c4501a6fSZiyue-Zhang      /*
1655c4501a6fSZiyue-Zhang      FMV.D.X
1656c4501a6fSZiyue-Zhang       */
1657c4501a6fSZiyue-Zhang      csBundle(0).srcType(0) := SrcType.reg
1658c4501a6fSZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
1659c4501a6fSZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
1660c4501a6fSZiyue-Zhang      csBundle(0).ldest := FP_TMP_REG_MV.U
1661964d9a87SZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1662964d9a87SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.i2Vec(2, 0), e64)
1663c4501a6fSZiyue-Zhang      csBundle(0).rfWen := false.B
1664c4501a6fSZiyue-Zhang      csBundle(0).fpWen := true.B
1665c4501a6fSZiyue-Zhang      csBundle(0).vecWen := false.B
166631c51290Szhanglinjuan      csBundle(0).vlsInstr := true.B
1667c4501a6fSZiyue-Zhang
16686a926cf7SXuan Hu      csBundle(1).srcType(0) := SrcType.reg
16696a926cf7SXuan Hu      csBundle(1).srcType(1) := SrcType.imm
1670e25c13faSXuan Hu      csBundle(1).lsrc(0) := latchedInst.lsrc(1)
16716a926cf7SXuan Hu      csBundle(1).lsrc(1) := 0.U
1672c4501a6fSZiyue-Zhang      csBundle(1).ldest := VECTOR_TMP_REG_LMUL.U
1673964d9a87SZiyue Zhang      csBundle(1).fuType := FuType.i2v.U
1674964d9a87SZiyue Zhang      csBundle(1).fuOpType := Cat(IF2VectorType.i2Vec(2, 0), e64)
1675c4501a6fSZiyue-Zhang      csBundle(1).rfWen := false.B
1676c4501a6fSZiyue-Zhang      csBundle(1).fpWen := true.B
1677c4501a6fSZiyue-Zhang      csBundle(1).vecWen := false.B
167831c51290Szhanglinjuan      csBundle(1).vlsInstr := true.B
1679c4501a6fSZiyue-Zhang
1680c4501a6fSZiyue-Zhang      //LMUL
1681c4501a6fSZiyue-Zhang      for (i <- 0 until MAX_VLMUL) {
1682c4501a6fSZiyue-Zhang        csBundle(i + 2).srcType(0) := SrcType.fp
16836a926cf7SXuan Hu        csBundle(i + 2).srcType(1) := SrcType.fp
1684c4501a6fSZiyue-Zhang        csBundle(i + 2).lsrc(0) := FP_TMP_REG_MV.U
1685c4501a6fSZiyue-Zhang        csBundle(i + 2).lsrc(1) := VECTOR_TMP_REG_LMUL.U
16864dfab1f2Szhanglinjuan        csBundle(i + 2).lsrc(2) := dest + i.U // old vd
1687c4501a6fSZiyue-Zhang        csBundle(i + 2).ldest := dest + i.U
1688c4501a6fSZiyue-Zhang        csBundle(i + 2).uopIdx := i.U
168931c51290Szhanglinjuan        csBundle(i + 2).vlsInstr := true.B
1690c4501a6fSZiyue-Zhang      }
16914aa00286SXuan Hu      csBundle.head.waitForward := isSdSegment
16924aa00286SXuan Hu      csBundle(numOfUop - 1.U).blockBackward := isSdSegment
1693c4501a6fSZiyue-Zhang    }
1694c4501a6fSZiyue-Zhang    is(UopSplitType.VEC_I_LDST) {
16952de01baaSZiyue Zhang      def genCsBundle_SEGMENT_INDEXED_LOADSTORE(lmul:Int, nf:Int): Unit ={
169655f7bedaSZiyue Zhang        for (i <- 0 until MAX_VLMUL) {
16972de01baaSZiyue Zhang          val vecWen = if (i < lmul * nf) true.B else false.B
16982de01baaSZiyue Zhang          val src2Type = if (i < lmul * nf) SrcType.vp else SrcType.no
16992de01baaSZiyue Zhang          csBundle(i + 1).srcType(0) := SrcType.fp
17002de01baaSZiyue Zhang          csBundle(i + 1).lsrc(0) := FP_TMP_REG_MV.U
17012de01baaSZiyue Zhang          csBundle(i + 1).srcType(1) := SrcType.no
170255f7bedaSZiyue Zhang          csBundle(i + 1).lsrc(1) := src2 + i.U
17032de01baaSZiyue Zhang          csBundle(i + 1).srcType(2) := src2Type
17042de01baaSZiyue Zhang          csBundle(i + 1).lsrc(2) := dest + i.U
170555f7bedaSZiyue Zhang          csBundle(i + 1).ldest := dest + i.U
17062de01baaSZiyue Zhang          csBundle(i + 1).rfWen := false.B
17072de01baaSZiyue Zhang          csBundle(i + 1).fpWen := false.B
17082de01baaSZiyue Zhang          csBundle(i + 1).vecWen := vecWen
170955f7bedaSZiyue Zhang          csBundle(i + 1).uopIdx := i.U
171055f7bedaSZiyue Zhang          csBundle(i + 1).vlsInstr := true.B
171155f7bedaSZiyue Zhang        }
171255f7bedaSZiyue Zhang      }
17132de01baaSZiyue Zhang      def genCsBundle_SEGMENT_INDEXED_LOADSTORE_SRC1(emul:Int): Unit ={
17142de01baaSZiyue Zhang        for (i <- 0 until MAX_VLMUL) {
17152de01baaSZiyue Zhang          val src1Type = if (i < emul) SrcType.vp else SrcType.no
17162de01baaSZiyue Zhang          csBundle(i + 1).srcType(1) := src1Type
17172de01baaSZiyue Zhang          csBundle(i + 1).lsrc(1) := src2 + i.U
17182de01baaSZiyue Zhang        }
17192de01baaSZiyue Zhang      }
172055f7bedaSZiyue Zhang
17210cd00663SzhanglyGit      val vlmul = vlmulReg
17220cd00663SzhanglyGit      val vsew = Cat(0.U(1.W), vsewReg)
17230cd00663SzhanglyGit      val veew = Cat(0.U(1.W), width)
1724c4501a6fSZiyue-Zhang      val vemul: UInt = veew.asUInt + 1.U + vlmul.asUInt + ~vsew.asUInt
172519d66d7fSXuan Hu      val simple_lmul = MuxLookup(vlmul, 0.U(2.W))(Array(
1726c4501a6fSZiyue-Zhang        "b001".U -> 1.U,
1727c4501a6fSZiyue-Zhang        "b010".U -> 2.U,
1728c4501a6fSZiyue-Zhang        "b011".U -> 3.U
1729c4501a6fSZiyue-Zhang      ))
173019d66d7fSXuan Hu      val simple_emul = MuxLookup(vemul, 0.U(2.W))(Array(
1731c4501a6fSZiyue-Zhang        "b001".U -> 1.U,
1732c4501a6fSZiyue-Zhang        "b010".U -> 2.U,
1733c4501a6fSZiyue-Zhang        "b011".U -> 3.U
1734c4501a6fSZiyue-Zhang      ))
1735c4501a6fSZiyue-Zhang      csBundle(0).srcType(0) := SrcType.reg
1736c4501a6fSZiyue-Zhang      csBundle(0).srcType(1) := SrcType.imm
1737c4501a6fSZiyue-Zhang      csBundle(0).lsrc(1) := 0.U
1738c4501a6fSZiyue-Zhang      csBundle(0).ldest := FP_TMP_REG_MV.U
1739964d9a87SZiyue Zhang      csBundle(0).fuType := FuType.i2v.U
1740964d9a87SZiyue Zhang      csBundle(0).fuOpType := Cat(IF2VectorType.i2Vec(2, 0), e64)
1741c4501a6fSZiyue-Zhang      csBundle(0).rfWen := false.B
1742c4501a6fSZiyue-Zhang      csBundle(0).fpWen := true.B
1743c4501a6fSZiyue-Zhang      csBundle(0).vecWen := false.B
174431c51290Szhanglinjuan      csBundle(0).vlsInstr := true.B
1745c4501a6fSZiyue-Zhang
1746c4501a6fSZiyue-Zhang      //LMUL
174755f7bedaSZiyue Zhang      when(nf === 0.U) {
174855f7bedaSZiyue Zhang        for (i <- 0 until MAX_VLMUL) {
174955f7bedaSZiyue Zhang          indexedLSRegOffset(i).src := Cat(simple_emul, simple_lmul)
1750c4501a6fSZiyue-Zhang          val offsetVs2 = indexedLSRegOffset(i).outOffsetVs2
1751c4501a6fSZiyue-Zhang          val offsetVd = indexedLSRegOffset(i).outOffsetVd
1752c4501a6fSZiyue-Zhang          csBundle(i + 1).srcType(0) := SrcType.fp
1753c4501a6fSZiyue-Zhang          csBundle(i + 1).lsrc(0) := FP_TMP_REG_MV.U
1754c4501a6fSZiyue-Zhang          csBundle(i + 1).lsrc(1) := Mux1H(UIntToOH(offsetVs2, MAX_VLMUL), (0 until MAX_VLMUL).map(j => src2 + j.U))
1755792b1339SAnzooooo          csBundle(i + 1).srcType(2) := SrcType.vp
175655f7bedaSZiyue Zhang          // lsrc2 is old vd
1757792b1339SAnzooooo          csBundle(i + 1).lsrc(2) := Mux1H(UIntToOH(offsetVd, MAX_VLMUL), (0 until MAX_VLMUL).map(j => dest + j.U))
1758c4501a6fSZiyue-Zhang          csBundle(i + 1).ldest := Mux1H(UIntToOH(offsetVd, MAX_VLMUL), (0 until MAX_VLMUL).map(j => dest + j.U))
1759c4501a6fSZiyue-Zhang          csBundle(i + 1).uopIdx := i.U
176031c51290Szhanglinjuan          csBundle(i + 1).vlsInstr := true.B
1761c4501a6fSZiyue-Zhang        }
176255f7bedaSZiyue Zhang      }.otherwise{
176355f7bedaSZiyue Zhang        // nf > 1, is segment indexed load/store
17642de01baaSZiyue Zhang        // gen src0, vd
17652de01baaSZiyue Zhang        switch(simple_lmul) {
17662de01baaSZiyue Zhang          is(0.U) {
17672de01baaSZiyue Zhang            switch(nf) {
17682de01baaSZiyue Zhang              is(1.U) {
17692de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 2)
177055f7bedaSZiyue Zhang              }
17712de01baaSZiyue Zhang              is(2.U) {
17722de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 3)
177355f7bedaSZiyue Zhang              }
17742de01baaSZiyue Zhang              is(3.U) {
17752de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 4)
17762de01baaSZiyue Zhang              }
17772de01baaSZiyue Zhang              is(4.U) {
17782de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 5)
17792de01baaSZiyue Zhang              }
17802de01baaSZiyue Zhang              is(5.U) {
17812de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 6)
17822de01baaSZiyue Zhang              }
17832de01baaSZiyue Zhang              is(6.U) {
17842de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 7)
17852de01baaSZiyue Zhang              }
17862de01baaSZiyue Zhang              is(7.U) {
17872de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(1, 8)
17882de01baaSZiyue Zhang              }
17892de01baaSZiyue Zhang            }
17902de01baaSZiyue Zhang          }
17912de01baaSZiyue Zhang          is(1.U) {
17922de01baaSZiyue Zhang            switch(nf) {
17932de01baaSZiyue Zhang              is(1.U) {
17942de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(2, 2)
17952de01baaSZiyue Zhang              }
17962de01baaSZiyue Zhang              is(2.U) {
17972de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(2, 3)
17982de01baaSZiyue Zhang              }
17992de01baaSZiyue Zhang              is(3.U) {
18002de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(2, 4)
18012de01baaSZiyue Zhang              }
18022de01baaSZiyue Zhang            }
18032de01baaSZiyue Zhang          }
18042de01baaSZiyue Zhang          is(2.U) {
18052de01baaSZiyue Zhang            switch(nf) {
18062de01baaSZiyue Zhang              is(1.U) {
18072de01baaSZiyue Zhang                genCsBundle_SEGMENT_INDEXED_LOADSTORE(4, 2)
18082de01baaSZiyue Zhang              }
18092de01baaSZiyue Zhang            }
18102de01baaSZiyue Zhang          }
18112de01baaSZiyue Zhang        }
18122de01baaSZiyue Zhang
18132de01baaSZiyue Zhang        // gen src1
18142de01baaSZiyue Zhang        switch(simple_emul) {
18152de01baaSZiyue Zhang          is(0.U) {
18162de01baaSZiyue Zhang            genCsBundle_SEGMENT_INDEXED_LOADSTORE_SRC1(1)
18172de01baaSZiyue Zhang          }
18182de01baaSZiyue Zhang          is(1.U) {
18192de01baaSZiyue Zhang            genCsBundle_SEGMENT_INDEXED_LOADSTORE_SRC1(2)
18202de01baaSZiyue Zhang          }
18212de01baaSZiyue Zhang          is(2.U) {
18222de01baaSZiyue Zhang            genCsBundle_SEGMENT_INDEXED_LOADSTORE_SRC1(4)
18232de01baaSZiyue Zhang          }
18242de01baaSZiyue Zhang          is(3.U) {
18252de01baaSZiyue Zhang            genCsBundle_SEGMENT_INDEXED_LOADSTORE_SRC1(8)
182655f7bedaSZiyue Zhang          }
182755f7bedaSZiyue Zhang        }
18287635b2a1SZiyue Zhang
18297635b2a1SZiyue Zhang        // when is vstore instructions, not set vecwen
18307635b2a1SZiyue Zhang        when(isVstore) {
18317635b2a1SZiyue Zhang          for (i <- 0 until MAX_VLMUL) {
18327635b2a1SZiyue Zhang            csBundle(i + 1).vecWen := false.B
18337635b2a1SZiyue Zhang          }
18347635b2a1SZiyue Zhang        }
183555f7bedaSZiyue Zhang      }
18364aa00286SXuan Hu      csBundle.head.waitForward := isIxSegment
18374aa00286SXuan Hu      csBundle(numOfUop - 1.U).blockBackward := isIxSegment
1838c4501a6fSZiyue-Zhang    }
1839d91483a6Sfdy  }
1840d91483a6Sfdy
1841d91483a6Sfdy  //readyFromRename Counter
1842e25c13faSXuan Hu  val readyCounter = PriorityMuxDefault(outReadys.map(x => !x).zip((0 until RenameWidth).map(_.U)), RenameWidth.U)
1843e25c13faSXuan Hu
1844e25c13faSXuan Hu  // The left uops of the complex inst in ComplexDecoder can be send out this cycle
1845e25c13faSXuan Hu  val thisAllOut = uopRes <= readyCounter
1846d91483a6Sfdy
1847189ec863SzhanglyGit  switch(state) {
1848e25c13faSXuan Hu    is(s_idle) {
1849e25c13faSXuan Hu      when (inValid) {
1850e25c13faSXuan Hu        stateNext := s_active
1851e25c13faSXuan Hu        uopResNext := inUopInfo.numOfUop
1852d91483a6Sfdy      }
1853e25c13faSXuan Hu    }
1854e25c13faSXuan Hu    is(s_active) {
1855e25c13faSXuan Hu      when (thisAllOut) {
1856e25c13faSXuan Hu        when (inValid) {
1857e25c13faSXuan Hu          stateNext := s_active
1858e25c13faSXuan Hu          uopResNext := inUopInfo.numOfUop
1859e25c13faSXuan Hu        }.otherwise {
1860e25c13faSXuan Hu          stateNext := s_idle
1861e25c13faSXuan Hu          uopResNext := 0.U
1862e25c13faSXuan Hu        }
1863e25c13faSXuan Hu      }.otherwise {
1864e25c13faSXuan Hu        stateNext := s_active
1865e25c13faSXuan Hu        uopResNext := uopRes - readyCounter
1866e25c13faSXuan Hu      }
1867d91483a6Sfdy    }
1868d91483a6Sfdy  }
1869d91483a6Sfdy
1870e25c13faSXuan Hu  state := Mux(io.redirect, s_idle, stateNext)
1871e25c13faSXuan Hu  uopRes := Mux(io.redirect, 0.U, uopResNext)
1872189ec863SzhanglyGit
1873e25c13faSXuan Hu  val complexNum = Mux(uopRes > readyCounter, readyCounter, uopRes)
1874d91483a6Sfdy
1875d91483a6Sfdy  for(i <- 0 until RenameWidth) {
1876e25c13faSXuan Hu    outValids(i) := complexNum > i.U
1877e25c13faSXuan Hu    outDecodedInsts(i) := Mux((i.U + numOfUop - uopRes) < maxUopSize.U, csBundle(i.U + numOfUop - uopRes), csBundle(maxUopSize - 1))
1878d91483a6Sfdy  }
1879d91483a6Sfdy
1880e25c13faSXuan Hu  outComplexNum := Mux(state === s_active, complexNum, 0.U)
1881e25c13faSXuan Hu  inReady := state === s_idle || state === s_active && thisAllOut
1882d91483a6Sfdy
1883e25c13faSXuan Hu//  val validSimple = Wire(Vec(DecodeWidth, Bool()))
1884e25c13faSXuan Hu//  validSimple.zip(io.validFromIBuf.zip(io.isComplex)).map{ case (dst, (src1, src2)) => dst := src1 && !src2 }
1885e25c13faSXuan Hu//  val notInf = Wire(Vec(DecodeWidth, Bool()))
1886e25c13faSXuan Hu//  notInf.drop(1).zip(io.validFromIBuf.drop(1).zip(validSimple.drop(1))).map{ case (dst, (src1, src2)) => dst := !src1 || src2 }
1887e25c13faSXuan Hu//  notInf(0) := !io.validFromIBuf(0) || validSimple(0) || (io.isComplex(0) && io.in0pc === io.simple.decodedInst.pc)
1888e25c13faSXuan Hu//  val notInfVec = Wire(Vec(DecodeWidth, Bool()))
1889e25c13faSXuan Hu//  notInfVec.zipWithIndex.map{ case (dst, i) => dst := Cat(notInf.take(i + 1)).andR}
1890e25c13faSXuan Hu//
1891e25c13faSXuan Hu//  complexNum := Mux(io.validFromIBuf(0) && readyCounter.orR ,
1892e25c13faSXuan Hu//    Mux(uopRes0 > readyCounter, readyCounter, uopRes0),
1893e25c13faSXuan Hu//    0.U)
1894e25c13faSXuan Hu//  validToRename.zipWithIndex.foreach{
1895e25c13faSXuan Hu//    case(dst, i) =>
1896e25c13faSXuan Hu//      val validFix = Mux(complexNum.orR, validSimple((i+1).U - complexNum), validSimple(i))
1897e25c13faSXuan Hu//      dst := MuxCase(false.B, Seq(
1898e25c13faSXuan Hu//        (io.validFromIBuf(0) && readyCounter.orR && uopRes0 > readyCounter) -> Mux(readyCounter > i.U, true.B, false.B),
1899e25c13faSXuan Hu//        (io.validFromIBuf(0) && readyCounter.orR && !(uopRes0 > readyCounter)) -> Mux(complexNum > i.U, true.B, validFix && notInfVec(i.U - complexNum) && io.readyFromRename(i)),
1900e25c13faSXuan Hu//      ).toSeq)
1901e25c13faSXuan Hu//  }
1902e25c13faSXuan Hu//
1903e25c13faSXuan Hu//  readyToIBuf.zipWithIndex.foreach {
1904e25c13faSXuan Hu//    case (dst, i) =>
1905e25c13faSXuan Hu//      val readyToIBuf0 = Mux(io.isComplex(0), io.in0pc === io.simple.decodedInst.pc, true.B)
1906e25c13faSXuan Hu//      dst := MuxCase(true.B, Seq(
1907e25c13faSXuan Hu//        (io.validFromIBuf(0) && uopRes0 > readyCounter || !readyCounter.orR) -> false.B,
1908e25c13faSXuan Hu//        (io.validFromIBuf(0) && !(uopRes0 > readyCounter) && readyCounter.orR) -> (if (i==0) readyToIBuf0 else Mux(RenameWidth.U - complexNum >= i.U, notInfVec(i) && validSimple(i) && io.readyFromRename(i), false.B))
1909e25c13faSXuan Hu//      ).toSeq)
1910e25c13faSXuan Hu//  }
1911e25c13faSXuan Hu//
1912e25c13faSXuan Hu//  io.deq.decodedInsts := decodedInsts
1913e25c13faSXuan Hu//  io.deq.complexNum := complexNum
1914e25c13faSXuan Hu//  io.deq.validToRename := validToRename
1915e25c13faSXuan Hu//  io.deq.readyToIBuf := readyToIBuf
1916d91483a6Sfdy}
1917