fhdl: len() for Constant
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 13 Jul 2012 16:16:50 +0000 (18:16 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 13 Jul 2012 16:16:50 +0000 (18:16 +0200)
migen/fhdl/structure.py

index 332f5bf90fa842de876cf8150cb472668ad1e8f1..a0a8da508a1746edf1d3ff40102eab33bba01d89 100644 (file)
@@ -134,6 +134,9 @@ class Constant(Value):
                self.bv = bv or BV(bits_for(n), n < 0)
                self.n = n
        
+       def __len__(self):
+               return self.bv.width
+       
        def __repr__(self):
                return str(self.bv) + str(self.n)