From 42f14afa3c098c85dbbe99e9b38f5b890ba142cb Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 22:32:56 +0100 Subject: [PATCH] move FPPackData to separate module --- src/ieee754/fpcommon/pack.py | 28 +-------------------------- src/ieee754/fpcommon/packdata.py | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 src/ieee754/fpcommon/packdata.py diff --git a/src/ieee754/fpcommon/pack.py b/src/ieee754/fpcommon/pack.py index 4f906bd3..d53533b1 100644 --- a/src/ieee754/fpcommon/pack.py +++ b/src/ieee754/fpcommon/pack.py @@ -9,33 +9,7 @@ from nmutil.pipemodbase import PipeModBase from ieee754.fpcommon.fpbase import FPNumBaseRecord, FPNumBase from ieee754.fpcommon.roundz import FPRoundData from ieee754.fpcommon.getop import FPPipeContext - - -class FPPackData: - - def __init__(self, pspec): - width = pspec.width - self.z = Signal(width, reset_less=True) # result - self.ctx = FPPipeContext(pspec) - - # this is complicated: it's a workaround, due to the - # array-indexing not working properly in nmigen. - # self.ports() is used to access the ArrayProxy objects by name, - # however it doesn't work recursively. the workaround: - # drop the sub-objects into *this* scope and they can be - # accessed / set. it's horrible. - self.muxid = self.ctx.muxid - self.op = self.ctx.op - - def eq(self, i): - return [self.z.eq(i.z), self.ctx.eq(i.ctx)] - - def __iter__(self): - yield self.z - yield from self.ctx - - def ports(self): - return list(self) +from ieee754.fpcommon.packdata import FPPackData class FPPackMod(PipeModBase): diff --git a/src/ieee754/fpcommon/packdata.py b/src/ieee754/fpcommon/packdata.py new file mode 100644 index 00000000..40cd7e18 --- /dev/null +++ b/src/ieee754/fpcommon/packdata.py @@ -0,0 +1,33 @@ +# IEEE Floating Point Adder (Single Precision) +# Copyright (C) Jonathan P Dawson 2013 +# 2013-12-12 + +from nmigen import Signal +from ieee754.fpcommon.getop import FPPipeContext + + +class FPPackData: + + def __init__(self, pspec): + width = pspec.width + self.z = Signal(width, reset_less=True) # result + self.ctx = FPPipeContext(pspec) + + # this is complicated: it's a workaround, due to the + # array-indexing not working properly in nmigen. + # self.ports() is used to access the ArrayProxy objects by name, + # however it doesn't work recursively. the workaround: + # drop the sub-objects into *this* scope and they can be + # accessed / set. it's horrible. + self.muxid = self.ctx.muxid + self.op = self.ctx.op + + def eq(self, i): + return [self.z.eq(i.z), self.ctx.eq(i.ctx)] + + def __iter__(self): + yield self.z + yield from self.ctx + + def ports(self): + return list(self) -- 2.30.2