bank/description/Register: add get_size
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 25 Mar 2013 13:43:44 +0000 (14:43 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 25 Mar 2013 13:43:44 +0000 (14:43 +0100)
migen/bank/description.py

index 3b9846db8279613e12f20cf050cbe40437c8b6db..160f2fb4620a5364739041126c9a9f051a4bb614 100644 (file)
@@ -19,6 +19,9 @@ class RegisterRaw(_Register):
                self.r = Signal(self.size)
                self.w = Signal(self.size)
 
+       def get_size(self):
+               return self.size
+
 (READ_ONLY, WRITE_ONLY, READ_WRITE) = range(3)
 
 class Field:
@@ -45,6 +48,9 @@ class RegisterFields(_Register):
                _Register.__init__(self, name)
                self.fields = fields
 
+       def get_size(self):
+               return sum(field.size for field in self.fields)
+
 class RegisterField(RegisterFields):
        def __init__(self, size=1, access_bus=READ_WRITE, access_dev=READ_ONLY, reset=0, atomic_write=False, name=None):
                self.field = Field(size, access_bus, access_dev, reset, atomic_write, name="")