allow pspec to specify the class of FPPipeContext.op
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Jul 2019 16:16:05 +0000 (17:16 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Jul 2019 16:16:05 +0000 (17:16 +0100)
src/ieee754/fpcommon/getop.py

index fbdee3e8ce91d8c55ea6db6a8724fa17406f853b..8f580c1fd7b5f959310bb64511fab82f73ba4c59 100644 (file)
@@ -85,11 +85,20 @@ class FPNumBase2Ops:
 class FPPipeContext:
 
     def __init__(self, pspec):
-        print (pspec)
+        """ creates a pipeline context.  currently: operator (op) and muxid
+
+            opkls (within pspec) - the class to create that will be the
+                                   "operator". instance must have an "eq"
+                                   function.
+        """
         self.id_wid = pspec['id_wid']
         self.op_wid = pspec.get('op_wid', 0)
         self.muxid = Signal(self.id_wid, reset_less=True)   # RS multiplex ID
-        self.op = Signal(self.op_wid, reset_less=True)
+        opkls = pspec.get('opkls', None)
+        if opkls is None:
+            self.op = Signal(self.op_wid, reset_less=True)
+        else:
+            self.op = opkls(pspec)
 
     def eq(self, i):
         ret = [self.muxid.eq(i.muxid)]