add option to add exception type to FUBaseData (pipe_data)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 4 May 2021 12:31:35 +0000 (13:31 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 4 May 2021 12:31:35 +0000 (13:31 +0100)
src/soc/fu/pipe_data.py

index 1f780336f3f75018136a10ffa68f65f011519147..ca67fd1b4d338100daf80fb18febaa15746c3ff3 100644 (file)
@@ -16,11 +16,13 @@ class FUBaseData:
     pipeline *to* output) must have it set to "True".
     """
 
-    def __init__(self, pspec, output):
+    def __init__(self, pspec, output, exc_kls=None):
         self.ctx = PipeContext(pspec) # context for ReservationStation usage
         self.muxid = self.ctx.muxid
         self.data = []
         self.is_output = output
+        # take regspec and create data attributes (in or out)
+        # TODO: use widspec to create reduced bit mapping.
         for i, (regfile, regname, widspec) in enumerate(self.regspec):
             wid = get_regspec_bitwidth([self.regspec], 0, i)
             if output:
@@ -29,6 +31,11 @@ class FUBaseData:
                 sig = Signal(wid, name=regname, reset_less=True)
             setattr(self, regname, sig)
             self.data.append(sig)
+        # optional exception type
+        if exc_kls is not None:
+            name = "exc_o" if output else "exc_i"
+            self.exception = exc_kls(name=name)
+            self.data.append(self.exception)
 
     def __iter__(self):
         yield from self.ctx