add in SVSTATE.srcstep update, loop from 0 to VL-1
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 12 Feb 2021 13:18:16 +0000 (13:18 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 12 Feb 2021 13:18:16 +0000 (13:18 +0000)
src/soc/decoder/isa/caller.py
src/soc/decoder/isa/test_caller_svp64.py

index 0a94fff9927db6dfc1e3a708539a80f7fa014030..147761996cec4b3e2ddff9a4ed1f65a050ac44b3 100644 (file)
@@ -977,6 +977,25 @@ class ISACaller:
                     self.gpr[regnum] = output
 
         print("end of call", self.namespace['CIA'], self.namespace['NIA'])
+
+        # check if it is the SVSTATE.src/dest step that needs incrementing
+        # this is our Sub-Program-Counter loop from 0 to VL-1
+        if self.is_svp64_mode:
+            # XXX twin predication TODO
+            vl = self.svstate.vl.asint(msb0=True)
+            mvl = self.svstate.maxvl.asint(msb0=True)
+            srcstep = self.svstate.srcstep.asint(msb0=True)
+            print ("    svstate.vl", vl)
+            print ("    svstate.mvl", mvl)
+            print ("    svstate.srcstep", srcstep)
+            # check if srcstep needs incrementing by one
+            if srcstep != vl-1:
+                self.svstate.srcstep += SelectableInt(1, 7)
+                return # DO NOT allow PC to update whilst Sub-PC loop running
+            # reset to zero
+            self.svstate.srcstep[0:7] = 0
+            print ("    svstate.srcstep loop end (PC to update)")
+
         # UPDATE program counter
         self.pc.update(self.namespace, self.is_svp64_mode)
 
index 1804461558ee0e55b4a2dbcececbecea6f38f9d2..90f2d40996cec8a2a20a3dac569e80ab9557982a 100644 (file)
@@ -17,14 +17,16 @@ from soc.sv.trans.svp64 import SVP64Asm
 class DecoderTestCase(FHDLTestCase):
 
     def test_sv_add(self):
-        isa = SVP64Asm(['sv.add 1, 2, 3'
+        isa = SVP64Asm(['sv.add 1, 5, 9'
                        ])
 
         lst = list(isa)
         print ("listing", lst)
         initial_regs = [0] * 32
-        initial_regs[3] = 0x1234
-        initial_regs[2] = 0x4321
+        initial_regs[9] = 0x1234
+        initial_regs[10] = 0x1111
+        initial_regs[5] = 0x4321
+        initial_regs[6] = 0x2223
         svstate = SVP64State()
         svstate.vl[0:7] = 2 # VL
         svstate.maxvl[0:7] = 2 # MAXVL