convert from public static functions/properties for regspecs
[soc.git] / src / soc / fu / logical / pipe_data.py
index 27e2a694efd3beb0f8b4f5540c4590deb917208f..40a18bc214a6ac6a6a652238ae9c24570a856c07 100644 (file)
@@ -1,37 +1,44 @@
-from nmigen import Signal, Const
-from ieee754.fpcommon.getop import FPPipeContext
-from soc.fu.pipe_data import IntegerData
+from soc.fu.pipe_data import FUBaseData
 from soc.fu.alu.pipe_data import ALUOutputData, CommonPipeSpec
-from soc.fu.alu.alu_input_record import CompALUOpSubset # TODO: replace
+from soc.fu.logical.logical_input_record import CompLogicalOpSubset
 
 
-class LogicalInputData(IntegerData):
-    regspec = [('INT', 'a', '0:63'),
-               ('INT', 'rb', '0:63'),
-               ('XER', 'xer_so', '32'),
-               ('XER', 'xer_ca', '34,45')]
+# input (and output) for logical initial stage (common input)
+class LogicalInputData(FUBaseData):
+    regspec = [('INT', 'ra', '0:63'), # RA
+               ('INT', 'rb', '0:63'), # RB/immediate
+               ('XER', 'xer_so', '32'),    # bit0: so
+               ]
     def __init__(self, pspec):
-        super().__init__(pspec)
-        self.a = Signal(64, reset_less=True) # RA
-        self.b = Signal(64, reset_less=True) # RB/immediate
-        self.xer_so = Signal(reset_less=True)    # XER bit 32: SO
-        self.xer_ca = Signal(2, reset_less=True) # XER bit 34/45: CA/CA32
-
-    def __iter__(self):
-        yield from super().__iter__()
-        yield self.a
-        yield self.b
-        yield self.xer_ca
-        yield self.xer_so
-
-    def eq(self, i):
-        lst = super().eq(i)
-        return lst + [self.a.eq(i.a), self.b.eq(i.b),
-                      self.xer_ca.eq(i.xer_ca),
-                      self.xer_so.eq(i.xer_so)]
-
-
-# TODO: replace CompALUOpSubset with CompLogicalOpSubset
+        super().__init__(pspec, False)
+        # convenience
+        self.a, self.b = self.ra, self.rb
+
+
+# input to logical final stage (common output)
+class LogicalOutputData(FUBaseData):
+    regspec = [('INT', 'o', '0:63'),        # RT
+               ('CR', 'cr_a', '0:3'),
+               ('XER', 'xer_so', '32'),    # bit0: so
+               ]
+    def __init__(self, pspec):
+        super().__init__(pspec, True)
+        # convenience
+        self.cr0 = self.cr_a
+
+
+# output from logical final stage (common output) - note that XER.so
+# is *not* included (the only reason it's in the input is because of CR0)
+class LogicalOutputDataFinal(FUBaseData):
+    regspec = [('INT', 'o', '0:63'),        # RT
+               ('CR', 'cr_a', '0:3'),
+               ]
+    def __init__(self, pspec):
+        super().__init__(pspec, True)
+        # convenience
+        self.cr0 = self.cr_a
+
+
 class LogicalPipeSpec(CommonPipeSpec):
-    regspec = (LogicalInputData.regspec, ALUOutputData.regspec)
-    opsubsetkls = CompALUOpSubset
+    regspecklses = (LogicalInputData, LogicalOutputDataFinal)
+    opsubsetkls = CompLogicalOpSubset