try making CR bitrange 32..63 not 0..31
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 7 Apr 2020 18:46:03 +0000 (19:46 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 7 Apr 2020 18:46:03 +0000 (19:46 +0100)
src/soc/decoder/isa/caller.py
src/soc/decoder/power_fields.py
src/soc/decoder/selectable_int.py

index deb30fc73fa57b3bf6537a36077f01316331becc..81a294d28be962b7745d67e3f590c71f5d1e2ffb 100644 (file)
@@ -148,7 +148,8 @@ class ISACaller:
         # 3.2.3 p46 p232 VRSAVE (actually SPR #256)
 
         # create CR then allow portions of it to be "selectable" (below)
-        self.cr = SelectableInt(0, 32) # TODO, must be bits range 32-63 not 0-31
+        self._cr = SelectableInt(0, 64) # underlying reg
+        self.cr = FieldSelectableInt(self._cr, list(range(32,64)))
 
         # "undefined", just set to variable-bit-width int (use exts "max")
         self.undefined = SelectableInt(0, 256) # TODO, not hard-code 256!
index 4e7bee0951ed6263265cb010a2935a72c75c18c6..9dc07b8ea554092b4228cc45f898c02646546744 100644 (file)
@@ -10,7 +10,7 @@ class BitRange(OrderedDict):
         if isinstance(subscript, slice):
             return list(self)[subscript]
         else:
-            return self[subscript]
+            return OrderedDict.__getitem__(self, subscript)
 
 
 def decode_instructions(form):
index 78cccc299e4f7b4c21e5e7f6be5ef399e55ef457..c4698c014c3df71382f2c539c940f6fcc47c11d7 100644 (file)
@@ -5,6 +5,8 @@ from operator import (add, sub, mul, truediv, mod, or_, and_, xor, neg, inv)
 
 
 def check_extsign(a, b):
+    if isinstance(b, FieldSelectableInt):
+        b = b.get_range()
     if b.bits != 256:
         return b
     return SelectableInt(b.value, a.bits)
@@ -23,8 +25,12 @@ class FieldSelectableInt:
         self.br = br # map of indices.
 
     def eq(self, b):
-        self.si = copy(b.si)
-        self.br = copy(b.br)
+        if isinstance(b, SelectableInt):
+            for i in range(b.bits):
+                self[i] = b[i]
+        else:
+            self.si = copy(b.si)
+            self.br = copy(b.br)
 
     def _op(self, op, b):
         vi = self.get_range()
@@ -37,12 +43,13 @@ class FieldSelectableInt:
         return self.merge(vi)
 
     def __getitem__(self, key):
+        print ("getitem", key, self.br)
         key = self.br[key] # don't do POWER 1.3.4 bit-inversion
         return self.si[key]
 
     def __setitem__(self, key, value):
         key = self.br[key] # don't do POWER 1.3.4 bit-inversion
-        return self.si__setitem__(key, value)
+        return self.si.__setitem__(key, value)
 
     def __negate__(self):
         return self._op1(negate)