Add test for cmpeqb
authorMichael Nolan <mtnolan2640@gmail.com>
Fri, 15 May 2020 16:33:39 +0000 (12:33 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Fri, 15 May 2020 16:34:09 +0000 (12:34 -0400)
src/soc/decoder/isa/comparefixed.patch
src/soc/decoder/isa/test_caller.py
src/soc/decoder/selectable_int.py

index fb0589415ddcc7cd47cc3b6bd5a894ad1bfefd2a..b80e7be450528ffb96ebc98ba64b27e91f568653 100644 (file)
@@ -1,5 +1,5 @@
---- comparefixed.py.orig       2020-05-07 14:19:47.384535384 -0400
-+++ comparefixed.py    2020-05-07 14:19:11.220806542 -0400
+--- comparefixed.py.orig       2020-05-15 10:02:00.087668937 -0400
++++ comparefixed.py    2020-05-15 12:32:36.834556205 -0400
 @@ -21,7 +21,7 @@
              c = SelectableInt(value=0x2, bits=3)
          else:
@@ -36,7 +36,7 @@
          return (CR,)
  
      @inject()
-@@ -85,10 +85,10 @@
+@@ -85,23 +85,22 @@
          else:
              in_range = le(src21lo, src1) & le(src1, src21hi) | le(src22lo, src1) & le(
                  src1, src22hi)
          return (CR,)
  
      @inject()
-@@ -98,10 +98,10 @@
+-    def op_cmpeqb(self, RB, CR):
+-        src1 = GPR[RA]
+-        src1 = src1[56:64]
++    def op_cmpeqb(self, RA, RB, CR):
++        src1 = RA[56:64]
          match = eq(src1, RB[0:8]) | eq(src1, RB[8:16]) | eq(src1, RB[16:24]) | eq(src1,
              RB[24:32]) | eq(src1, RB[32:40]) | eq(src1, RB[40:48]) | eq(src1, RB[48:56]
              ) | eq(src1, RB[56:64])
          return (CR,)
  
      comparefixed_instrs = {}
+@@ -136,7 +135,7 @@
+                 form='X',
+                 asmregs=[['BF', 'L', 'RA', 'RB']])
+     comparefixed_instrs['cmpeqb'] = instruction_info(func=op_cmpeqb,
+-                read_regs=OrderedSet(['RB']),
++                read_regs=OrderedSet(['RA', 'RB']),
+                 uninit_regs=OrderedSet(), write_regs=OrderedSet(['CR']),
+                 special_regs=OrderedSet(['CR']), op_fields=OrderedSet(['BF']),
+                 form='X',
index f15634722f8f94a46e3d7ce473f34a695a89f2ce..19bff96ace32bb6808007cdab16b60f08566422a 100644 (file)
@@ -264,6 +264,17 @@ class DecoderTestCase(FHDLTestCase):
             sim = self.run_tst_program(program, initial_regs)
             self.assertEqual(sim.gpr(2), SelectableInt(16, 64))
             self.assertEqual(sim.gpr(4), SelectableInt(8, 64))
+
+    def test_cmpeqb(self):
+        lst = ["cmpeqb cr0, 2, 1",
+               "cmpeqb cr1, 3, 1"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x0102030405060708
+        initial_regs[2] = 0x04
+        initial_regs[3] = 0x10
+        with Program(lst) as program:
+            sim = self.run_tst_program(program, initial_regs)
+        
         
 
     def test_mtcrf(self):
index ce7c2ebbb9dc585e25036ba2a62e9fd46fe01fae..e09d85957e345f2fddd74b9460ba4598e53fd76a 100644 (file)
@@ -149,6 +149,8 @@ class FieldSelectableIntTestCase(unittest.TestCase):
 
 class SelectableInt:
     def __init__(self, value, bits):
+        if isinstance(value, SelectableInt):
+            value = value.value
         mask = (1 << bits) - 1
         self.value = value & mask
         self.bits = bits