# XXX bad practice: use of global variables
from soc.fu.shift_rot.test.test_pipe_caller import get_cu_inputs
from soc.fu.shift_rot.test.test_pipe_caller import ShiftRotTestCase
-from soc.fu.shift_rot.test.test_pipe_caller import test_data
from soc.fu.compunits.compunits import ShiftRotFunctionUnit
from soc.fu.compunits.test.test_compunit import TestRunner
if __name__ == "__main__":
unittest.main(exit=False)
suite = unittest.TestSuite()
- suite.addTest(ShiftRotTestRunner(test_data))
+ suite.addTest(ShiftRotTestRunner(ShiftRotTestCase.test_data))
runner = unittest.TextTestRunner()
runner.run(suite)
print ("extra inputs: CA/32", bin(inp['xer_ca']))
else:
yield alu.p.data_i.xer_ca.eq(0)
-
+
# This test bench is a bit different than is usual. Initially when I
# was writing it, I had all of the tests call a function to create a
# massively. Before, it took around 1 minute on my computer, now it
# takes around 3 seconds
-test_data = []
-
class ShiftRotTestCase(FHDLTestCase):
+ test_data = []
def __init__(self, name):
super().__init__(name)
self.test_name = name
+
def run_tst_program(self, prog, initial_regs=None, initial_sprs=None):
tc = TestCase(prog, self.test_name, initial_regs, initial_sprs)
- test_data.append(tc)
-
+ self.test_data.append(tc)
def test_shift(self):
insns = ["slw", "sld", "srw", "srd", "sraw", "srad"]
print(initial_regs[1], initial_regs[2])
self.run_tst_program(Program(lst), initial_regs)
-
def test_shift_arith(self):
lst = ["sraw 3, 1, 2"]
initial_regs = [0] * 32
fn_unit = yield pdecode2.e.fn_unit
self.assertEqual(fn_unit, Function.SHIFT_ROT.value)
yield from set_alu_inputs(alu, pdecode2, simulator)
- yield
+ yield
opname = code.split(' ')[0]
yield from simulator.call(opname)
index = simulator.pc.CIA.value//4
if __name__ == "__main__":
unittest.main(exit=False)
suite = unittest.TestSuite()
- suite.addTest(TestRunner(test_data))
+ suite.addTest(TestRunner(ShiftRotTestCase.test_data))
runner = unittest.TextTestRunner()
runner.run(suite)