import unittest from migen.fhdl.std import * from migen.genlib.coding import * from migen.test.support import SimCase, SimBench class EncCase(SimCase, unittest.TestCase): class TestBench(SimBench): def __init__(self): self.submodules.dut = Encoder(8) def test_sizes(self): self.assertEqual(flen(self.tb.dut.i), 8) self.assertEqual(flen(self.tb.dut.o), 3) self.assertEqual(flen(self.tb.dut.n), 1) def test_run_sequence(self): seq = list(range(1<<8)) def cb(tb, tbp): if seq: tbp.dut.i = seq.pop(0) if tbp.dut.n: self.assertNotIn(tbp.dut.i, [1< 0: self.assertEqual(i & 1<<(o - 1), 0) self.assertGreaterEqual(i, 1< 0: self.assertEqual(i & 1<<(o - 1), 0) self.assertGreaterEqual(i, 1<