add SVSTATE SPR sub-field accessor class to ISACaller
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 31 Jan 2021 15:53:19 +0000 (15:53 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 31 Jan 2021 15:53:19 +0000 (15:53 +0000)
src/soc/decoder/isa/caller.py
src/soc/sv/svp64.py

index ad724a113ba21359c455a903c7816b4a0aa79e9e..dfd69339de63f6d44f48f7ee4bc8d9ac2c92a201 100644 (file)
@@ -208,6 +208,21 @@ class PC:
         namespace['NIA'] = self.NIA
 
 
+# Simple-V: see https://libre-soc.org/openpower/sv
+# also soc.sv.svp64 SVP64Rec
+class SVSTATE:
+    def __init__(self, init=0):
+        self.spr = SelectableInt(init, 32)
+        # fields of SVSTATE, see https://libre-soc.org/openpower/sv/sprs/
+        self.mmode = FieldSelectableInt(self.spr, [0])
+        self.mask = FieldSelectableInt(self.spr, tuple(range(1,4)))
+        self.elwidth = FieldSelectableInt(self.spr, tuple(range(4,6)))
+        self.ewsrc = FieldSelectableInt(self.spr, tuple(range(6,8)))
+        self.subvl = FieldSelectableInt(self.spr, tuple(range(8,10)))
+        self.extra = FieldSelectableInt(self.spr, tuple(range(10,19)))
+        self.mode = FieldSelectableInt(self.spr, tuple(range(19,24)))
+
+
 class SPR(dict):
     def __init__(self, dec2, initial_sprs={}):
         self.sd = dec2
@@ -274,6 +289,7 @@ class ISACaller:
     # respect_pc - tracks the program counter.  requires initial_insns
     def __init__(self, decoder2, regfile, initial_sprs=None, initial_cr=0,
                  initial_mem=None, initial_msr=0,
+                 initial_svstate=0,
                  initial_insns=None, respect_pc=False,
                  disassembly=None,
                  initial_pc=0,
@@ -314,6 +330,7 @@ class ISACaller:
         self.mem = Mem(row_bytes=8, initial_mem=initial_mem)
         self.imem = Mem(row_bytes=4, initial_mem=initial_insns)
         self.pc = PC()
+        self.svstate = SVSTATE(initial_svstate)
         self.spr = SPR(decoder2, initial_sprs)
         self.msr = SelectableInt(initial_msr, 64)  # underlying reg
 
index 4926cb112e7be655bd314465bf5c0cec8107218e..5a8be91f072c4191a5b1b10f488548f67eee0c51 100644 (file)
@@ -24,6 +24,7 @@ class SVP64Rec(Record):
                                       ("mask"    , 3),
                                       ("elwidth" , 2),
                                       ("ewsrc"   , 2),
+                                      ("subvl"   , 2),
                                       ("extra"   , 9),
                                       ("mode"    , 5)], name=name)