diff --git a/migen/genlib/coding.py b/migen/genlib/coding.py index ed0315576..df89f6cc1 100644 --- a/migen/genlib/coding.py +++ b/migen/genlib/coding.py @@ -26,7 +26,7 @@ class Encoder(Module): """ def __init__(self, width): self.i = Signal(width) # one-hot - self.o = Signal(max=width) # binary + self.o = Signal(max=max(2, width)) # binary self.n = Signal() # invalid: none or multiple act = dict((1< 0: + self.assertEqual(i & 1<<(o - 1), 0) + self.assertGreaterEqual(i, 1<