Skip to content

Commit

Permalink
MulPlugin.bufferedHigh added
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Oct 13, 2023
1 parent 9e44c1b commit 8124eb4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/scala/naxriscv/execute/MulPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class MulPlugin(val euId : String,
var splitWidthB : Int = 17,
var sum1WidthMax : Int = -1,
var sum2WidthMax : Int = -1,
var staticLatency : Boolean = true) extends ExecutionUnitElementSimple(euId, staticLatency) {
var staticLatency : Boolean = true,
var bufferedHigh : Boolean = false) extends ExecutionUnitElementSimple(euId, staticLatency) {
import MulPlugin._

override def euWritebackAt = writebackAt
Expand All @@ -46,6 +47,11 @@ class MulPlugin(val euId : String,

getServiceOption[PrivilegedService].foreach(_.addMisa('M'))

if(bufferedHigh) {
eu.setDecodingDefault(HIGH, False)
assert(!staticLatency)
}

add(Rvi.MUL , List(), DecodeList(HIGH -> False, RS1_SIGNED -> True, RS2_SIGNED -> True))
add(Rvi.MULH , List(), DecodeList(HIGH -> True, RS1_SIGNED -> True, RS2_SIGNED -> True))
add(Rvi.MULHSU, List(), DecodeList(HIGH -> True, RS1_SIGNED -> True, RS2_SIGNED -> False))
Expand Down Expand Up @@ -120,7 +126,12 @@ class MulPlugin(val euId : String,

val writeback = new ExecuteArea(writebackAt) {
import stage._
wb.payload := B(HIGH ? stage(MUL_SUM3)(XLEN, XLEN bits) otherwise stage(MUL_SUM3)(0, XLEN bits))
val buffer = bufferedHigh generate new Area{
val valid = RegNext(False) init (False) setWhen (isValid && !isReady && !isRemoved)
val data = RegNext(stage(MUL_SUM3)(XLEN, XLEN bits))
haltIt(HIGH && !valid)
}
wb.payload := B(HIGH ? (if(bufferedHigh) buffer.data else stage(MUL_SUM3)(XLEN, XLEN bits)) otherwise stage(MUL_SUM3)(0, XLEN bits))
}
}

Expand Down

0 comments on commit 8124eb4

Please sign in to comment.