Skip to content

Commit

Permalink
[rtl] fix decode in MulDiv.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li committed Aug 19, 2024
1 parent 5f3417d commit b83db43
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
15 changes: 12 additions & 3 deletions elaborator/src/rocketv/MulDiv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package org.chipsalliance.t1.elaborator.rocketv

import mainargs._
import org.chipsalliance.rocketv.{MulDiv, MulDivParameter}
import org.chipsalliance.rocketv.{DecoderParameter, MulDiv, MulDivParameter}
import org.chipsalliance.t1.elaborator.Elaborator

object MulDiv extends Elaborator {
Expand All @@ -16,7 +16,15 @@ object MulDiv extends Elaborator {
@arg(name = "divEarlyOut") divEarlyOut: Boolean,
@arg(name = "divEarlyOutGranularity") divEarlyOutGranularity: Int,
@arg(name = "mulUnroll") mulUnroll: Int,
@arg(name = "mulEarlyOut") mulEarlyOut: Boolean) {
@arg(name = "mulEarlyOut") mulEarlyOut: Boolean,
@arg(name = "instructionSets") instructionSets: Set[String],
@arg(name = "pipelinedMul") pipelinedMul: Boolean,
@arg(name = "fenceIFlushDCache") fenceIFlushDCache: Boolean) {
def decodeParam: DecoderParameter = DecoderParameter(
instructionSets,
pipelinedMul,
fenceIFlushDCache
)
def convert: MulDivParameter = MulDivParameter(
useAsyncReset,
latency,
Expand All @@ -25,7 +33,8 @@ object MulDiv extends Elaborator {
divEarlyOut,
divEarlyOutGranularity,
mulUnroll,
mulEarlyOut
mulEarlyOut,
decodeParam
)
}

Expand Down
21 changes: 11 additions & 10 deletions rocketv/src/MulDiv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ case class MulDivParameter(useAsyncReset: Boolean,
divEarlyOut: Boolean,
divEarlyOutGranularity: Int,
mulUnroll: Int,
mulEarlyOut: Boolean)
mulEarlyOut: Boolean,
decoderParameter: DecoderParameter)
extends SerializableModuleParameter {
// optional to 16 when rve?
val nXpr: Int = 32
val uopWidth: Int = 4

def FN_MUL = 1.U(4.W)
def FN_MULH = 2.U(4.W)
def FN_MULHU = 3.U(4.W)
def FN_MULHSU = 4.U(4.W)
def FN_DIV = 4.U(4.W)
def FN_REM = 5.U(4.W)
def FN_DIVU = 6.U(4.W)
def FN_REMU = 7.U(4.W)
def FN_MUL = decoderParameter.UOPALU.mul
def FN_MULH = decoderParameter.UOPALU.mulh
def FN_MULHU = decoderParameter.UOPALU.mulhu
def FN_MULHSU = decoderParameter.UOPALU.mulhsu
def FN_DIV = decoderParameter.UOPALU.div
def FN_REM = decoderParameter.UOPALU.rem
def FN_DIVU = decoderParameter.UOPALU.divu
def FN_REMU = decoderParameter.UOPALU.remu
def DW_32 = false.B
}
class MulDivInterface(parameter: MulDivParameter) extends Bundle {
Expand Down Expand Up @@ -62,7 +63,7 @@ class MulDiv(val parameter: MulDivParameter)
}

def N = BitPat.N()
def Y = BitPat.N()
def Y = BitPat.Y()
def X = BitPat.dontCare(1)

val w = io.req.bits.in1.getWidth
Expand Down
4 changes: 3 additions & 1 deletion rocketv/src/RocketCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ case class RocketParameter(
divEarlyOut: Boolean,
divEarlyOutGranularity: Int,
mulUnroll: Int,
mulEarlyOut: Boolean)
mulEarlyOut: Boolean,
decoderParameter: DecoderParameter
)
val mulParameter: Option[PipelinedMultiplierParameter] = Option.when(usingMulDiv && mulUnroll == xLen)(PipelinedMultiplierParameter(
useAsyncReset: Boolean,
2,
Expand Down

0 comments on commit b83db43

Please sign in to comment.