Skip to content

Instantly share code, notes, and snippets.

@halferty
Created February 10, 2020 23:38
Show Gist options
  • Save halferty/bd78b5645c10f9e1b1ef2b4bbbd08107 to your computer and use it in GitHub Desktop.
Save halferty/bd78b5645c10f9e1b1ef2b4bbbd08107 to your computer and use it in GitHub Desktop.
Test berkeley-hardfloat fused multiply-add
// Test berkeley-hardfloat fused multiply-add
class Stuff(dut: MulAddRecFN2) extends PeekPokeTester(dut) {
val floatToUInt: (Float) => UInt = (f) => f"h${java.lang.Float.floatToIntBits(1.0f)}%08X".U(32.W)
val a = 3.33f
val b = 2.0f
val c = 1.0f
val expected = a * b + c
poke(dut.io.a, floatToUInt(a))
poke(dut.io.b, floatToUInt(b))
poke(dut.io.c, floatToUInt(c))
poke(dut.io.op, 0.U)
step(100)
expect(dut.io.out, floatToUInt(expected), f"Actual parsed = ${java.lang.Float.intBitsToFloat(peek(dut.io.out).intValue())}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment