Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(IntToFP):Fixed the sign problem of F16 and F32 when converting. #164

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/scala/yunsuan/scalar/IntToFP.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ class IntToFP_postnorm(val expWidth: Int, val precision: Int) extends Module {
val fp_sig = rounder.io.out
val flow = fp_exp>((1<<expWidth)-2).U // underflow or overflow

val final_fp_exp = fp_exp(expWidth-1,0)

nv := false.B
dz := false.B
of := !in_sign && flow
uf := in_sign && flow
nx := flow || ix

io.result := Mux(flow, Mux(rmin, Cat(in_sign, FloatPoint.maxNormExp(expWidth).U(expWidth.W), ~0.U((precision-1).W)),
Cat(in_sign, ~0.U(expWidth.W), 0.U((precision-1).W))), Cat(in_sign, fp_exp, fp_sig))
Cat(in_sign, ~0.U(expWidth.W), 0.U((precision-1).W))), Cat(in_sign, final_fp_exp, fp_sig))
io.fflags := Cat(nv, dz, of, uf, nx)
}

Expand Down
Loading