From 151d216a20045620cb5a3761d1d32788737cb7d9 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 31 Jul 2019 11:04:08 +0100 Subject: [PATCH] convert fcvt to DynamicPipe --- src/ieee754/fcvt/pipeline.py | 22 +++++++++++----------- src/ieee754/pipeline.py | 10 +++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ieee754/fcvt/pipeline.py b/src/ieee754/fcvt/pipeline.py index d8f0db06..cb23a024 100644 --- a/src/ieee754/fcvt/pipeline.py +++ b/src/ieee754/fcvt/pipeline.py @@ -21,10 +21,9 @@ from math import log from ieee754.fpcommon.getop import FPPipeContext -from nmutil.singlepipe import SimpleHandshake, StageChain +from nmutil.singlepipe import StageChain -from ieee754.fpcommon.fpbase import FPState -from ieee754.pipeline import PipelineSpec +from ieee754.pipeline import PipelineSpec, DynamicPipe from ieee754.fcvt.float2int import FPCVTFloatToIntMod from ieee754.fcvt.int2float import FPCVTIntToFloatMod @@ -40,21 +39,22 @@ class SignedOp: return [self.signed.eq(i)] -class FPCVTConvertDeNorm(FPState, SimpleHandshake): +class FPCVTConvertDeNorm(DynamicPipe): """ FPConversion and De-norm """ - def __init__(self, modkls, in_pspec, out_pspec): - FPState.__init__(self, "cvt") + def __init__(self, in_pspec, out_pspec, modkls): + print ("cvtdenorm") sc = modkls(in_pspec, out_pspec) - SimpleHandshake.__init__(self, sc) + in_pspec.stage = sc + super().__init__(in_pspec) self.out = self.ospec(None) class FPCVTFtoIntBasePipe(ControlBase): def __init__(self, modkls, e_extra, in_pspec, out_pspec): ControlBase.__init__(self) - self.pipe1 = FPCVTConvertDeNorm(modkls, in_pspec, out_pspec) + self.pipe1 = FPCVTConvertDeNorm(in_pspec, out_pspec, modkls) #self.pipe2 = FPNormToPack(out_pspec, e_extra=e_extra) #self._eqs = self.connect([self.pipe1, self.pipe2]) @@ -71,7 +71,7 @@ class FPCVTFtoIntBasePipe(ControlBase): class FPCVTBasePipe(ControlBase): def __init__(self, modkls, e_extra, in_pspec, out_pspec): ControlBase.__init__(self) - self.pipe1 = FPCVTConvertDeNorm(modkls, in_pspec, out_pspec) + self.pipe1 = FPCVTConvertDeNorm(in_pspec, out_pspec, modkls) self.pipe2 = FPNormToPack(out_pspec, e_extra=e_extra) self._eqs = self.connect([self.pipe1, self.pipe2]) @@ -99,8 +99,8 @@ class FPCVTMuxInOutBase(ReservationStations): self.op_wid = op_wid self.id_wid = num_bits(num_rows) - self.in_pspec = PipelineSpec(in_width, id_wid, self.op_wid) - self.out_pspec = PipelineSpec(out_width, id_wid, op_wid) + self.in_pspec = PipelineSpec(in_width, self.id_wid, self.op_wid) + self.out_pspec = PipelineSpec(out_width, self.id_wid, op_wid) self.alu = pkls(modkls, e_extra, self.in_pspec, self.out_pspec) ReservationStations.__init__(self, num_rows) diff --git a/src/ieee754/pipeline.py b/src/ieee754/pipeline.py index 9c6866d6..3bd4d9f3 100644 --- a/src/ieee754/pipeline.py +++ b/src/ieee754/pipeline.py @@ -32,6 +32,7 @@ class PipelineSpec: self.op_wid = op_wid self.opkls = opkls self.pipekls = pipekls or SimpleHandshakeRedir + self.stage = None self.core_config = None self.fpformat = None self.n_comb_stages = None @@ -96,7 +97,10 @@ class DynamicPipe(metaclass=Meta): # "self" as the 1st argument (it is its own "Stage"). anything else # could hypothetically be passed through the pspec. class SimpleHandshakeRedir(SimpleHandshake): - def __init__(self, pspec, *args): - print ("redir", pspec, args) - SimpleHandshake.__init__(self, self) + def __init__(self, mod, *args): + print ("redir", mod, args) + stage = self + if args and args[0].stage: + stage = args[0].stage + SimpleHandshake.__init__(self, stage) -- 2.30.2