[libre-riscv-dev] big cleanup / reorg

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Jul 31 14:31:51 BST 2019

this is now what FPNormToPack looks like.  real obvious.  no
unnecessary crufy.  four combinatorial modules are clearly and
obviously chained together.  including the imports and copyright
notice the file is 29 lines long.

class FPNormToPack(FPModBaseChain):

    def __init__(self, pspec, e_extra=False):
        self.e_extra = e_extra

    def get_chain(self):
        """ gets chain of modules
        # Normalisation, Rounding Corrections, Pack - in a chain
        nmod = FPNorm1ModSingle(self.pspec, e_extra=self.e_extra)
        rmod = FPRoundMod(self.pspec)
        cmod = FPCorrectionsMod(self.pspec)
        pmod = FPPackMod(self.pspec)

        return [nmod, rmod, cmod, pmod]

On Wed, Jul 31, 2019 at 1:55 PM Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
> i did a tidyup today including putting heavily commonly used
> (identical) code into two key strategic modules: FPModBase and
> FPModBaseChain.
> FPModBase sets up self.i and self.o from ispec and ospec, and the
> setup and process functions are absolutely cookie-cut identical across
> literally every single FP module... so those go into a FPModBase,
> which is now the default base class for pretty much absolutely every
> FP module.
> bear in mind that those are all *combinatorial* modules.
> FPModBaseChain now contains the code that creates *pipelines* from
> those combinatorial modules, and so derives from the (new)
> DynamicPipe.  the *only* place now where DynamicPipe is used is:
> FPModBaseChain.
> all of the manual (near-duplicated) code that was formerly in setup()
> has now gone, replaced with get_chain() which must return the chain of
> *combinatorial* blocks that are to have the "data handling" - pipeline
> registers - wrapped around them.
> importantly: rather than be forced to declare the ispec and ospec, the
> new FPModBaseChain returns the ispec and ospec of the *start and end
> of the chain*.  this saves a lot of messing about.
> right across the board these two cut out a huge amount of duplicated
> cookie-cut identical code.
> i've also started removing a lot of the FSM code that wasn't really
> being used / maintained, as there is still the (original) jon dawson
> code that does pretty much the same job, is smaller, and easier to
> read.
> l.

More information about the libre-riscv-dev mailing list