From: Luke Kenneth Casson Leighton Date: Fri, 19 Jun 2020 09:49:20 +0000 (+0100) Subject: add simulator test for divw X-Git-Tag: div_pipeline~322 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e8490764854213aa6c343d86b7f31ba92d54bd0;p=soc.git add simulator test for divw --- diff --git a/src/soc/simulator/test_div_sim.py b/src/soc/simulator/test_div_sim.py new file mode 100644 index 00000000..b84a10c6 --- /dev/null +++ b/src/soc/simulator/test_div_sim.py @@ -0,0 +1,48 @@ +from nmigen import Module, Signal +from nmigen.back.pysim import Simulator, Delay, Settle +from nmigen.test.utils import FHDLTestCase +import unittest +from soc.decoder.power_decoder import (create_pdecode) +from soc.decoder.power_enums import (Function, InternalOp, + In1Sel, In2Sel, In3Sel, + OutSel, RC, LdstLen, CryIn, + single_bit_flags, Form, SPR, + get_signal_name, get_csv) +from soc.decoder.power_decoder2 import (PowerDecode2) +from soc.simulator.program import Program +from soc.simulator.qemu import run_program +from soc.decoder.isa.all import ISA +from soc.fu.test.common import TestCase +from soc.simulator.test_sim import DecoderBase + + + +class DivTestCases(FHDLTestCase): + test_data = [] + + def __init__(self, name="general"): + super().__init__(name) + self.test_name = name + + def test_0_divw(self): + lst = ["addi 1, 0, 0x5678", + "addi 2, 0, 0x1234", + "divw 3, 1, 2", + ] + with Program(lst) as program: + self.run_tst_program(program, [1, 2, 3]) + + def run_tst_program(self, prog, initial_regs=None, initial_sprs=None, + initial_mem=None): + initial_regs = [0] * 32 + tc = TestCase(prog, self.test_name, initial_regs, initial_sprs, 0, + initial_mem, 0) + self.test_data.append(tc) + + +class DecoderTestCase(DecoderBase, DivTestCases): + pass + + +if __name__ == "__main__": + unittest.main()