From: Aleksandar Kostovic Date: Sun, 17 Feb 2019 15:00:29 +0000 (+0100) Subject: Started to translate special cases X-Git-Tag: ls180-24jan2020~1924 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c832b3bb72c5855b2c413ee3abef910a4e6eca45;p=ieee754fpu.git Started to translate special cases --- diff --git a/src/add/fmul.py b/src/add/fmul.py index d41d974b..373f7976 100644 --- a/src/add/fmul.py +++ b/src/add/fmul.py @@ -57,55 +57,30 @@ class FPMUL(FPBase): b.e.eq(b[23:31] - 127), a.s.eq(a[31]), b.s.eq(b[31]) - + ] + + with m.State("special_cases"): + m.next = "normalise_a" + with m.If(a.is_nan() | b.is_nan()): + m.next += "put_z" + m.d.sync += [ + z[31].eq(1), + z[23:31].eq(255), + z[22].eq(1), + z[0:22].eq(0) ] - + with m.Elif(a.e.is_inf()): + m.next += "put_z" + m.d.sync += [ + z[31].eq(a.s ^ b.s), + z[23:31].eq(255), + z[0:22].eq(0) + ] """ -always @(posedge clk) - begin - - case(state) - - get_a: - begin - s_input_a_ack <= 1; - if (s_input_a_ack && input_a_stb) begin - a <= input_a; - s_input_a_ack <= 0; - state <= get_b; - end - end - - get_b: - begin - s_input_b_ack <= 1; - if (s_input_b_ack && input_b_stb) begin - b <= input_b; - s_input_b_ack <= 0; - state <= unpack; - end - end - - unpack: - begin - a_m <= a[22 : 0]; - b_m <= b[22 : 0]; - a_e <= a[30 : 23] - 127; - b_e <= b[30 : 23] - 127; - a_s <= a[31]; - b_s <= b[31]; - state <= special_cases; - end special_cases: begin - //if a is NaN or b is NaN return NaN - if ((a_e == 128 && a_m != 0) || (b_e == 128 && b_m != 0)) begin - z[31] <= 1; - z[30:23] <= 255; - z[22] <= 1; - z[21:0] <= 0; - state <= put_z; + //if a is inf return inf end else if (a_e == 128) begin z[31] <= a_s ^ b_s;