FPUSubModule.scala 1.2 KB
Newer Older
1
package xiangshan.backend.fu.fpu
L
FPUv0.1  
LinJiawei 已提交
2 3 4

import chisel3._
import chisel3.util._
L
LinJiawei 已提交
5
import xiangshan.{FPUCtrlSignals, XSModule}
6
import xiangshan.backend.fu.{FuConfig, FunctionUnit, HasPipelineReg}
L
FPUv0.1  
LinJiawei 已提交
7 8 9 10 11 12 13

trait HasUIntToSIntHelper {
  implicit class UIntToSIntHelper(x: UInt){
    def toSInt: SInt = Cat(0.U(1.W), x).asSInt()
  }
}

L
LinJiawei 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
abstract class FPUDataModule extends XSModule {
  val io = IO(new Bundle() {
    val in = Input(new Bundle() {
      val src = Vec(3, UInt(65.W))
      val fpCtrl = new FPUCtrlSignals
      val rm = UInt(3.W)
    })
    val out = Output(new Bundle() {
      val data = UInt(65.W)
      val fflags = UInt(5.W)
    })
  })

  val rm = io.in.rm
  val fflags = io.out.fflags
}

31
abstract class FPUSubModule extends FunctionUnit(len = 65)
L
LinJiawei 已提交
32 33 34
  with HasUIntToSIntHelper
{
  val rm = IO(Input(UInt(3.W)))
35
  val fflags = IO(Output(UInt(5.W)))
L
LinJiawei 已提交
36 37 38 39 40 41 42 43
  val dataModule: FPUDataModule
  def connectDataModule = {
    dataModule.io.in.src <> io.in.bits.src
    dataModule.io.in.fpCtrl <> io.in.bits.uop.ctrl.fpu
    dataModule.io.in.rm <> rm
    io.out.bits.data := dataModule.io.out.data
    fflags := dataModule.io.out.fflags
  }
L
LinJiawei 已提交
44
}
45

46 47
abstract class FPUPipelineModule
  extends FPUSubModule
L
LinJiawei 已提交
48
  with HasPipelineReg