add support for Indexed mode in SVSHAPE
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 9 Jul 2022 19:39:53 +0000 (20:39 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 9 Jul 2022 19:39:53 +0000 (20:39 +0100)
src/openpower/decoder/isa/svshape.py

index 4d4cb1d23b99da11a1793a90183cd6266843f538..6f3fc176e8b8f9b5cb2b8e3d9fcde2c79ec083c1 100644 (file)
@@ -1,3 +1,11 @@
+"""provides convenient field mappings for SVSHAPE in different modes
+
+the trickiest is Indexed mode which sits inside Matrix using two of
+permute options to activate.
+
+https://libre-soc.org/openpower/sv/remap
+"""
+
 from openpower.decoder.selectable_int import (FieldSelectableInt, SelectableInt,
                                         selectconcat)
 from openpower.decoder.isa.remapyield import iterate_indices
@@ -29,6 +37,10 @@ class SVSHAPE(SelectableInt):
             log("SVSHAPE setup field", field, offs, end)
             offs = end
 
+    def is_indexed(self):
+        "REMAP Indexed Mode"
+        return self.mode == 0b00 and self.submode2 in [0b110, 0b111]
+
     @property
     def submode2(self):
         return self.fsi['permute'].asint(msb0=True)
@@ -40,6 +52,8 @@ class SVSHAPE(SelectableInt):
     @property
     def order(self):
         permute = self.fsi['permute'].asint(msb0=True)
+        if self.is_indexed():
+            permute -= 0b110 # xyz or yxz
         return SVP64SHAPE.order(permute)
 
     @order.setter
@@ -63,9 +77,16 @@ class SVSHAPE(SelectableInt):
     def ydimsz(self, value):
         self.fsi['ydimsz'].eq(value-1)
 
+    @property
+    def svgpr(self):
+        return self.fsi['zdimsz'].asint(msb0=True) << 1
+
     @property
     def zdimsz(self):
-        return self.fsi['zdimsz'].asint(msb0=True)+1
+        z = self.fsi['zdimsz'].asint(msb0=True)+1
+        if self.is_indexed():
+            z = 1 # no z dimension when indexed
+        return z
 
     @zdimsz.setter
     def zdimsz(self, value):
@@ -84,6 +105,8 @@ class SVSHAPE(SelectableInt):
     @property
     def invxyz(self):
         inv = self.fsi['invxyz'].asint(msb0=True)
+        if self.is_indexed():
+            inv &= 0b011 # no 3rd z in indexed mode
         return [(inv & 0b1), (inv & 0b10) >> 1, (inv & 0b100) >> 2]
 
     @invxyz.setter
@@ -98,8 +121,15 @@ class SVSHAPE(SelectableInt):
     def mode(self, value):
         self.fsi['mode'].eq(value)
 
+    @property
+    def elwid(self):
+        return self.fsi['skip'].asint(msb0=True)
+
     @property
     def skip(self):
+        if self.is_indexed():
+            inv = self.fsi['invxyz'].asint(msb0=True)
+            return (inv & 0b100) >> 2
         return self.fsi['skip'].asint(msb0=True)
 
     @skip.setter