Skip to content

Commit

Permalink
Add support for no-dFMA units
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Mar 14, 2021
1 parent 62c01f5 commit e7919df
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/main/scala/TopLevelConfigs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class WithSmallPredRF extends Config((site, here, up) => {
case HwachaNPredRFEntries => 128
})

class WithNoDFMA extends Config((site, here, up) => {
case HwachaBuildDFMA => false
})

class ISCA2016Config extends Config(
new Process28nmConfig ++
new WithNBanks(4) ++
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DefaultHwachaConfig extends Config((site, here, up) => {
case HwachaStagesHFMA => 3
case HwachaStagesFConv => 2
case HwachaStagesFCmp => 1
case HwachaBuildDFMA => true

case HwachaNSeqEntries => 8

Expand Down
1 change: 1 addition & 0 deletions src/main/scala/lane.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ case object HwachaStagesSFMA extends Field[Int]
case object HwachaStagesHFMA extends Field[Int]
case object HwachaStagesFConv extends Field[Int]
case object HwachaStagesFCmp extends Field[Int]
case object HwachaBuildDFMA extends Field[Boolean]

abstract trait LaneParameters extends UsesHwachaParameters {
val nSRAM = p(HwachaNSRAMRFEntries)
Expand Down
38 changes: 23 additions & 15 deletions src/main/scala/vfu-fma.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,33 @@ class FMASlice(implicit p: Parameters) extends VXUModule()(p) with Packing {
fn.op_is(FM_MUL) -> Bits(0, SZ_D)
))

val buildDFMA = p(HwachaBuildDFMA)
val buildSFMA = true
val buildHFMA = true
val results =
List((stagesDFMA, SZ_D, FPD, recode_dp _, unpack_d _, ieee_dp _, repack_d _, expand_float_d _, (11, 53)),
(stagesSFMA, SZ_W, FPS, recode_sp _, unpack_w _, ieee_sp _, repack_w _, expand_float_s _, (8, 24)),
(stagesHFMA, SZ_H, FPH, recode_hp _, unpack_h _, ieee_hp _, repack_h _, expand_float_h _, (5, 11))) map {
case (stages, sz, fp, recode, unpack, ieee, repack, expand, (exp, sig)) => {
List((buildDFMA, stagesDFMA, SZ_D, FPD, recode_dp _, unpack_d _, ieee_dp _, repack_d _, expand_float_d _, (11, 53)),
(buildSFMA, stagesSFMA, SZ_W, FPS, recode_sp _, unpack_w _, ieee_sp _, repack_w _, expand_float_s _, (8, 24)),
(buildHFMA, stagesHFMA, SZ_H, FPH, recode_hp _, unpack_h _, ieee_hp _, repack_h _, expand_float_h _, (5, 11))) map {
case (build, stages, sz, fp, recode, unpack, ieee, repack, expand, (exp, sig)) => {
val n = SZ_D / sz
val val_fp = fn.fp_is(fp)
val results = for (i <- (0 until n) if (confprec || i == 0)) yield {
val fma = Module(new freechips.rocketchip.tile.MulAddRecFNPipe(stages min 2, exp, sig))
fma.suggestName("fmaInst")
val valid = pred(i) && val_fp
fma.io.validin := valid
fma.io.op := dgate(valid, fma_op)
fma.io.a := recode(dgate(valid, unpack(fma_multiplicand, i)))
fma.io.b := recode(dgate(valid, unpack(fma_multiplier, i)))
fma.io.c := recode(dgate(valid, unpack(fma_addend, i)))
fma.io.roundingMode := dgate(valid, fn.rm)
val out = Pipe(fma.io.validout, ieee(fma.io.out), (stages - 2) max 0).bits
val exc = Pipe(fma.io.validout, fma.io.exceptionFlags, (stages - 2) max 0).bits
val (out, exc) = if (build) {
val fma = Module(new freechips.rocketchip.tile.MulAddRecFNPipe(stages min 2, exp, sig))
fma.suggestName("fmaInst")
val valid = pred(i) && val_fp
fma.io.validin := valid
fma.io.op := dgate(valid, fma_op)
fma.io.a := recode(dgate(valid, unpack(fma_multiplicand, i)))
fma.io.b := recode(dgate(valid, unpack(fma_multiplier, i)))
fma.io.c := recode(dgate(valid, unpack(fma_addend, i)))
fma.io.roundingMode := dgate(valid, fn.rm)
val out = Pipe(fma.io.validout, ieee(fma.io.out), (stages - 2) max 0).bits
val exc = Pipe(fma.io.validout, fma.io.exceptionFlags, (stages - 2) max 0).bits
(out, exc)
} else {
(0.U, 0.U)
}
(out, exc)
}
val valid = active && val_fp
Expand Down

0 comments on commit e7919df

Please sign in to comment.