Add OP_CMPB
authorMichael Nolan <mtnolan2640@gmail.com>
Thu, 14 May 2020 15:06:43 +0000 (11:06 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Thu, 14 May 2020 15:07:00 +0000 (11:07 -0400)
src/soc/logical/main_stage.py
src/soc/logical/test/test_pipe_caller.py

index 7b43cf3112510821defa46969a266f3c65aa0dcd..426564bb39cff65eb8a48152f1fc0f70644fe5dc 100644 (file)
@@ -37,12 +37,19 @@ class LogicalMainStage(PipeModBase):
                 comb += self.o.o.eq(self.i.a | self.i.b)
             with m.Case(InternalOp.OP_XOR):
                 comb += self.o.o.eq(self.i.a ^ self.i.b)
+            ###### cmpb #######
+            with m.Case(InternalOp.OP_CMPB):
+                for i in range(8):
+                    slc = slice(i*8, (i+1)*8)
+                    with m.If(self.i.a[slc] == self.i.b[slc]):
+                        comb += self.o.o[slc].eq(Repl(1, 8))
+                    with m.Else():
+                        comb += self.o.o[slc].eq(Repl(0, 8))
+
             ###### popcount #######
             # TODO with m.Case(InternalOp.OP_POPCNT):
             ###### parity #######
             # TODO with m.Case(InternalOp.OP_PRTY):
-            ###### cmpb #######
-            # TODO with m.Case(InternalOp.OP_CMPB):
             ###### cntlz #######
             # TODO with m.Case(InternalOp.OP_CNTZ):
             ###### bpermd #######
index eaed9e743b38e3752e418394b2f355d59443b7a2..f93cffd5de5f911a6b02654413a8fc023aeb3fa2 100644 (file)
@@ -122,7 +122,14 @@ class LogicalTestCase(FHDLTestCase):
             initial_regs = [0] * 32
             initial_regs[1] = random.randint(0, (1<<64)-1)
             self.run_tst_program(Program(lst), initial_regs)
-        
+
+    def test_cmpb(self):
+        lst = ["cmpb 3, 1, 2"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0xdeadbeefcafec0de
+        initial_regs[2] = 0xd0adb0000afec1de
+        self.run_tst_program(Program(lst), initial_regs)
+
     def test_ilang(self):
         rec = CompALUOpSubset()