[libre-riscv-dev] buffered pipeline
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Sun Mar 24 15:20:37 GMT 2019
ok so i now have something like *nine* unique, separate and distinct
ways in which the Stage API can be used.
* single Signal (with an eq function)
* list or tuple of Signals (each with an eq function)
* single class instance (with an eq function that takes care of
attribute assignment)
* mixed list or tuple of Signals and class instances
* a Record
* a hierarchical Record containing Records
and several more.
also, the process() function can receive an object (including a
placeholder object), or a dictionary containing the assignments built
up from the input.
it turns out that a side-effect of python's flexibility is that this works fine:
class FPADDStageIn:
def __init__(self, width, id_wid):
self.a = Signal(width)
self.b = Signal(width)
self.mid = Signal(id_wid, reset_less=True)
class FPADDStageOut:
def __init__(self, width, id_wid):
self.z = Signal(width)
self.mid = Signal(id_wid, reset_less=True)
def eq(self, i):
return [self.z.eq(i.z), self.mid.eq(i.mid)]
class PlaceHolder: pass
class FPAddBaseStage:
def __init__(self, width, id_wid):
self.width = width
self.id_wid = id_wid
def ispec(self):
return FPADDStageIn(self.width, self.id_wid)
def ospec(self):
return FPADDStageOut(self.width, self.id_wid)
def process(self, i):
o = PlaceHolder()
o.z = i.a + i.b
o.mid = i.mid
return o
so where the argument "i" to PlaceHolder is an FPStageIn, and the
specification of the output is of type FPADDStageOut, the
FPADDStageOut.eq function doesn't care that it's been handed a
"PlaceHolder" object, all that it cares about is whether there are
matching "z" and "mid" attributes for it to work with.
this type of "implied APIs" is one of the weird things about python
that takes some getting used to. unlike a static typed language, you
do *not* need to declare a base class, or make a formal "interface".
all you actually need is for the functions and properties (of any
given object being used) to be the same names.
i have however seen that done (creation of classes that were full of
"pass", "pass", "pass"), just as a way to give people something to
"conform" to.
anyway: above is the first attempt at an actual IEEE754 pipeline, i'll
decide whether to add stages to it or to try to do the multi-input
part.
l.
More information about the libre-riscv-dev
mailing list