From: Michael Nolan Date: Fri, 20 Mar 2020 14:07:53 +0000 (-0400) Subject: Add test for rotate/shift instructions X-Git-Tag: div_pipeline~1669 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e00232ddc985177fff17c764996449d15b0a2d88;p=soc.git Add test for rotate/shift instructions --- diff --git a/src/soc/decoder/test/test_decoder_gas.py b/src/soc/decoder/test/test_decoder_gas.py index 9a09f184..f79c81b8 100644 --- a/src/soc/decoder/test/test_decoder_gas.py +++ b/src/soc/decoder/test/test_decoder_gas.py @@ -205,6 +205,57 @@ class CmpRegOp: assert(crsel == self.cr.num) +class RotateOp: + def __init__(self): + self.ops = { + "rlwinm": InternalOp.OP_CMP, + "rlwnm": InternalOp.OP_CMP, + "rlwimi": InternalOp.OP_CMP, + "rlwinm.": InternalOp.OP_CMP, + "rlwnm.": InternalOp.OP_CMP, + "rlwimi.": InternalOp.OP_CMP, + } + self.opcodestr = random.choice(list(self.ops.keys())) + self.opcode = self.ops[self.opcodestr] + self.r1 = Register(random.randrange(32)) + self.r2 = Register(random.randrange(32)) + self.shift = random.randrange(32) + self.mb = random.randrange(32) + self.me = random.randrange(32) + + def generate_instruction(self): + string = "{} {},{},{},{},{}\n".format(self.opcodestr, + self.r1.num, + self.r2.num, + self.shift, + self.mb, + self.me) + return string + + def check_results(self, pdecode2): + r1sel = yield pdecode2.e.write_reg.data + r2sel = yield pdecode2.e.read_reg3.data + dec = pdecode2.dec + + if "i" in self.opcodestr: + shift = yield dec.SH[0:-1] + else: + shift = yield pdecode2.e.read_reg2.data + mb = yield dec.MB[0:-1] + me = yield dec.ME[0:-1] + + assert(r1sel == self.r1.num) + assert(r2sel == self.r2.num) + assert(shift == self.shift) + assert(mb == self.mb) + assert(me == self.me) + + rc = yield pdecode2.e.rc.data + if '.' in self.opcodestr: + assert(rc == 1) + else: + assert(rc == 0) + class DecoderTestCase(FHDLTestCase): @@ -270,6 +321,8 @@ class DecoderTestCase(FHDLTestCase): def test_cmp_reg(self): self.run_tst(CmpRegOp, "cmp_reg") + def test_rot(self): + self.run_tst(RotateOp, "rot") if __name__ == "__main__": unittest.main()