1*a8db15d8Sfdypackage xiangshan.backend.fu 2*a8db15d8Sfdy 3*a8db15d8Sfdyobject VsetRef{ 4*a8db15d8Sfdy def VLEN: Int = 128 5*a8db15d8Sfdy def XLEN: Int = 64 6*a8db15d8Sfdy def ELEN: Int = 64 7*a8db15d8Sfdy def isKeepVL(func: Int): Boolean = (func >> 1 & 1) == 1 8*a8db15d8Sfdy def isSetVlmax(func: Int): Boolean = (func & 1) == 1 9*a8db15d8Sfdy def isVsetivli(func: Int): Boolean = (func & 0xc0) == 0 10*a8db15d8Sfdy def isVsetvl(func: Int): Boolean = (func >> 6 & 1) == 1 11*a8db15d8Sfdy 12*a8db15d8Sfdy def test(avlPre: Int, vsew: Int, vlmul: Int, vta: Boolean, vma: Boolean, villPre: Boolean, func: Int, oldVL: Int) = { 13*a8db15d8Sfdy val avl = if(this.isVsetivli(func)) avlPre & 0x1f else avlPre 14*a8db15d8Sfdy val vill = if(this.isVsetvl(func)) villPre else false 15*a8db15d8Sfdy println("[REF] --- avl:" + avl + " vsew:" + vsew + " vlmul:" + vlmul + " vta:" + vta + " vma:" + vma + " vill:" + vill + " func:" + func.toBinaryString + " oldVL:" + oldVL) 16*a8db15d8Sfdy val isKeepVl = this.isKeepVL(func) 17*a8db15d8Sfdy val isSetVlmax = this.isSetVlmax(func) 18*a8db15d8Sfdy val isVsetivli = this.isVsetivli(func) 19*a8db15d8Sfdy 20*a8db15d8Sfdy val vsewValue = 1 << vsew + 3 21*a8db15d8Sfdy val vflmul: Double = if ((vlmul & 0x4) == 0) 1 << vlmul else 1.0 / (1 << ((vlmul ^ 0x7) + 1)) 22*a8db15d8Sfdy val vlmax = (VLEN/vsewValue) * vflmul 23*a8db15d8Sfdy 24*a8db15d8Sfdy println("[REF] --- vsewValue: " + vsewValue + " vflmul: " + vflmul + " vlmax: " + vlmax) 25*a8db15d8Sfdy 26*a8db15d8Sfdy val villegal = !(vflmul >= 0.125 && vflmul <= 8) || vsewValue > (vflmul min 1.0f) * ELEN || vill 27*a8db15d8Sfdy 28*a8db15d8Sfdy // set vl 29*a8db15d8Sfdy val vl = if(isVsetivli) { 30*a8db15d8Sfdy if(avl > vlmax) vlmax else avl 31*a8db15d8Sfdy }else if (isKeepVl) { 32*a8db15d8Sfdy oldVL 33*a8db15d8Sfdy } else if (isSetVlmax) { 34*a8db15d8Sfdy vlmax 35*a8db15d8Sfdy } else { 36*a8db15d8Sfdy if(avl > vlmax) vlmax else avl 37*a8db15d8Sfdy } 38*a8db15d8Sfdy if (villegal) { 39*a8db15d8Sfdy (0, true, false, false, 0, 0) 40*a8db15d8Sfdy }else{ 41*a8db15d8Sfdy (vl.toInt, villegal, vta, vma, vsew, vlmul) 42*a8db15d8Sfdy } 43*a8db15d8Sfdy } 44*a8db15d8Sfdy 45*a8db15d8Sfdy} 46