xref: /XiangShan/src/main/scala/xiangshan/backend/fu/vector/VecPipedFuncUnit.scala (revision 35d005df068392f03f28e9ad6f2d4d3a70c32ed3)
1package xiangshan.backend.fu.vector
2
3import chipsalliance.rocketchip.config.Parameters
4import chisel3._
5import chisel3.util._
6import xiangshan.backend.fu.vector.Bundles.VConfig
7import xiangshan.backend.fu.{FuConfig, FuncUnit, HasPipelineReg}
8import yunsuan.VialuFixType
9
10trait VecFuncUnitAlias { this: FuncUnit =>
11  protected val inCtrl  = io.in.bits.ctrl
12  protected val inData  = io.in.bits.data
13  protected val vecCtrl = inCtrl.vpu.get
14
15  protected val vill    = vecCtrl.vill
16  protected val vma     = vecCtrl.vma
17  protected val vta     = vecCtrl.vta
18  protected val vsew    = vecCtrl.vsew
19  protected val vlmul   = vecCtrl.vlmul
20  protected val vm      = vecCtrl.vm
21  protected val vstart  = vecCtrl.vstart
22
23  protected val frm     = vecCtrl.frm
24  protected val vxrm    = vecCtrl.vxrm
25  protected val vuopIdx = vecCtrl.vuopIdx
26  protected val nf      = vecCtrl.frm
27
28  protected val fuOpType  = inCtrl.fuOpType
29  protected val isNarrow  = vecCtrl.isNarrow
30  protected val isExt     = vecCtrl.isExt
31  protected val isMove    = vecCtrl.isMove
32  protected val isReverse = vecCtrl.isReverse
33
34  // There is no difference between control-dependency or data-dependency for function unit,
35  // but spliting these in ctrl or data bundles is easy to codinpjfg.
36  protected val srcMask    = if(!cfg.maskWakeUp) inCtrl.vpu.get.vmask else inData.getSrcMask
37  protected val srcVConfig = if(!cfg.vconfigWakeUp) inCtrl.vpu.get.vconfig else inData.getSrcVConfig.asTypeOf(new VConfig)
38
39  // swap vs1 and vs2, used by vrsub, etc
40  val needReverse = VialuFixType.needReverse(inCtrl.fuOpType)
41  // vadc.vv, vsbc.vv need this
42  val needClearMask = VialuFixType.needClearMask(inCtrl.fuOpType)
43
44}
45
46class VecPipedFuncUnit(cfg: FuConfig)(implicit p: Parameters) extends FuncUnit(cfg)
47  with HasPipelineReg
48  with VecFuncUnitAlias
49{
50
51  override def latency: Int = cfg.latency.latencyVal.get
52
53}
54