1567f0269Ssinsanctionpackage xiangshan.backend.decode 2567f0269Ssinsanction 3*83ba63b3SXuan Huimport org.chipsalliance.cde.config.Parameters 4567f0269Ssinsanctionimport chisel3._ 5567f0269Ssinsanctionimport chisel3.util._ 6567f0269Ssinsanctionimport freechips.rocketchip.rocket.Instructions._ 7567f0269Ssinsanctionimport freechips.rocketchip.util.uintToBitPat 8567f0269Ssinsanctionimport utility._ 9567f0269Ssinsanctionimport utils._ 10567f0269Ssinsanctionimport xiangshan._ 11567f0269Ssinsanctionimport xiangshan.backend.Bundles.{DecodedInst, DynInst, StaticInst} 12567f0269Ssinsanctionimport xiangshan.backend.fu.FuType 13567f0269Ssinsanctionimport xiangshan.backend.fu.vector.Bundles._ 14567f0269Ssinsanctionimport xiangshan.backend.decode.isa.bitfield.{InstVType, XSInstBitFields} 15567f0269Ssinsanction 16567f0269Ssinsanctionobject RegNumNotAlign { 17567f0269Ssinsanction def apply(reg: UInt, emul: UInt): Bool = { 18567f0269Ssinsanction emul === "b101".U && reg(0) =/= 0.U || emul === "b110".U && reg(1, 0) =/= 0.U || emul === "b111".U && reg(2, 0) =/= 0.U 19567f0269Ssinsanction } 20567f0269Ssinsanction} 21567f0269Ssinsanction 22567f0269Ssinsanctionobject NFtoLmul { 23567f0269Ssinsanction def apply(nf: UInt): UInt = { 24567f0269Ssinsanction LookupTree(nf, List( 25567f0269Ssinsanction "b000".U -> 4.U, 26567f0269Ssinsanction "b001".U -> 5.U, 27567f0269Ssinsanction "b011".U -> 6.U, 28567f0269Ssinsanction "b111".U -> 7.U 29567f0269Ssinsanction )) 30567f0269Ssinsanction } 31567f0269Ssinsanction} 32567f0269Ssinsanction 33567f0269Ssinsanctionobject LmultoRegNum { 34567f0269Ssinsanction def apply(lmul: UInt): UInt = { 35567f0269Ssinsanction val numPow = Mux(lmul(2).asBool, lmul(1, 0), 0.U(2.W)) 36567f0269Ssinsanction val regNum = 1.U << numPow 37567f0269Ssinsanction regNum 38567f0269Ssinsanction } 39567f0269Ssinsanction} 40567f0269Ssinsanction 41567f0269Ssinsanctionclass VecExceptionGen(implicit p: Parameters) extends XSModule{ 42567f0269Ssinsanction val io = IO(new Bundle(){ 43567f0269Ssinsanction val inst = Input(UInt(32.W)) 44567f0269Ssinsanction val decodedInst = Input(new DecodedInst) 45567f0269Ssinsanction val vtype = Input(new VType) 46567f0269Ssinsanction 47567f0269Ssinsanction val illegalInst = Output(Bool()) 48567f0269Ssinsanction }) 49567f0269Ssinsanction 50567f0269Ssinsanction private val inst: XSInstBitFields = io.inst.asTypeOf(new XSInstBitFields) 51239413e5SXuan Hu private val isVector = FuType.isVArithMem(io.decodedInst.fuType) 52567f0269Ssinsanction 53567f0269Ssinsanction private val SEW = io.vtype.vsew(1, 0) 54567f0269Ssinsanction private val LMUL = Cat(~io.vtype.vlmul(2), io.vtype.vlmul(1, 0)) 55567f0269Ssinsanction 56567f0269Ssinsanction private val lsStrideInst = Seq( 57567f0269Ssinsanction VLE8_V, VLE16_V, VLE32_V, VLE64_V, VSE8_V, VSE16_V, VSE32_V, VSE64_V, 58567f0269Ssinsanction VLSE8_V, VLSE16_V, VLSE32_V, VLSE64_V, VSSE8_V, VSSE16_V, VSSE32_V, VSSE64_V, 59567f0269Ssinsanction VLE8FF_V, VLE16FF_V, VLE32FF_V, VLE64FF_V 60567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 61567f0269Ssinsanction 62567f0269Ssinsanction private val lsMaskInst = Seq( 63567f0269Ssinsanction VLM_V, VSM_V 64567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 65567f0269Ssinsanction 66567f0269Ssinsanction private val lsIndexInst = Seq( 67567f0269Ssinsanction VLUXEI8_V, VLUXEI16_V, VLUXEI32_V, VLUXEI64_V, VLOXEI8_V, VLOXEI16_V, VLOXEI32_V, VLOXEI64_V, 68567f0269Ssinsanction VSUXEI8_V, VSUXEI16_V, VSUXEI32_V, VSUXEI64_V, VSOXEI8_V, VSOXEI16_V, VSOXEI32_V, VSOXEI64_V 69567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 70567f0269Ssinsanction 71567f0269Ssinsanction private val lsWholeInst = Seq( 72567f0269Ssinsanction VL1RE8_V, VL1RE16_V, VL1RE32_V, VL1RE64_V, 73567f0269Ssinsanction VL2RE8_V, VL2RE16_V, VL2RE32_V, VL2RE64_V, 74567f0269Ssinsanction VL4RE8_V, VL4RE16_V, VL4RE32_V, VL4RE64_V, 75567f0269Ssinsanction VL8RE8_V, VL8RE16_V, VL8RE32_V, VL8RE64_V, 76567f0269Ssinsanction VS1R_V, VS2R_V, VS4R_V, VS8R_V 77567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 78567f0269Ssinsanction 79567f0269Ssinsanction private val vdWideningInst = Seq( 80567f0269Ssinsanction //int 81567f0269Ssinsanction VWADD_VV, VWADD_VX, VWADD_WV, VWADD_WX, VWADDU_VV, VWADDU_VX, VWADDU_WV, VWADDU_WX, 82567f0269Ssinsanction VWMACC_VV, VWMACC_VX, VWMACCSU_VV, VWMACCSU_VX, VWMACCU_VV, VWMACCU_VX, VWMACCUS_VX, 83567f0269Ssinsanction VWMUL_VV, VWMUL_VX, VWMULSU_VV, VWMULSU_VX, VWMULU_VV, VWMULU_VX, 84567f0269Ssinsanction VWSUB_VV, VWSUB_VX, VWSUB_WV, VWSUB_WX, VWSUBU_VV, VWSUBU_VX, VWSUBU_WV, VWSUBU_WX, 85567f0269Ssinsanction //fp 86567f0269Ssinsanction VFWADD_VF, VFWADD_VV, VFWADD_WF, VFWADD_WV, VFWSUB_VF, VFWSUB_VV, VFWSUB_WF, VFWSUB_WV, 87567f0269Ssinsanction VFWMUL_VF, VFWMUL_VV, 88567f0269Ssinsanction VFWMACC_VF, VFWMACC_VV, VFWMSAC_VF, VFWMSAC_VV, VFWNMACC_VF, VFWNMACC_VV, VFWNMSAC_VF, VFWNMSAC_VV, 89567f0269Ssinsanction VFWCVT_F_F_V, VFWCVT_F_X_V, VFWCVT_F_XU_V, VFWCVT_RTZ_X_F_V, VFWCVT_RTZ_XU_F_V, VFWCVT_X_F_V, VFWCVT_XU_F_V 90567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 91567f0269Ssinsanction 92567f0269Ssinsanction private val vs2WideningInst = Seq( 93567f0269Ssinsanction //int 94567f0269Ssinsanction VWADD_WV, VWADD_WX, VWADDU_WV, VWADDU_WX, 95567f0269Ssinsanction VWSUB_WV, VWSUB_WX, VWSUBU_WV, VWSUBU_WX, 96567f0269Ssinsanction //fp 97567f0269Ssinsanction VFWADD_WF, VFWADD_WV, VFWSUB_WF, VFWSUB_WV 98567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 99567f0269Ssinsanction 100567f0269Ssinsanction private val narrowingInst = Seq( 101567f0269Ssinsanction //int 102567f0269Ssinsanction VNCLIP_WI, VNCLIP_WV, VNCLIP_WX, VNCLIPU_WI, VNCLIPU_WV, VNCLIPU_WX, 103567f0269Ssinsanction VNSRA_WI, VNSRA_WV, VNSRA_WX, VNSRL_WI, VNSRL_WV, VNSRL_WX, 104567f0269Ssinsanction //fp 105567f0269Ssinsanction VFNCVT_F_F_W, VFNCVT_F_X_W, VFNCVT_F_XU_W, VFNCVT_ROD_F_F_W, VFNCVT_RTZ_X_F_W, VFNCVT_RTZ_XU_F_W, VFNCVT_X_F_W, VFNCVT_XU_F_W 106567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 107567f0269Ssinsanction 108567f0269Ssinsanction private val intExtInst = Seq( 109567f0269Ssinsanction VSEXT_VF2, VSEXT_VF4, VSEXT_VF8, VZEXT_VF2, VZEXT_VF4, VZEXT_VF8 110567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 111567f0269Ssinsanction 112567f0269Ssinsanction private val acsbInst = Seq( 113567f0269Ssinsanction VMADC_VI, VMADC_VIM, VMADC_VV, VMADC_VVM, VMADC_VX, VMADC_VXM, 114567f0269Ssinsanction VMSBC_VV, VMSBC_VVM, VMSBC_VX, VMSBC_VXM 115567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 116567f0269Ssinsanction 117567f0269Ssinsanction private val cmpInst = Seq( 118567f0269Ssinsanction //int 119567f0269Ssinsanction VMSEQ_VI, VMSEQ_VV, VMSEQ_VX, 120567f0269Ssinsanction VMSGT_VI, VMSGT_VX, VMSGTU_VI, VMSGTU_VX, 121567f0269Ssinsanction VMSLE_VI, VMSLE_VV, VMSLE_VX, VMSLEU_VI, VMSLEU_VV, VMSLEU_VX, 122567f0269Ssinsanction VMSLT_VV, VMSLT_VX, VMSLTU_VV, VMSLTU_VX, 123567f0269Ssinsanction VMSNE_VI, VMSNE_VV, VMSNE_VX, 124567f0269Ssinsanction //fp 125567f0269Ssinsanction VMFEQ_VF, VMFEQ_VV, VMFNE_VF, VMFNE_VV, 126567f0269Ssinsanction VMFGE_VF, VMFGT_VF, VMFLE_VF, VMFLE_VV, VMFLT_VF, VMFLT_VV 127567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 128567f0269Ssinsanction 129567f0269Ssinsanction private val redInst = Seq( 130567f0269Ssinsanction VREDAND_VS, VREDMAX_VS, VREDMAXU_VS, VREDMIN_VS, VREDMINU_VS, VREDOR_VS, VREDSUM_VS, VREDXOR_VS, 131567f0269Ssinsanction VFREDMAX_VS, VFREDMIN_VS, VFREDOSUM_VS, VFREDUSUM_VS 132567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 133567f0269Ssinsanction 134567f0269Ssinsanction private val redWideningInst = Seq( 135567f0269Ssinsanction VWREDSUM_VS, VWREDSUMU_VS, 136567f0269Ssinsanction VFWREDOSUM_VS, VFWREDUSUM_VS 137567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 138567f0269Ssinsanction 139567f0269Ssinsanction private val maskLogicalInst = Seq( 140567f0269Ssinsanction VMAND_MM, VMNAND_MM, VMANDN_MM, VMXOR_MM, VMOR_MM, VMNOR_MM, VMORN_MM, VMXNOR_MM 141567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 142567f0269Ssinsanction 143567f0269Ssinsanction private val maskArithmeticInst = Seq( 144567f0269Ssinsanction VCPOP_M, VFIRST_M, VMSBF_M, VMSIF_M, VMSOF_M 145567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) || maskLogicalInst 146567f0269Ssinsanction 147567f0269Ssinsanction private val maskIndexInst = Seq( 148567f0269Ssinsanction VIOTA_M, VID_V 149567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 150567f0269Ssinsanction 151567f0269Ssinsanction private val vmvSingleInst = Seq( 152567f0269Ssinsanction VMV_X_S, VMV_S_X, VFMV_F_S, VFMV_S_F 153567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 154567f0269Ssinsanction 155567f0269Ssinsanction private val vmvWholeInst = Seq( 156567f0269Ssinsanction VMV1R_V, VMV2R_V, VMV4R_V, VMV8R_V 157567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 158567f0269Ssinsanction 159567f0269Ssinsanction private val vrgather16 = VRGATHEREI16_VV === inst.ALL 160567f0269Ssinsanction private val vcompress = VCOMPRESS_VM === inst.ALL 161567f0269Ssinsanction private val intExt2 = Seq(VSEXT_VF2, VZEXT_VF2).map(_ === inst.ALL).reduce(_ || _) 162567f0269Ssinsanction private val intExt4 = Seq(VSEXT_VF4, VZEXT_VF4).map(_ === inst.ALL).reduce(_ || _) 163567f0269Ssinsanction private val intExt8 = Seq(VSEXT_VF8, VZEXT_VF8).map(_ === inst.ALL).reduce(_ || _) 164567f0269Ssinsanction 165567f0269Ssinsanction private val notDependVtypeInst = Seq(VSETVLI, VSETIVLI, VSETVL).map(_ === inst.ALL).reduce(_ || _) || lsWholeInst || vmvWholeInst 166567f0269Ssinsanction 167567f0269Ssinsanction 168567f0269Ssinsanction // 1. inst Illegal 169567f0269Ssinsanction private val instIllegal = maskLogicalInst && inst.VM === 0.U 170567f0269Ssinsanction 171567f0269Ssinsanction // 2. vill Illegal 172567f0269Ssinsanction private val villIllegal = io.vtype.illegal && isVector && !notDependVtypeInst 173567f0269Ssinsanction 174567f0269Ssinsanction // 3. EEW Illegal 175567f0269Ssinsanction private val doubleFpInst = Seq( 176567f0269Ssinsanction VFWCVT_F_X_V, VFWCVT_F_XU_V, VFNCVT_RTZ_X_F_W, VFNCVT_RTZ_XU_F_W, VFNCVT_X_F_W, VFNCVT_XU_F_W 177567f0269Ssinsanction ).map(_ === inst.ALL).reduce(_ || _) 178239413e5SXuan Hu private val fpEewIllegal = FuType.isVecOPF(io.decodedInst.fuType) && !doubleFpInst && SEW === 0.U 179567f0269Ssinsanction 180567f0269Ssinsanction private val intExtEewIllegal = intExt2 && SEW === 0.U || 181567f0269Ssinsanction intExt4 && SEW <= 1.U || 182567f0269Ssinsanction intExt8 && SEW <= 2.U 183567f0269Ssinsanction 184567f0269Ssinsanction private val wnEewIllegal = (vdWideningInst || narrowingInst || redWideningInst) && SEW === 3.U 185567f0269Ssinsanction 186567f0269Ssinsanction private val eewIllegal = fpEewIllegal || intExtEewIllegal || wnEewIllegal 187567f0269Ssinsanction 188567f0269Ssinsanction // 4. EMUL Illegal 189567f0269Ssinsanction private val lsEmulIllegal = (lsStrideInst || lsIndexInst) && (LMUL +& inst.WIDTH(1, 0) < SEW +& 1.U || LMUL +& inst.WIDTH(1, 0) > SEW +& 7.U) 190567f0269Ssinsanction 191567f0269Ssinsanction private val intExtEmulIllegal = intExt2 && LMUL === 1.U || 192567f0269Ssinsanction intExt4 && LMUL <= 2.U || 193567f0269Ssinsanction intExt8 && LMUL <= 3.U 194567f0269Ssinsanction 195567f0269Ssinsanction private val wnEmulIllegal = (vdWideningInst || narrowingInst || redWideningInst) && LMUL === 7.U 196567f0269Ssinsanction 197567f0269Ssinsanction private val gather16EmulIllegal = vrgather16 && (LMUL < SEW || LMUL > SEW +& 6.U) 198567f0269Ssinsanction 199567f0269Ssinsanction private val NFIELDS = inst.NF +& 1.U 200567f0269Ssinsanction private val segEmul = Mux(lsIndexInst, LMUL, LMUL +& inst.WIDTH(1, 0) - SEW) 201567f0269Ssinsanction private val emulNumPow = Mux(segEmul(2), segEmul(1, 0), 0.U(2.W)) 202567f0269Ssinsanction private val segRegNum = NFIELDS << emulNumPow 203567f0269Ssinsanction private val segRegMax = inst.VD +& segRegNum 204567f0269Ssinsanction 205567f0269Ssinsanction private val lsSegIllegal = (lsStrideInst || lsIndexInst) && inst.NF =/= 0.U && (segRegNum > 8.U || segRegMax > 32.U) 206567f0269Ssinsanction 207567f0269Ssinsanction private val emulIllegal = lsEmulIllegal || intExtEmulIllegal || wnEmulIllegal || gather16EmulIllegal || lsSegIllegal 208567f0269Ssinsanction 209567f0269Ssinsanction // 5. Reg Number Align 210567f0269Ssinsanction private val vs1IsMask = maskArithmeticInst || vcompress 211567f0269Ssinsanction private val vs1IsSingleElem = redInst 212567f0269Ssinsanction private val vs1Eew = Mux(vrgather16, "b01".U, SEW) 213567f0269Ssinsanction private val vs1Emul = Mux(vs1IsMask || vs1IsSingleElem, "b100".U, Mux(vrgather16, LMUL +& 1.U - SEW, LMUL)) 214567f0269Ssinsanction private val vs1NotAlign = SrcType.isVp(io.decodedInst.srcType(0)) && RegNumNotAlign(inst.VS1, vs1Emul) 215567f0269Ssinsanction 216567f0269Ssinsanction private val vs2IsMask = maskArithmeticInst || maskIndexInst 217567f0269Ssinsanction private val vs2IsSingleElem = redWideningInst || vmvSingleInst 218567f0269Ssinsanction private val vs2EewSel = Cat(lsIndexInst, (vs2WideningInst || narrowingInst || redWideningInst), intExt2, intExt4, intExt8) 219567f0269Ssinsanction private val vs2Eew = LookupTreeDefault(vs2EewSel, SEW, List( 220567f0269Ssinsanction "b10000".U -> inst.WIDTH(1, 0), 221567f0269Ssinsanction "b01000".U -> (SEW + 1.U), 222567f0269Ssinsanction "b00100".U -> (SEW - 1.U), 223567f0269Ssinsanction "b00010".U -> (SEW - 2.U), 224567f0269Ssinsanction "b00001".U -> (SEW - 3.U) 225567f0269Ssinsanction )) 226567f0269Ssinsanction private val vs2EmulSel = Cat((vs2IsMask || vs2IsSingleElem), (vs2WideningInst || narrowingInst), vmvWholeInst, (intExtInst || lsIndexInst)) 227567f0269Ssinsanction private val vs2Emul = LookupTreeDefault(vs2EmulSel, LMUL, List( 228567f0269Ssinsanction "b1000".U -> "b100".U, 229567f0269Ssinsanction "b0100".U -> (LMUL + 1.U), 230567f0269Ssinsanction "b0010".U -> NFtoLmul(inst.NF), 231567f0269Ssinsanction "b0001".U -> (LMUL +& vs2Eew - SEW) 232567f0269Ssinsanction )) 233567f0269Ssinsanction private val vs2NotAlign = SrcType.isVp(io.decodedInst.srcType(1)) && RegNumNotAlign(inst.VS2, vs2Emul) 234567f0269Ssinsanction 235567f0269Ssinsanction private val vdIsMask = lsMaskInst || acsbInst || cmpInst || maskArithmeticInst 236567f0269Ssinsanction private val vdIsSingleElem = redInst || redWideningInst || vmvSingleInst 237567f0269Ssinsanction private val vdEew = Mux(lsStrideInst, inst.WIDTH(1, 0), Mux(vdWideningInst || redWideningInst, SEW + 1.U, SEW)) 238567f0269Ssinsanction private val vdEmulSel = Cat((vdIsMask || vdIsSingleElem), vdWideningInst, (lsWholeInst || vmvWholeInst), lsStrideInst) 239567f0269Ssinsanction private val vdEmul = LookupTreeDefault(vdEmulSel, LMUL, List( 240567f0269Ssinsanction "b1000".U -> "b100".U, 241567f0269Ssinsanction "b0100".U -> (LMUL + 1.U), 242567f0269Ssinsanction "b0010".U -> NFtoLmul(inst.NF), 243567f0269Ssinsanction "b0001".U -> (LMUL +& vdEew - SEW) 244567f0269Ssinsanction )) 245567f0269Ssinsanction private val vdNotAlign = (SrcType.isVp(io.decodedInst.srcType(2)) || io.decodedInst.vecWen) && RegNumNotAlign(inst.VD, vdEmul) 246567f0269Ssinsanction 247567f0269Ssinsanction private val regNumIllegal = isVector && (vs1NotAlign || vs2NotAlign || vdNotAlign) 248567f0269Ssinsanction 249567f0269Ssinsanction // 6. v0 Overlap 250567f0269Ssinsanction private val v0AllowOverlap = (vdIsMask || vdIsSingleElem) && !Seq(VMSBF_M, VMSIF_M, VMSOF_M).map(_ === inst.ALL).reduce(_ || _) 251567f0269Ssinsanction private val v0Overlap = io.decodedInst.vecWen && inst.VM === 0.U && inst.VD === 0.U && !v0AllowOverlap 252567f0269Ssinsanction 253567f0269Ssinsanction // 7. Src Reg Overlap 254567f0269Ssinsanction private val vs1RegLo = inst.VS1 255567f0269Ssinsanction private val vs1RegHi = inst.VS1 +& LmultoRegNum(vs1Emul) - 1.U 256567f0269Ssinsanction private val vs2RegLo = inst.VS2 257567f0269Ssinsanction private val vs2RegHi = inst.VS2 +& LmultoRegNum(vs2Emul) - 1.U 258567f0269Ssinsanction private val vdRegLo = inst.VD 259567f0269Ssinsanction private val vdRegHi = Mux(lsStrideInst || lsIndexInst, segRegMax - 1.U, inst.VD + LmultoRegNum(vdEmul) - 1.U) 260567f0269Ssinsanction 261567f0269Ssinsanction private val notAllowOverlapInst = lsIndexInst && inst.NF =/= 0.U || Seq(VMSBF_M, VMSIF_M, VMSOF_M, VIOTA_M, 262567f0269Ssinsanction VSLIDEUP_VX, VSLIDEUP_VI, VSLIDE1UP_VX, VFSLIDE1UP_VF, VRGATHER_VV, VRGATHEREI16_VV, VRGATHER_VX, VRGATHER_VI, VCOMPRESS_VM).map(_ === inst.ALL).reduce(_ || _) 263567f0269Ssinsanction 264567f0269Ssinsanction //vs1 265567f0269Ssinsanction private val vs1vdRegNotOverlap = vs1RegHi < vdRegLo || vdRegHi < vs1RegLo 266567f0269Ssinsanction private val vs1Constraint1 = vs1IsMask && vdIsMask || !vs1IsMask && !vdIsMask && vs1Eew === vdEew 267567f0269Ssinsanction private val vs1Constraint2 = (vdIsMask && !vs1IsMask || !vs1IsMask && !vdIsMask && vs1Eew > vdEew) && vdRegLo === vs1RegLo && vdRegHi <= vs1RegHi 268567f0269Ssinsanction private val vs1Constraint3 = (!vdIsMask && vs1IsMask || !vs1IsMask && !vdIsMask && vs1Eew < vdEew) && vs1Emul >= "b100".U && vdRegHi === vs1RegHi && vdRegLo <= vs1RegLo 269567f0269Ssinsanction private val vs1AllowOverlap = (vs1Constraint1 || vs1Constraint2 || vs1Constraint3 || vdIsSingleElem) && !notAllowOverlapInst 270567f0269Ssinsanction private val vs1vdOverlap = (SrcType.isVp(io.decodedInst.srcType(0)) && io.decodedInst.vecWen) && !vs1vdRegNotOverlap && !vs1AllowOverlap 271567f0269Ssinsanction //vs2 272567f0269Ssinsanction private val vs2vdRegNotOverlap = vs2RegHi < vdRegLo || vdRegHi < vs2RegLo 273567f0269Ssinsanction private val vs2Constraint1 = vs2IsMask && vdIsMask || !vs2IsMask && !vdIsMask && vs2Eew === vdEew 274567f0269Ssinsanction private val vs2Constraint2 = (vdIsMask && !vs2IsMask || !vs2IsMask && !vdIsMask && vs2Eew > vdEew) && vdRegLo === vs2RegLo && vdRegHi <= vs2RegHi 275567f0269Ssinsanction private val vs2Constraint3 = (!vdIsMask && vs2IsMask || !vs2IsMask && !vdIsMask && vs2Eew < vdEew) && vs2Emul >= "b100".U && vdRegHi === vs2RegHi && vdRegLo <= vs2RegLo 276567f0269Ssinsanction private val vs2AllowOverlap = (vs2Constraint1 || vs2Constraint2 || vs2Constraint3 || vdIsSingleElem) && !notAllowOverlapInst 277567f0269Ssinsanction private val vs2vdOverlap = (SrcType.isVp(io.decodedInst.srcType(1)) && io.decodedInst.vecWen) && !vs2vdRegNotOverlap && !vs2AllowOverlap 278567f0269Ssinsanction 279567f0269Ssinsanction private val regOverlapIllegal = v0Overlap || vs1vdOverlap || vs2vdOverlap 280567f0269Ssinsanction 281567f0269Ssinsanction io.illegalInst := instIllegal || villIllegal || eewIllegal || emulIllegal || regNumIllegal || regOverlapIllegal 282567f0269Ssinsanction}