xref: /XiangShan/src/main/scala/xiangshan/backend/decode/VecExceptionGen.scala (revision 567f026902f33590220a91e845893430ab6be193)
1*567f0269Ssinsanctionpackage xiangshan.backend.decode
2*567f0269Ssinsanction
3*567f0269Ssinsanctionimport chipsalliance.rocketchip.config.Parameters
4*567f0269Ssinsanctionimport chisel3._
5*567f0269Ssinsanctionimport chisel3.util._
6*567f0269Ssinsanctionimport freechips.rocketchip.rocket.Instructions._
7*567f0269Ssinsanctionimport freechips.rocketchip.util.uintToBitPat
8*567f0269Ssinsanctionimport utility._
9*567f0269Ssinsanctionimport utils._
10*567f0269Ssinsanctionimport xiangshan._
11*567f0269Ssinsanctionimport xiangshan.backend.Bundles.{DecodedInst, DynInst, StaticInst}
12*567f0269Ssinsanctionimport xiangshan.backend.fu.FuType
13*567f0269Ssinsanctionimport xiangshan.backend.fu.vector.Bundles._
14*567f0269Ssinsanctionimport xiangshan.backend.decode.isa.bitfield.{InstVType, XSInstBitFields}
15*567f0269Ssinsanction
16*567f0269Ssinsanctionobject RegNumNotAlign {
17*567f0269Ssinsanction  def apply(reg: UInt, emul: UInt): Bool = {
18*567f0269Ssinsanction    emul === "b101".U && reg(0) =/= 0.U || emul === "b110".U && reg(1, 0) =/= 0.U || emul === "b111".U && reg(2, 0) =/= 0.U
19*567f0269Ssinsanction  }
20*567f0269Ssinsanction}
21*567f0269Ssinsanction
22*567f0269Ssinsanctionobject NFtoLmul {
23*567f0269Ssinsanction  def apply(nf: UInt): UInt = {
24*567f0269Ssinsanction    LookupTree(nf, List(
25*567f0269Ssinsanction      "b000".U -> 4.U,
26*567f0269Ssinsanction      "b001".U -> 5.U,
27*567f0269Ssinsanction      "b011".U -> 6.U,
28*567f0269Ssinsanction      "b111".U -> 7.U
29*567f0269Ssinsanction    ))
30*567f0269Ssinsanction  }
31*567f0269Ssinsanction}
32*567f0269Ssinsanction
33*567f0269Ssinsanctionobject LmultoRegNum {
34*567f0269Ssinsanction  def apply(lmul: UInt): UInt = {
35*567f0269Ssinsanction    val numPow = Mux(lmul(2).asBool, lmul(1, 0), 0.U(2.W))
36*567f0269Ssinsanction    val regNum = 1.U << numPow
37*567f0269Ssinsanction    regNum
38*567f0269Ssinsanction  }
39*567f0269Ssinsanction}
40*567f0269Ssinsanction
41*567f0269Ssinsanctionclass VecExceptionGen(implicit p: Parameters) extends XSModule{
42*567f0269Ssinsanction  val io = IO(new Bundle(){
43*567f0269Ssinsanction    val inst = Input(UInt(32.W))
44*567f0269Ssinsanction    val decodedInst = Input(new DecodedInst)
45*567f0269Ssinsanction    val vtype = Input(new VType)
46*567f0269Ssinsanction
47*567f0269Ssinsanction    val illegalInst = Output(Bool())
48*567f0269Ssinsanction  })
49*567f0269Ssinsanction
50*567f0269Ssinsanction  private val inst: XSInstBitFields = io.inst.asTypeOf(new XSInstBitFields)
51*567f0269Ssinsanction  private val isVector = io.decodedInst.fuType(24, 16).orR
52*567f0269Ssinsanction
53*567f0269Ssinsanction  private val SEW = io.vtype.vsew(1, 0)
54*567f0269Ssinsanction  private val LMUL = Cat(~io.vtype.vlmul(2), io.vtype.vlmul(1, 0))
55*567f0269Ssinsanction
56*567f0269Ssinsanction  private val lsStrideInst = Seq(
57*567f0269Ssinsanction    VLE8_V, VLE16_V, VLE32_V, VLE64_V, VSE8_V, VSE16_V, VSE32_V, VSE64_V,
58*567f0269Ssinsanction    VLSE8_V, VLSE16_V, VLSE32_V, VLSE64_V, VSSE8_V, VSSE16_V, VSSE32_V, VSSE64_V,
59*567f0269Ssinsanction    VLE8FF_V, VLE16FF_V, VLE32FF_V, VLE64FF_V
60*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
61*567f0269Ssinsanction
62*567f0269Ssinsanction  private val lsMaskInst = Seq(
63*567f0269Ssinsanction    VLM_V, VSM_V
64*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
65*567f0269Ssinsanction
66*567f0269Ssinsanction  private val lsIndexInst = Seq(
67*567f0269Ssinsanction    VLUXEI8_V, VLUXEI16_V, VLUXEI32_V, VLUXEI64_V, VLOXEI8_V, VLOXEI16_V, VLOXEI32_V, VLOXEI64_V,
68*567f0269Ssinsanction    VSUXEI8_V, VSUXEI16_V, VSUXEI32_V, VSUXEI64_V, VSOXEI8_V, VSOXEI16_V, VSOXEI32_V, VSOXEI64_V
69*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
70*567f0269Ssinsanction
71*567f0269Ssinsanction  private val lsWholeInst = Seq(
72*567f0269Ssinsanction    VL1RE8_V, VL1RE16_V, VL1RE32_V, VL1RE64_V,
73*567f0269Ssinsanction    VL2RE8_V, VL2RE16_V, VL2RE32_V, VL2RE64_V,
74*567f0269Ssinsanction    VL4RE8_V, VL4RE16_V, VL4RE32_V, VL4RE64_V,
75*567f0269Ssinsanction    VL8RE8_V, VL8RE16_V, VL8RE32_V, VL8RE64_V,
76*567f0269Ssinsanction    VS1R_V, VS2R_V, VS4R_V, VS8R_V
77*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
78*567f0269Ssinsanction
79*567f0269Ssinsanction  private val vdWideningInst = Seq(
80*567f0269Ssinsanction    //int
81*567f0269Ssinsanction    VWADD_VV, VWADD_VX, VWADD_WV, VWADD_WX, VWADDU_VV, VWADDU_VX, VWADDU_WV, VWADDU_WX,
82*567f0269Ssinsanction    VWMACC_VV, VWMACC_VX, VWMACCSU_VV, VWMACCSU_VX, VWMACCU_VV, VWMACCU_VX, VWMACCUS_VX,
83*567f0269Ssinsanction    VWMUL_VV, VWMUL_VX, VWMULSU_VV, VWMULSU_VX, VWMULU_VV, VWMULU_VX,
84*567f0269Ssinsanction    VWSUB_VV, VWSUB_VX, VWSUB_WV, VWSUB_WX, VWSUBU_VV, VWSUBU_VX, VWSUBU_WV, VWSUBU_WX,
85*567f0269Ssinsanction    //fp
86*567f0269Ssinsanction    VFWADD_VF, VFWADD_VV, VFWADD_WF, VFWADD_WV, VFWSUB_VF, VFWSUB_VV, VFWSUB_WF, VFWSUB_WV,
87*567f0269Ssinsanction    VFWMUL_VF, VFWMUL_VV,
88*567f0269Ssinsanction    VFWMACC_VF, VFWMACC_VV, VFWMSAC_VF, VFWMSAC_VV, VFWNMACC_VF, VFWNMACC_VV, VFWNMSAC_VF, VFWNMSAC_VV,
89*567f0269Ssinsanction    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
90*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
91*567f0269Ssinsanction
92*567f0269Ssinsanction  private val vs2WideningInst = Seq(
93*567f0269Ssinsanction    //int
94*567f0269Ssinsanction    VWADD_WV, VWADD_WX, VWADDU_WV, VWADDU_WX,
95*567f0269Ssinsanction    VWSUB_WV, VWSUB_WX, VWSUBU_WV, VWSUBU_WX,
96*567f0269Ssinsanction    //fp
97*567f0269Ssinsanction    VFWADD_WF, VFWADD_WV, VFWSUB_WF, VFWSUB_WV
98*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
99*567f0269Ssinsanction
100*567f0269Ssinsanction  private val narrowingInst = Seq(
101*567f0269Ssinsanction    //int
102*567f0269Ssinsanction    VNCLIP_WI, VNCLIP_WV, VNCLIP_WX, VNCLIPU_WI, VNCLIPU_WV, VNCLIPU_WX,
103*567f0269Ssinsanction    VNSRA_WI, VNSRA_WV, VNSRA_WX, VNSRL_WI, VNSRL_WV, VNSRL_WX,
104*567f0269Ssinsanction    //fp
105*567f0269Ssinsanction    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
106*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
107*567f0269Ssinsanction
108*567f0269Ssinsanction  private val intExtInst = Seq(
109*567f0269Ssinsanction    VSEXT_VF2, VSEXT_VF4, VSEXT_VF8, VZEXT_VF2, VZEXT_VF4, VZEXT_VF8
110*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
111*567f0269Ssinsanction
112*567f0269Ssinsanction  private val acsbInst = Seq(
113*567f0269Ssinsanction    VMADC_VI, VMADC_VIM, VMADC_VV, VMADC_VVM, VMADC_VX, VMADC_VXM,
114*567f0269Ssinsanction    VMSBC_VV, VMSBC_VVM, VMSBC_VX, VMSBC_VXM
115*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
116*567f0269Ssinsanction
117*567f0269Ssinsanction  private val cmpInst = Seq(
118*567f0269Ssinsanction    //int
119*567f0269Ssinsanction    VMSEQ_VI, VMSEQ_VV, VMSEQ_VX,
120*567f0269Ssinsanction    VMSGT_VI, VMSGT_VX, VMSGTU_VI, VMSGTU_VX,
121*567f0269Ssinsanction    VMSLE_VI, VMSLE_VV, VMSLE_VX, VMSLEU_VI, VMSLEU_VV, VMSLEU_VX,
122*567f0269Ssinsanction    VMSLT_VV, VMSLT_VX, VMSLTU_VV, VMSLTU_VX,
123*567f0269Ssinsanction    VMSNE_VI, VMSNE_VV, VMSNE_VX,
124*567f0269Ssinsanction    //fp
125*567f0269Ssinsanction    VMFEQ_VF, VMFEQ_VV, VMFNE_VF, VMFNE_VV,
126*567f0269Ssinsanction    VMFGE_VF, VMFGT_VF, VMFLE_VF, VMFLE_VV, VMFLT_VF, VMFLT_VV
127*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
128*567f0269Ssinsanction
129*567f0269Ssinsanction  private val redInst = Seq(
130*567f0269Ssinsanction    VREDAND_VS, VREDMAX_VS, VREDMAXU_VS, VREDMIN_VS, VREDMINU_VS, VREDOR_VS, VREDSUM_VS, VREDXOR_VS,
131*567f0269Ssinsanction    VFREDMAX_VS, VFREDMIN_VS, VFREDOSUM_VS, VFREDUSUM_VS
132*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
133*567f0269Ssinsanction
134*567f0269Ssinsanction  private val redWideningInst = Seq(
135*567f0269Ssinsanction    VWREDSUM_VS, VWREDSUMU_VS,
136*567f0269Ssinsanction    VFWREDOSUM_VS, VFWREDUSUM_VS
137*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
138*567f0269Ssinsanction
139*567f0269Ssinsanction  private val maskLogicalInst = Seq(
140*567f0269Ssinsanction    VMAND_MM, VMNAND_MM, VMANDN_MM, VMXOR_MM, VMOR_MM, VMNOR_MM, VMORN_MM, VMXNOR_MM
141*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
142*567f0269Ssinsanction
143*567f0269Ssinsanction  private val maskArithmeticInst = Seq(
144*567f0269Ssinsanction    VCPOP_M, VFIRST_M, VMSBF_M, VMSIF_M, VMSOF_M
145*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _) || maskLogicalInst
146*567f0269Ssinsanction
147*567f0269Ssinsanction  private val maskIndexInst = Seq(
148*567f0269Ssinsanction    VIOTA_M, VID_V
149*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
150*567f0269Ssinsanction
151*567f0269Ssinsanction  private val vmvSingleInst = Seq(
152*567f0269Ssinsanction    VMV_X_S, VMV_S_X, VFMV_F_S, VFMV_S_F
153*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
154*567f0269Ssinsanction
155*567f0269Ssinsanction  private val vmvWholeInst = Seq(
156*567f0269Ssinsanction    VMV1R_V, VMV2R_V, VMV4R_V, VMV8R_V
157*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
158*567f0269Ssinsanction
159*567f0269Ssinsanction  private val vrgather16 = VRGATHEREI16_VV === inst.ALL
160*567f0269Ssinsanction  private val vcompress = VCOMPRESS_VM === inst.ALL
161*567f0269Ssinsanction  private val intExt2 = Seq(VSEXT_VF2, VZEXT_VF2).map(_ === inst.ALL).reduce(_ || _)
162*567f0269Ssinsanction  private val intExt4 = Seq(VSEXT_VF4, VZEXT_VF4).map(_ === inst.ALL).reduce(_ || _)
163*567f0269Ssinsanction  private val intExt8 = Seq(VSEXT_VF8, VZEXT_VF8).map(_ === inst.ALL).reduce(_ || _)
164*567f0269Ssinsanction
165*567f0269Ssinsanction  private val notDependVtypeInst = Seq(VSETVLI, VSETIVLI, VSETVL).map(_ === inst.ALL).reduce(_ || _) || lsWholeInst || vmvWholeInst
166*567f0269Ssinsanction
167*567f0269Ssinsanction
168*567f0269Ssinsanction  // 1. inst Illegal
169*567f0269Ssinsanction  private val instIllegal = maskLogicalInst && inst.VM === 0.U
170*567f0269Ssinsanction
171*567f0269Ssinsanction  // 2. vill Illegal
172*567f0269Ssinsanction  private val villIllegal = io.vtype.illegal && isVector && !notDependVtypeInst
173*567f0269Ssinsanction
174*567f0269Ssinsanction  // 3. EEW Illegal
175*567f0269Ssinsanction  private val doubleFpInst = Seq(
176*567f0269Ssinsanction    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
177*567f0269Ssinsanction  ).map(_ === inst.ALL).reduce(_ || _)
178*567f0269Ssinsanction  private val fpEewIllegal = io.decodedInst.fuType(18).asBool && !doubleFpInst && SEW === 0.U
179*567f0269Ssinsanction
180*567f0269Ssinsanction  private val intExtEewIllegal = intExt2 && SEW === 0.U ||
181*567f0269Ssinsanction                                 intExt4 && SEW <= 1.U ||
182*567f0269Ssinsanction                                 intExt8 && SEW <= 2.U
183*567f0269Ssinsanction
184*567f0269Ssinsanction  private val wnEewIllegal = (vdWideningInst || narrowingInst || redWideningInst) && SEW === 3.U
185*567f0269Ssinsanction
186*567f0269Ssinsanction  private val eewIllegal = fpEewIllegal || intExtEewIllegal || wnEewIllegal
187*567f0269Ssinsanction
188*567f0269Ssinsanction  // 4. EMUL Illegal
189*567f0269Ssinsanction  private val lsEmulIllegal = (lsStrideInst || lsIndexInst) && (LMUL +& inst.WIDTH(1, 0) < SEW +& 1.U || LMUL +& inst.WIDTH(1, 0) > SEW +& 7.U)
190*567f0269Ssinsanction
191*567f0269Ssinsanction  private val intExtEmulIllegal = intExt2 && LMUL === 1.U ||
192*567f0269Ssinsanction                                  intExt4 && LMUL <= 2.U ||
193*567f0269Ssinsanction                                  intExt8 && LMUL <= 3.U
194*567f0269Ssinsanction
195*567f0269Ssinsanction  private val wnEmulIllegal = (vdWideningInst || narrowingInst || redWideningInst) && LMUL === 7.U
196*567f0269Ssinsanction
197*567f0269Ssinsanction  private val gather16EmulIllegal = vrgather16 && (LMUL < SEW || LMUL > SEW +& 6.U)
198*567f0269Ssinsanction
199*567f0269Ssinsanction  private val NFIELDS = inst.NF +& 1.U
200*567f0269Ssinsanction  private val segEmul = Mux(lsIndexInst, LMUL, LMUL +& inst.WIDTH(1, 0) - SEW)
201*567f0269Ssinsanction  private val emulNumPow = Mux(segEmul(2), segEmul(1, 0), 0.U(2.W))
202*567f0269Ssinsanction  private val segRegNum = NFIELDS << emulNumPow
203*567f0269Ssinsanction  private val segRegMax = inst.VD +& segRegNum
204*567f0269Ssinsanction
205*567f0269Ssinsanction  private val lsSegIllegal = (lsStrideInst || lsIndexInst) && inst.NF =/= 0.U && (segRegNum > 8.U || segRegMax > 32.U)
206*567f0269Ssinsanction
207*567f0269Ssinsanction  private val emulIllegal = lsEmulIllegal || intExtEmulIllegal || wnEmulIllegal || gather16EmulIllegal || lsSegIllegal
208*567f0269Ssinsanction
209*567f0269Ssinsanction  // 5. Reg Number Align
210*567f0269Ssinsanction  private val vs1IsMask = maskArithmeticInst || vcompress
211*567f0269Ssinsanction  private val vs1IsSingleElem = redInst
212*567f0269Ssinsanction  private val vs1Eew = Mux(vrgather16, "b01".U, SEW)
213*567f0269Ssinsanction  private val vs1Emul = Mux(vs1IsMask || vs1IsSingleElem, "b100".U, Mux(vrgather16, LMUL +& 1.U - SEW, LMUL))
214*567f0269Ssinsanction  private val vs1NotAlign = SrcType.isVp(io.decodedInst.srcType(0)) && RegNumNotAlign(inst.VS1, vs1Emul)
215*567f0269Ssinsanction
216*567f0269Ssinsanction  private val vs2IsMask = maskArithmeticInst || maskIndexInst
217*567f0269Ssinsanction  private val vs2IsSingleElem = redWideningInst || vmvSingleInst
218*567f0269Ssinsanction  private val vs2EewSel = Cat(lsIndexInst, (vs2WideningInst || narrowingInst || redWideningInst), intExt2, intExt4, intExt8)
219*567f0269Ssinsanction  private val vs2Eew = LookupTreeDefault(vs2EewSel, SEW, List(
220*567f0269Ssinsanction    "b10000".U  -> inst.WIDTH(1, 0),
221*567f0269Ssinsanction    "b01000".U  -> (SEW + 1.U),
222*567f0269Ssinsanction    "b00100".U  -> (SEW - 1.U),
223*567f0269Ssinsanction    "b00010".U  -> (SEW - 2.U),
224*567f0269Ssinsanction    "b00001".U  -> (SEW - 3.U)
225*567f0269Ssinsanction  ))
226*567f0269Ssinsanction  private val vs2EmulSel = Cat((vs2IsMask || vs2IsSingleElem), (vs2WideningInst || narrowingInst), vmvWholeInst, (intExtInst || lsIndexInst))
227*567f0269Ssinsanction  private val vs2Emul = LookupTreeDefault(vs2EmulSel, LMUL, List(
228*567f0269Ssinsanction    "b1000".U  -> "b100".U,
229*567f0269Ssinsanction    "b0100".U  -> (LMUL + 1.U),
230*567f0269Ssinsanction    "b0010".U  -> NFtoLmul(inst.NF),
231*567f0269Ssinsanction    "b0001".U  -> (LMUL +& vs2Eew - SEW)
232*567f0269Ssinsanction  ))
233*567f0269Ssinsanction  private val vs2NotAlign = SrcType.isVp(io.decodedInst.srcType(1)) && RegNumNotAlign(inst.VS2, vs2Emul)
234*567f0269Ssinsanction
235*567f0269Ssinsanction  private val vdIsMask = lsMaskInst || acsbInst || cmpInst || maskArithmeticInst
236*567f0269Ssinsanction  private val vdIsSingleElem = redInst || redWideningInst || vmvSingleInst
237*567f0269Ssinsanction  private val vdEew = Mux(lsStrideInst, inst.WIDTH(1, 0), Mux(vdWideningInst || redWideningInst, SEW + 1.U, SEW))
238*567f0269Ssinsanction  private val vdEmulSel = Cat((vdIsMask || vdIsSingleElem), vdWideningInst, (lsWholeInst || vmvWholeInst), lsStrideInst)
239*567f0269Ssinsanction  private val vdEmul = LookupTreeDefault(vdEmulSel, LMUL, List(
240*567f0269Ssinsanction    "b1000".U  -> "b100".U,
241*567f0269Ssinsanction    "b0100".U  -> (LMUL + 1.U),
242*567f0269Ssinsanction    "b0010".U  -> NFtoLmul(inst.NF),
243*567f0269Ssinsanction    "b0001".U  -> (LMUL +& vdEew - SEW)
244*567f0269Ssinsanction  ))
245*567f0269Ssinsanction  private val vdNotAlign = (SrcType.isVp(io.decodedInst.srcType(2)) || io.decodedInst.vecWen) && RegNumNotAlign(inst.VD, vdEmul)
246*567f0269Ssinsanction
247*567f0269Ssinsanction  private val regNumIllegal = isVector && (vs1NotAlign || vs2NotAlign || vdNotAlign)
248*567f0269Ssinsanction
249*567f0269Ssinsanction  // 6. v0 Overlap
250*567f0269Ssinsanction  private val v0AllowOverlap = (vdIsMask || vdIsSingleElem) && !Seq(VMSBF_M, VMSIF_M, VMSOF_M).map(_ === inst.ALL).reduce(_ || _)
251*567f0269Ssinsanction  private val v0Overlap = io.decodedInst.vecWen && inst.VM === 0.U && inst.VD === 0.U && !v0AllowOverlap
252*567f0269Ssinsanction
253*567f0269Ssinsanction  // 7. Src Reg Overlap
254*567f0269Ssinsanction  private val vs1RegLo = inst.VS1
255*567f0269Ssinsanction  private val vs1RegHi = inst.VS1 +& LmultoRegNum(vs1Emul) - 1.U
256*567f0269Ssinsanction  private val vs2RegLo = inst.VS2
257*567f0269Ssinsanction  private val vs2RegHi = inst.VS2 +& LmultoRegNum(vs2Emul) - 1.U
258*567f0269Ssinsanction  private val vdRegLo = inst.VD
259*567f0269Ssinsanction  private val vdRegHi = Mux(lsStrideInst || lsIndexInst, segRegMax - 1.U, inst.VD + LmultoRegNum(vdEmul) - 1.U)
260*567f0269Ssinsanction
261*567f0269Ssinsanction  private val notAllowOverlapInst = lsIndexInst && inst.NF =/= 0.U || Seq(VMSBF_M, VMSIF_M, VMSOF_M, VIOTA_M,
262*567f0269Ssinsanction                                    VSLIDEUP_VX, VSLIDEUP_VI, VSLIDE1UP_VX, VFSLIDE1UP_VF, VRGATHER_VV, VRGATHEREI16_VV, VRGATHER_VX, VRGATHER_VI, VCOMPRESS_VM).map(_ === inst.ALL).reduce(_ || _)
263*567f0269Ssinsanction
264*567f0269Ssinsanction  //vs1
265*567f0269Ssinsanction  private val vs1vdRegNotOverlap = vs1RegHi < vdRegLo || vdRegHi < vs1RegLo
266*567f0269Ssinsanction  private val vs1Constraint1 = vs1IsMask && vdIsMask || !vs1IsMask && !vdIsMask && vs1Eew === vdEew
267*567f0269Ssinsanction  private val vs1Constraint2 = (vdIsMask && !vs1IsMask || !vs1IsMask && !vdIsMask && vs1Eew > vdEew) && vdRegLo === vs1RegLo && vdRegHi <= vs1RegHi
268*567f0269Ssinsanction  private val vs1Constraint3 = (!vdIsMask && vs1IsMask || !vs1IsMask && !vdIsMask && vs1Eew < vdEew) && vs1Emul >= "b100".U && vdRegHi === vs1RegHi && vdRegLo <= vs1RegLo
269*567f0269Ssinsanction  private val vs1AllowOverlap = (vs1Constraint1 || vs1Constraint2 || vs1Constraint3 || vdIsSingleElem) && !notAllowOverlapInst
270*567f0269Ssinsanction  private val vs1vdOverlap = (SrcType.isVp(io.decodedInst.srcType(0)) && io.decodedInst.vecWen) && !vs1vdRegNotOverlap && !vs1AllowOverlap
271*567f0269Ssinsanction  //vs2
272*567f0269Ssinsanction  private val vs2vdRegNotOverlap = vs2RegHi < vdRegLo || vdRegHi < vs2RegLo
273*567f0269Ssinsanction  private val vs2Constraint1 = vs2IsMask && vdIsMask || !vs2IsMask && !vdIsMask && vs2Eew === vdEew
274*567f0269Ssinsanction  private val vs2Constraint2 = (vdIsMask && !vs2IsMask || !vs2IsMask && !vdIsMask && vs2Eew > vdEew) && vdRegLo === vs2RegLo && vdRegHi <= vs2RegHi
275*567f0269Ssinsanction  private val vs2Constraint3 = (!vdIsMask && vs2IsMask || !vs2IsMask && !vdIsMask && vs2Eew < vdEew) && vs2Emul >= "b100".U && vdRegHi === vs2RegHi && vdRegLo <= vs2RegLo
276*567f0269Ssinsanction  private val vs2AllowOverlap = (vs2Constraint1 || vs2Constraint2 || vs2Constraint3 || vdIsSingleElem) && !notAllowOverlapInst
277*567f0269Ssinsanction  private val vs2vdOverlap = (SrcType.isVp(io.decodedInst.srcType(1)) && io.decodedInst.vecWen) && !vs2vdRegNotOverlap && !vs2AllowOverlap
278*567f0269Ssinsanction
279*567f0269Ssinsanction  private val regOverlapIllegal = v0Overlap || vs1vdOverlap || vs2vdOverlap
280*567f0269Ssinsanction
281*567f0269Ssinsanction  io.illegalInst := instIllegal || villIllegal || eewIllegal || emulIllegal || regNumIllegal || regOverlapIllegal
282*567f0269Ssinsanction}