1package xiangshan.backend.fu.wrapper 2 3import org.chipsalliance.cde.config.Parameters 4import chisel3._ 5import chisel3.util._ 6import utils.XSError 7import xiangshan.backend.fu.FuConfig 8import xiangshan.backend.fu.vector.Bundles.VSew 9import xiangshan.backend.fu.vector.utils.VecDataSplitModule 10import xiangshan.backend.fu.vector.{Mgu, Utils, VecPipedFuncUnit, VecSrcTypeModule} 11import xiangshan.SrcType 12import yunsuan.encoding.Opcode.VimacOpcode 13import yunsuan.encoding.{VdType, Vs1IntType, Vs2IntType} 14import yunsuan.{OpType, VpermType} 15import yunsuan.vector.perm.Permutation 16 17class VPermSrcTypeModule extends VecSrcTypeModule { 18 private val srcVdType = Wire(new Bundle{ 19 val srcType2 = UInt(4.W) 20 val srcType1 = UInt(4.W) 21 val vdType = UInt(4.W) 22 }) 23 srcVdType := VpermType.getSrcVdType(fuOpType, vsew) 24 25 io.out.vs2Type := srcVdType.srcType2 26 io.out.vs1Type := srcVdType.srcType1 27 io.out.vdType := srcVdType.vdType 28} 29 30class VPPU(cfg: FuConfig)(implicit p: Parameters) extends VecPipedFuncUnit(cfg) { 31 XSError(io.in.valid && io.in.bits.ctrl.fuOpType === VpermType.dummy, "VpermType OpType not supported") 32 33 // params alias 34 private val dataWidth = cfg.dataBits 35 private val dataWidthOfDataModule = 64 36 private val numVecModule = dataWidth / dataWidthOfDataModule 37 private val vppuNeedClearMask = (VpermType.vcompress === io.in.bits.ctrl.fuOpType) && (vuopIdx(log2Up(MaxUopSize)-1,1) === 0.U) 38 private val mask = Mux(vppuNeedClearMask, 0.U, srcMask) 39 // mvnr (whole rigister move) instruction no need to use permutation module 40 private val isMvnr = (VpermType.vmvnr === io.in.bits.ctrl.fuOpType) 41 42 // io alias 43 private val opcode = VpermType.getOpcode(fuOpType) 44 45 // modules 46 private val typeMod = Module(new VIMacSrcTypeModule) 47 private val vperms = Module(new Permutation) 48 49 /** 50 * [[typeMod]]'s in connection 51 */ 52 typeMod.io.in.fuOpType := fuOpType 53 typeMod.io.in.vsew := vsew 54 typeMod.io.in.isReverse := isReverse 55 typeMod.io.in.isExt := isExt 56 typeMod.io.in.isDstMask := vecCtrl.isDstMask 57 typeMod.io.in.isMove := isMove 58 59 /** 60 * [[vperms]]'s in connection 61 */ 62 vperms.io match { 63 case subIO => 64 subIO.in.valid := io.in.valid && !isMvnr 65 subIO.in.bits.opcode.op := opcode 66 subIO.in.bits.info.vm := vm 67 subIO.in.bits.info.ma := vma 68 subIO.in.bits.info.ta := vta 69 subIO.in.bits.info.vlmul := vlmul 70 subIO.in.bits.info.vl := srcVConfig.vl 71 subIO.in.bits.info.vstart := vstart 72 subIO.in.bits.info.uopIdx := vuopIdx 73 subIO.in.bits.info.vxrm := vxrm 74 subIO.in.bits.srcType(0) := typeMod.io.out.vs2Type 75 subIO.in.bits.srcType(1) := typeMod.io.out.vs1Type 76 subIO.in.bits.vdType := typeMod.io.out.vdType 77 subIO.in.bits.vs1 := vs1 78 subIO.in.bits.vs2 := vs2 79 subIO.in.bits.old_vd := oldVd 80 subIO.in.bits.mask := mask 81 } 82 83 io.out.bits.res.data := Mux(isMvnr, RegEnable(vs2, io.in.valid), vperms.io.out.vd) 84 io.out.bits.res.vxsat.foreach(_ := vperms.io.out.vxsat) 85} 86