Skip to content

Commit

Permalink
Merge pull request #3659 from chipsalliance/zvfh
Browse files Browse the repository at this point in the history
Fix support for vector units with Zvfh
  • Loading branch information
sequencer authored Jul 29, 2024
2 parents 4b33216 + 794c5b1 commit 306467d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/main/scala/rocket/RocketCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ case class RocketCoreParams(
override def vLen = vector.map(_.vLen).getOrElse(0)
override def eLen = vector.map(_.eLen).getOrElse(0)
override def vfLen = vector.map(_.vfLen).getOrElse(0)
override def vfh = vector.map(_.vfh).getOrElse(false)
override def vMemDataBits = vector.map(_.vMemDataBits).getOrElse(0)
override val customIsaExt = Option.when(haveCease)("xrocket") // CEASE instruction
override def minFLen: Int = fpu.map(_.minFLen).getOrElse(32)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/rocket/VectorUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ case class RocketCoreVectorParams(
vLen: Int,
eLen: Int,
vfLen: Int,
vfh: Boolean,
vMemDataBits: Int,
decoder: Parameters => RocketVectorDecoder,
useDCache: Boolean,
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/tile/BaseTile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ trait HasNonDiplomaticTileParameters {
}
Seq(s"zve${tileParams.core.eLen}$c")
}
val zvfh = Option.when(tileParams.core.useVector && tileParams.core.vfh) { Seq("zvfh") }

val multiLetterExt = (
// rdcycle[h], rdinstret[h] is implemented
// rdtime[h] is not implemented, and could be provided by software emulation
Expand All @@ -123,8 +125,7 @@ trait HasNonDiplomaticTileParameters {
Option.when(tileParams.core.useConditionalZero)(Seq("zicond")) ++
Some(Seq("zicsr", "zifencei", "zihpm")) ++
Option.when(tileParams.core.fpu.nonEmpty && tileParams.core.fpu.get.fLen >= 16 && tileParams.core.fpu.get.minFLen <= 16)(Seq("zfh")) ++
zvl ++
zve ++
zvl ++ zve ++ zvfh ++
tileParams.core.customIsaExt.map(Seq(_))
).flatten
val multiLetterString = multiLetterExt.mkString("_")
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/tile/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ trait CoreParams {
def vLen: Int = 0
def eLen: Int = 0
def vfLen: Int = 0
def vfh: Boolean = false
def hasV: Boolean = vLen >= 128 && eLen >= 64 && vfLen >= 64
def vMemDataBits: Int = 0
}
Expand Down Expand Up @@ -119,6 +120,7 @@ trait HasCoreParameters extends HasTileParameters {
require(eLen >= 32 && vLen % eLen == 0, s"eLen must divide vLen ($vLen) and be no less than 32")
require(eLen == 32 || eLen == 64)
require(vfLen <= eLen)
require(!coreParams.vfh || (vfLen >= 32 && coreParams.minFLen <= 16))
}

if (coreParams.useVM) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/tile/FPU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,23 @@ class FPToInt(implicit p: Parameters) extends FPUModule()(p) with ShouldBeRetime
dcmp.io.signaling := !in.rm(1)

val tag = in.typeTagOut
val store = (floatTypes.map(t => if (t == FType.H) Fill(maxType.ieeeWidth / minXLen, ieee(in.in1)(15, 0).sextTo(minXLen))
else Fill(maxType.ieeeWidth / t.ieeeWidth, ieee(in.in1)(t.ieeeWidth - 1, 0))): Seq[UInt])(tag)
val toint_ieee = (floatTypes.map(t => if (t == FType.H) Fill(maxType.ieeeWidth / minXLen, ieee(in.in1)(15, 0).sextTo(minXLen))
else Fill(maxType.ieeeWidth / t.ieeeWidth, ieee(in.in1)(t.ieeeWidth - 1, 0))): Seq[UInt])(tag)

val toint = WireDefault(store)
val toint = WireDefault(toint_ieee)
val intType = WireDefault(in.fmt(0))
io.out.bits.store := store
io.out.bits.store := (floatTypes.map(t => Fill(fLen / t.ieeeWidth, ieee(in.in1)(t.ieeeWidth - 1, 0))): Seq[UInt])(tag)
io.out.bits.toint := ((0 until nIntTypes).map(i => toint((minXLen << i) - 1, 0).sextTo(xLen)): Seq[UInt])(intType)
io.out.bits.exc := 0.U

when (in.rm(0)) {
val classify_out = (floatTypes.map(t => t.classify(maxType.unsafeConvert(in.in1, t))): Seq[UInt])(tag)
toint := classify_out | (store >> minXLen << minXLen)
toint := classify_out | (toint_ieee >> minXLen << minXLen)
intType := false.B
}

when (in.wflags) { // feq/flt/fle, fcvt
toint := (~in.rm & Cat(dcmp.io.lt, dcmp.io.eq)).orR | (store >> minXLen << minXLen)
toint := (~in.rm & Cat(dcmp.io.lt, dcmp.io.eq)).orR | (toint_ieee >> minXLen << minXLen)
io.out.bits.exc := dcmp.io.exceptionFlags
intType := false.B

Expand Down

0 comments on commit 306467d

Please sign in to comment.