def test_mux(self): "Defines a truth table for mux" self.assertFalse(mux(zero, zero, zero)) self.assertFalse(mux(zero, zero, one)) self.assertFalse(mux(zero, one, zero)) self.assertTrue(mux(zero, one, one)) self.assertTrue(mux(one, zero, zero)) self.assertFalse(mux(one, zero, one)) self.assertTrue(mux(one, one, zero)) self.assertTrue(mux(one, one, one))
def __call__(self, bit, load, clock): initial_mux = mux(self.value, bit, load) self.value = self.dff(initial_mux, clock) return self.value
def multimux(mult1, mult2, sel): "Takes two Multi instances and a 1-Bit sel and returns m1 if sel = 0 and m2 if sel = 1" a, b = pad_multi(mult1, mult2) return Multi(mux(pair[0], pair[1], sel) for pair in zip(a.value, b.value))