From a0240621f181ecc46c2e13cbe9a018a822010376 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 23 Jul 2019 10:05:50 +0100 Subject: [PATCH] reorganise loop --- src/ieee754/fpdiv/pipeline.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/ieee754/fpdiv/pipeline.py b/src/ieee754/fpdiv/pipeline.py index c11dbf1a..cf2a04c2 100644 --- a/src/ieee754/fpdiv/pipeline.py +++ b/src/ieee754/fpdiv/pipeline.py @@ -81,35 +81,34 @@ class FPDIVBasePipe(ControlBase): ControlBase.__init__(self) pipechain = [] - max_n_comb_stages = 2 # TODO (depends on how many RS's we want) + n_comb_stages = 3 # TODO (depends on how many RS's we want) # to which the answer: "as few as possible" # is required. too many ReservationStations # means "big problems". - # XXX BUG - subtracting 4 from number of stages stops assert - # probably related to having to add 4 in FPDivMuxInOut - radix = pspec.log2_radix - n_stages = pspec.core_config.n_stages // max_n_comb_stages - print ("n_stages", pspec.core_config.n_stages, n_stages) + # get number of stages, set up loop. + n_stages = pspec.core_config.n_stages + print ("n_stages", n_stages) stage_idx = 0 - for i in range(n_stages): + end = False + while not end: - n_comb_stages = max_n_comb_stages # needs to convert input from pipestart ospec - if i == 0: - kls = FPDivStagesSetup - #n_comb_stages -= 1 # reduce due to work done at start? + if stage_idx == 0: + kls = FPDivStagesSetup # does n_comb_stages-1 calcs as well # needs to convert output to pipeend ispec - elif i == n_stages - 1: - kls = FPDivStagesFinal - #n_comb_stages -= 1 # FIXME - reduce due to work done at end? + elif stage_idx + n_comb_stages >= n_stages: + kls = FPDivStagesFinal # does n_comb_stages-1 calcs as well + end = True + n_comb_stages = n_stages - stage_idx # intermediary stage else: - kls = FPDivStagesIntermediate + kls = FPDivStagesIntermediate # does n_comb_stages calcs + # create (in each pipe) a StageChain n_comb_stages in length pipechain.append(kls(self.pspec, n_comb_stages, stage_idx)) stage_idx += n_comb_stages # increment so that each CalcStage # gets a (correct) unique index -- 2.30.2