fpu zero/nan wip
This commit is contained in:
parent
ac5844f393
commit
ccd13b7e9e
|
@ -628,12 +628,20 @@ case class FpuCore( portCount : Int, p : FpuParameter) extends Component{
|
||||||
val norm = new Area{
|
val norm = new Area{
|
||||||
def xyExponent = math.xyExponent
|
def xyExponent = math.xyExponent
|
||||||
def xyMantissa = math.xyMantissa
|
def xyMantissa = math.xyMantissa
|
||||||
def xySign = math.xySign
|
val xySign = CombInit(math.xySign)
|
||||||
|
|
||||||
val shiftOh = OHMasking.first(xyMantissa.asBools.reverse)
|
val shiftOh = OHMasking.first(xyMantissa.asBools.reverse)
|
||||||
val shift = OHToUInt(shiftOh)
|
val shift = OHToUInt(shiftOh)
|
||||||
val mantissa = (xyMantissa |<< shift) >> 1
|
val mantissa = (xyMantissa |<< shift) >> 1
|
||||||
val exponent = xyExponent - shift + 1
|
val exponent = xyExponent - shift + 1
|
||||||
|
val forceZero = xyMantissa === 0
|
||||||
|
val forceOverflow = exponent === exponent.maxValue
|
||||||
|
val forceNan =
|
||||||
|
// val
|
||||||
|
when(forceZero){ //TODO
|
||||||
|
exponent := 0
|
||||||
|
xySign := False
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -304,6 +304,7 @@ class FpuTest extends FunSuite{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def checkFloat(ref : Float, dut : Float): Boolean ={
|
def checkFloat(ref : Float, dut : Float): Boolean ={
|
||||||
|
if(ref === dut) return true
|
||||||
ref.abs * 1.0001 > dut.abs && ref.abs * 0.9999 < dut.abs && ref.signum == dut.signum
|
ref.abs * 1.0001 > dut.abs && ref.abs * 0.9999 < dut.abs && ref.signum == dut.signum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,6 +492,13 @@ class FpuTest extends FunSuite{
|
||||||
val b2f = lang.Float.intBitsToFloat(_)
|
val b2f = lang.Float.intBitsToFloat(_)
|
||||||
|
|
||||||
|
|
||||||
|
testAdd(1.2f, -1.2f)
|
||||||
|
testAdd(-1.2f, 1.2f)
|
||||||
|
testAdd(0.0f, -1.2f)
|
||||||
|
testAdd(-0.0f, -1.2f)
|
||||||
|
testAdd(1.2f, -0f)
|
||||||
|
testAdd(1.2f, 0f)
|
||||||
|
|
||||||
testFmv_x_w(1.246f)
|
testFmv_x_w(1.246f)
|
||||||
testFmv_w_x(lang.Float.floatToIntBits(7.234f))
|
testFmv_w_x(lang.Float.floatToIntBits(7.234f))
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,11 @@ object MiaouSqrt extends App{
|
||||||
println(output)
|
println(output)
|
||||||
println(s"ref ${Math.sqrt(input)}")
|
println(s"ref ${Math.sqrt(input)}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object MiaouNan extends App{
|
||||||
|
println(Float.NaN + 3.0f)
|
||||||
|
println(3.0f + Float.NaN )
|
||||||
|
println(0.0f*Float.PositiveInfinity )
|
||||||
|
println(1.0f/0.0f )
|
||||||
|
}
|
Loading…
Reference in New Issue