Test FPRs that aren't XLEN in size.
authorTim Newsome <tim@sifive.com>
Wed, 27 Dec 2017 23:41:45 +0000 (15:41 -0800)
committerTim Newsome <tim@sifive.com>
Wed, 27 Dec 2017 23:43:02 +0000 (15:43 -0800)
Cover all combinations of 32,64 bit XLEN with F and FD extensions.

Finishes Issue https://github.com/riscv/riscv-openocd/issues/110

debug/gdbserver.py
debug/targets/RISC-V/spike32-2.py
debug/targets/RISC-V/spike32.py
debug/targets/RISC-V/spike64-2.py
debug/targets/RISC-V/spike64.py
debug/testlib.py

index d7092a8aaf62e28ac9b18e5ba909128634fcc20f..8104fedabe3454b54d120beeddd08586d3d0234a 100755 (executable)
@@ -121,6 +121,12 @@ class SimpleF18Test(SimpleRegisterTest):
             self.gdb.stepi()
             assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
             assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - b), .001)
+
+            size = self.gdb.p("sizeof($%s)" % name)
+            if self.hart.extensionSupported('D'):
+                assertEqual(size, 8)
+            else:
+                assertEqual(size, 4)
         else:
             output = self.gdb.p_raw("$" + name)
             assertEqual(output, "void")
index 719009dbcf88437eb646528ed24af6d41a4c5eb8..f57f816afeedaff230cb07aec4507a17c42ca733 100644 (file)
@@ -9,4 +9,4 @@ class spike32_2(targets.Target):
     timeout_sec = 30
 
     def create(self):
-        return testlib.Spike(self)
+        return testlib.Spike(self, isa="RV32IMAFC")
index 809463cb697c065d365eabd6505d4f042ae07c12..dfcfc0134dc26a67dedbc1ee79fd4e0d3d1c38c2 100644 (file)
@@ -15,4 +15,5 @@ class spike32(targets.Target):
     timeout_sec = 30
 
     def create(self):
-        return testlib.Spike(self)
+        # 64-bit FPRs on 32-bit target
+        return testlib.Spike(self, isa="RV32IMAFDC")
index 79aab3e696721e4b59265fbd868a8f2a6c9e545c..a2082b41b7d9e68174267d6b3be79add87f9f1e6 100644 (file)
@@ -9,4 +9,4 @@ class spike64_2(targets.Target):
     timeout_sec = 60
 
     def create(self):
-        return testlib.Spike(self)
+        return testlib.Spike(self, isa="RV64IMAFD")
index 2cd67a5501c85148a97634ed969d76b6ae9aebe8..2aa1dd057ef66a9723f76c201763658604b3b409 100644 (file)
@@ -15,4 +15,5 @@ class spike64(targets.Target):
     timeout_sec = 30
 
     def create(self):
-        return testlib.Spike(self)
+        # 32-bit FPRs only
+        return testlib.Spike(self, isa="RV64IMAFC")
index ce8aecaafbf3369e718e93b100f4276747207224..94ee83e79792e93de50af688068fd276a4974d3b 100644 (file)
@@ -56,10 +56,12 @@ def compile(args, xlen=32): # pylint: disable=redefined-builtin
         raise Exception("Compile failed!")
 
 class Spike(object):
-    def __init__(self, target, halted=False, timeout=None, with_jtag_gdb=True):
+    def __init__(self, target, halted=False, timeout=None, with_jtag_gdb=True,
+            isa=None):
         """Launch spike. Return tuple of its process and the port it's running
         on."""
         self.process = None
+        self.isa = isa
 
         if target.harts:
             harts = target.harts
@@ -109,10 +111,12 @@ class Spike(object):
         assert len(set(t.xlen for t in harts)) == 1, \
                 "All spike harts must have the same XLEN"
 
-        if harts[0].xlen == 32:
-            cmd += ["--isa", "RV32G"]
+        if self.isa:
+            isa = self.isa
         else:
-            cmd += ["--isa", "RV64G"]
+            isa = "RV%dG" % harts[0].xlen
+
+        cmd += ["--isa", isa]
 
         assert len(set(t.ram for t in harts)) == 1, \
                 "All spike harts must have the same RAM layout"