From: Michael Nolan Date: Thu, 14 May 2020 15:06:43 +0000 (-0400) Subject: Add OP_CMPB X-Git-Tag: div_pipeline~1234 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d7589886181fb00dcea53b58aa218fd33223c3d;p=soc.git Add OP_CMPB --- diff --git a/src/soc/logical/main_stage.py b/src/soc/logical/main_stage.py index 7b43cf31..426564bb 100644 --- a/src/soc/logical/main_stage.py +++ b/src/soc/logical/main_stage.py @@ -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 ####### diff --git a/src/soc/logical/test/test_pipe_caller.py b/src/soc/logical/test/test_pipe_caller.py index eaed9e74..f93cffd5 100644 --- a/src/soc/logical/test/test_pipe_caller.py +++ b/src/soc/logical/test/test_pipe_caller.py @@ -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()