record: return offset
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 10 Jan 2012 16:10:03 +0000 (17:10 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 10 Jan 2012 16:10:03 +0000 (17:10 +0100)
migen/corelogic/record.py

index e2722a9abcd3fa13c8ba2e9f736385787866b007..2bbe47cf8445b55dba6e0ec6e5ed0dc4bdbb671f 100644 (file)
@@ -67,7 +67,7 @@ class Record:
                tpl2 = other.flatten()
                return len(tpl1) == len(tpl2)
        
-       def flatten(self, align=False, offset=0):
+       def flatten(self, align=False, offset=0, return_offset=False):
                l = []
                for key, alignment in self.field_order:
                        if align:
@@ -86,7 +86,10 @@ class Record:
                        for x in added:
                                offset += x.bv.width
                        l += added
-               return l
+               if return_offset:
+                       return (l, offset)
+               else:
+                       return l
        
        def __repr__(self):
                return repr(self.layout())