fix signedness of zero fmul results
We were using the FMA unit to compute rs1 * rs2 + 0.0 for fmul, which incorrectly computes +0.0 when rs1 * rs2 == -0.0. Now we add -0.0 if rs1*rs2 is negative.
This commit is contained in:
parent
e3a68848e0
commit
7eb73c325e
@ -390,12 +390,15 @@ class rocketFPUSFMAPipe(latency: Int) extends Component
|
|||||||
io.cmd === FCMD_NMADD || io.cmd === FCMD_NMSUB
|
io.cmd === FCMD_NMADD || io.cmd === FCMD_NMSUB
|
||||||
val cmd_addsub = io.cmd === FCMD_ADD || io.cmd === FCMD_SUB
|
val cmd_addsub = io.cmd === FCMD_ADD || io.cmd === FCMD_SUB
|
||||||
|
|
||||||
|
val one = Bits("h80000000")
|
||||||
|
val zero = Cat(io.in1(32) ^ io.in2(32), Bits(0, 32))
|
||||||
|
|
||||||
when (io.valid) {
|
when (io.valid) {
|
||||||
cmd := Cat(io.cmd(1) & (cmd_fma || cmd_addsub), io.cmd(0))
|
cmd := Cat(io.cmd(1) & (cmd_fma || cmd_addsub), io.cmd(0))
|
||||||
rm := io.rm
|
rm := io.rm
|
||||||
in1 := io.in1
|
in1 := io.in1
|
||||||
in2 := Mux(cmd_addsub, Bits("h80000000"), io.in2)
|
in2 := Mux(cmd_addsub, one, io.in2)
|
||||||
in3 := Mux(cmd_fma, io.in3, Mux(cmd_addsub, io.in2, Bits(0)))
|
in3 := Mux(cmd_fma, io.in3, Mux(cmd_addsub, io.in2, zero))
|
||||||
}
|
}
|
||||||
|
|
||||||
val fma = new hardfloat.mulAddSubRecodedFloat32_1
|
val fma = new hardfloat.mulAddSubRecodedFloat32_1
|
||||||
@ -423,12 +426,15 @@ class rocketFPUDFMAPipe(latency: Int) extends Component
|
|||||||
io.cmd === FCMD_NMADD || io.cmd === FCMD_NMSUB
|
io.cmd === FCMD_NMADD || io.cmd === FCMD_NMSUB
|
||||||
val cmd_addsub = io.cmd === FCMD_ADD || io.cmd === FCMD_SUB
|
val cmd_addsub = io.cmd === FCMD_ADD || io.cmd === FCMD_SUB
|
||||||
|
|
||||||
|
val one = Bits("h8000000000000000")
|
||||||
|
val zero = Cat(io.in1(64) ^ io.in2(64), Bits(0, 64))
|
||||||
|
|
||||||
when (io.valid) {
|
when (io.valid) {
|
||||||
cmd := Cat(io.cmd(1) & (cmd_fma || cmd_addsub), io.cmd(0))
|
cmd := Cat(io.cmd(1) & (cmd_fma || cmd_addsub), io.cmd(0))
|
||||||
rm := io.rm
|
rm := io.rm
|
||||||
in1 := io.in1
|
in1 := io.in1
|
||||||
in2 := Mux(cmd_addsub, Bits("h8000000000000000"), io.in2)
|
in2 := Mux(cmd_addsub, one, io.in2)
|
||||||
in3 := Mux(cmd_fma, io.in3, Mux(cmd_addsub, io.in2, Bits(0)))
|
in3 := Mux(cmd_fma, io.in3, Mux(cmd_addsub, io.in2, zero))
|
||||||
}
|
}
|
||||||
|
|
||||||
val fma = new hardfloat.mulAddSubRecodedFloat64_1
|
val fma = new hardfloat.mulAddSubRecodedFloat64_1
|
||||||
|
Loading…
Reference in New Issue
Block a user