1ad22c988SZiyue Zhangpackage xiangshan.backend.fu.wrapper 2ad22c988SZiyue Zhang 383ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters 4ad22c988SZiyue Zhangimport chisel3._ 5ad22c988SZiyue Zhangimport chisel3.util._ 6*bb2f3f51STang Haojinimport utility.XSError 7ad22c988SZiyue Zhangimport xiangshan.backend.fu.FuConfig 8ad22c988SZiyue Zhangimport xiangshan.backend.fu.vector.Bundles.VSew 9ad22c988SZiyue Zhangimport xiangshan.backend.fu.vector.utils.VecDataSplitModule 10ad22c988SZiyue Zhangimport xiangshan.backend.fu.vector.{Mgu, Utils, VecPipedFuncUnit, VecSrcTypeModule} 11ad22c988SZiyue Zhangimport xiangshan.SrcType 12ad22c988SZiyue Zhangimport yunsuan.encoding.Opcode.VimacOpcode 13ad22c988SZiyue Zhangimport yunsuan.encoding.{VdType, Vs1IntType, Vs2IntType} 14ad22c988SZiyue Zhangimport yunsuan.{OpType, VpermType} 15ad22c988SZiyue Zhangimport yunsuan.vector.perm.Permutation 16ad22c988SZiyue Zhang 17ad22c988SZiyue Zhangclass VPermSrcTypeModule extends VecSrcTypeModule { 18ad22c988SZiyue Zhang private val srcVdType = Wire(new Bundle{ 19ad22c988SZiyue Zhang val srcType2 = UInt(4.W) 20ad22c988SZiyue Zhang val srcType1 = UInt(4.W) 21ad22c988SZiyue Zhang val vdType = UInt(4.W) 22ad22c988SZiyue Zhang }) 23daae8f22SZiyue Zhang srcVdType := VpermType.getSrcVdType(fuOpType, vsew).asTypeOf(srcVdType.cloneType) 24ad22c988SZiyue Zhang 25daae8f22SZiyue Zhang io.out.illegal := false.B 26ad22c988SZiyue Zhang io.out.vs2Type := srcVdType.srcType2 27ad22c988SZiyue Zhang io.out.vs1Type := srcVdType.srcType1 28ad22c988SZiyue Zhang io.out.vdType := srcVdType.vdType 29ad22c988SZiyue Zhang} 30ad22c988SZiyue Zhang 31ad22c988SZiyue Zhangclass VPPU(cfg: FuConfig)(implicit p: Parameters) extends VecPipedFuncUnit(cfg) { 32ad22c988SZiyue Zhang XSError(io.in.valid && io.in.bits.ctrl.fuOpType === VpermType.dummy, "VpermType OpType not supported") 33ad22c988SZiyue Zhang 34ad22c988SZiyue Zhang // params alias 352d12882cSxiaofeibao private val dataWidth = cfg.destDataBits 36ad22c988SZiyue Zhang private val dataWidthOfDataModule = 64 37ad22c988SZiyue Zhang private val numVecModule = dataWidth / dataWidthOfDataModule 38ad22c988SZiyue Zhang private val vppuNeedClearMask = (VpermType.vcompress === io.in.bits.ctrl.fuOpType) && (vuopIdx(log2Up(MaxUopSize)-1,1) === 0.U) 395da52072SsinceforYy private val mask = Mux(vppuNeedClearMask, 0.U, io.in.bits.data.src(3)) 404c4e2cd8SZiyue Zhang private val isVmvnr = VpermType.isVmvnr(io.in.bits.ctrl.fuOpType) 414c4e2cd8SZiyue Zhang private val emul = VpermType.getEmulVmvnr(io.in.bits.ctrl.fuOpType) 42ad22c988SZiyue Zhang // io alias 43ad22c988SZiyue Zhang private val opcode = VpermType.getOpcode(fuOpType) 44ad22c988SZiyue Zhang 45ad22c988SZiyue Zhang // modules 46daae8f22SZiyue Zhang private val typeMod = Module(new VPermSrcTypeModule) 47ad22c988SZiyue Zhang private val vperms = Module(new Permutation) 48ad22c988SZiyue Zhang 49ad22c988SZiyue Zhang /** 50ad22c988SZiyue Zhang * [[typeMod]]'s in connection 51ad22c988SZiyue Zhang */ 52ad22c988SZiyue Zhang typeMod.io.in.fuOpType := fuOpType 53ad22c988SZiyue Zhang typeMod.io.in.vsew := vsew 54ad22c988SZiyue Zhang typeMod.io.in.isReverse := isReverse 55ad22c988SZiyue Zhang typeMod.io.in.isExt := isExt 56ad22c988SZiyue Zhang typeMod.io.in.isDstMask := vecCtrl.isDstMask 57ad22c988SZiyue Zhang typeMod.io.in.isMove := isMove 58ad22c988SZiyue Zhang 59ad22c988SZiyue Zhang /** 60ad22c988SZiyue Zhang * [[vperms]]'s in connection 61ad22c988SZiyue Zhang */ 62ad22c988SZiyue Zhang vperms.io match { 63ad22c988SZiyue Zhang case subIO => 64daae8f22SZiyue Zhang subIO.in.valid := io.in.valid 65ad22c988SZiyue Zhang subIO.in.bits.opcode.op := opcode 66ad22c988SZiyue Zhang subIO.in.bits.info.vm := vm 67ad22c988SZiyue Zhang subIO.in.bits.info.ma := vma 68ad22c988SZiyue Zhang subIO.in.bits.info.ta := vta 694c4e2cd8SZiyue Zhang subIO.in.bits.info.vlmul := Mux(isVmvnr, emul, vlmul) 70ad22c988SZiyue Zhang subIO.in.bits.info.vl := srcVConfig.vl 71ad22c988SZiyue Zhang subIO.in.bits.info.vstart := vstart 72ad22c988SZiyue Zhang subIO.in.bits.info.uopIdx := vuopIdx 73ad22c988SZiyue Zhang subIO.in.bits.info.vxrm := vxrm 74ad22c988SZiyue Zhang subIO.in.bits.srcType(0) := typeMod.io.out.vs2Type 75ad22c988SZiyue Zhang subIO.in.bits.srcType(1) := typeMod.io.out.vs1Type 76ad22c988SZiyue Zhang subIO.in.bits.vdType := typeMod.io.out.vdType 77d6059658SZiyue Zhang subIO.in.bits.vs1 := vs1 78ad22c988SZiyue Zhang subIO.in.bits.vs2 := vs2 79ad22c988SZiyue Zhang subIO.in.bits.old_vd := oldVd 80ad22c988SZiyue Zhang subIO.in.bits.mask := mask 81ad22c988SZiyue Zhang } 82ad22c988SZiyue Zhang 83daae8f22SZiyue Zhang io.out.bits.res.data := vperms.io.out.vd 84ad22c988SZiyue Zhang io.out.bits.res.vxsat.foreach(_ := vperms.io.out.vxsat) 85ad22c988SZiyue Zhang} 86