1 # A.3 Round to Float conversion
3 <!-- Power ISA Book I Version 3.0B Section A.3 page 782 -->
5 def Round_Float( tgt_precision, sign, exp, frac, round_mode ):
7 if tgt_precision = "single-precision" then
11 xbit <- frac[26:63] > 0
12 else # tgt_precision = "double-precision"
16 xbit <= frac[55:63] > 0
18 if round_mode = 0b00 then # Round to Nearest
19 if lsb = 1 and gbit = 1 then inc <- 1
20 if lsb = 0 and gbit = 1 and rbit = 1 then inc <- 1
21 if lsb = 0 and gbit = 1 and xbit = 1 then inc <- 1
23 if round_mode = 0b10 then # Round toward + Infinity
24 if sign = 0 and gbit = 1 then inc <-1
25 if sign = 0 and rbit = 1 then inc <-1
26 if sign = 0 and xbit = 1 then inc <-1
28 if round_mode = 0b11 then # Round toward - Infinity
29 if sign = 1 and gbit = 1 then inc <-1
30 if sign = 1 and rbit = 1 then inc <-1
31 if sign = 1 and xbit = 1 then inc <-1
33 if tgt_precision = "single-precision" then
34 frac[0:23] <- frac[0:23] + inc
35 else # tgt_precision = "double-precision"
36 frac[0:52] <- frac[0:52] + inc
37 if carry_out = 1 then exp <- exp + 1
39 FPSCR[FI] <- gbit | rbit | xbit
40 FPSCR[XX] <- FPSCR[XX] | FPSCR[FI]