rename InternalOp to MicrOp
[soc.git] / src / soc / simulator / test_mul_sim.py
1 from nmigen import Module, Signal
2 from nmigen.back.pysim import Simulator, Delay, Settle
3 from nmigen.test.utils import FHDLTestCase
4 import unittest
5 from soc.decoder.power_decoder import (create_pdecode)
6 from soc.decoder.power_enums import (Function, MicrOp,
7 In1Sel, In2Sel, In3Sel,
8 OutSel, RC, LdstLen, CryIn,
9 single_bit_flags, Form, SPR,
10 get_signal_name, get_csv)
11 from soc.decoder.power_decoder2 import (PowerDecode2)
12 from soc.simulator.program import Program
13 from soc.simulator.qemu import run_program
14 from soc.decoder.isa.all import ISA
15 from soc.fu.test.common import TestCase
16 from soc.simulator.test_sim import DecoderBase
17 from soc.config.endian import bigendian
18
19
20
21 class MulTestCases(FHDLTestCase):
22 test_data = []
23
24 def __init__(self, name="div"):
25 super().__init__(name)
26 self.test_name = name
27
28 def tst_mullw(self):
29 lst = ["addi 1, 0, 0x5678",
30 "addi 2, 0, 0x1234",
31 "mullw 3, 1, 2"]
32 self.run_tst_program(Program(lst, bigendian), [3])
33
34 def test_mullwo(self):
35 lst = ["addi 1, 0, 0x5678",
36 "neg 1, 1",
37 "addi 2, 0, 0x1234",
38 "neg 2, 2",
39 "mullwo 3, 1, 2"]
40 self.run_tst_program(Program(lst, bigendian), [3])
41
42 def run_tst_program(self, prog, initial_regs=None, initial_sprs=None,
43 initial_mem=None):
44 initial_regs = [0] * 32
45 tc = TestCase(prog, self.test_name, initial_regs, initial_sprs, 0,
46 initial_mem, 0)
47 self.test_data.append(tc)
48
49
50 class MulDecoderTestCase(DecoderBase, MulTestCases):
51 pass
52
53
54 if __name__ == "__main__":
55 unittest.main()