From f907216922d0880430f5a5435a9b86144dfe2a32 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 16 Feb 2019 09:12:22 +0000 Subject: [PATCH] create pack function --- src/add/nmigen_add_experiment.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 -- 2.30.2