From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:12:22 +0000 (+0000) Subject: create pack function X-Git-Tag: ls180-24jan2020~1961 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f907216922d0880430f5a5435a9b86144dfe2a32;p=ieee754fpu.git create pack function --- diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 8a7ef0ea..435fc252 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -169,6 +169,14 @@ class FPADD: with m.If((z.e == z.N126) & (z.m[0:] == 0)): m.d.sync += z.s.eq(0) + def pack(self, m, z, next_state): + m.next = next_state + # if overflow occurs, return inf + with m.If(z.is_overflowed()): + m.d.sync += z.inf(0) + with m.Else(): + m.d.sync += z.create(z.s, z.e, z.m) + def get_fragment(self, platform=None): m = Module() @@ -357,12 +365,7 @@ class FPADD: # pack stage with m.State("pack"): - m.next = "put_z" - # if overflow occurs, return inf - with m.If(z.is_overflowed()): - m.d.sync += z.inf(0) - with m.Else(): - m.d.sync += z.create(z.s, z.e, z.m) + self.pack(m, z, "put_z") # ****** # put_z stage