corelogic/record: add to_signal convenience function
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 11 Feb 2012 19:55:23 +0000 (20:55 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 11 Feb 2012 19:55:23 +0000 (20:55 +0100)
migen/corelogic/record.py

index 4bb1a20a5fbf6ef9e6c6a431a21402db53324d5d..ffebb928de0b430305f51b47934c8923e61667fb 100644 (file)
@@ -94,5 +94,14 @@ class Record:
                else:
                        return l
        
+       def to_signal(self, assignment_list, sig_out, align=False):
+               flattened, length = self.flatten(align, return_offset=True)
+               raw = Signal(BV(length))
+               if sig_out:
+                       assignment_list.append(raw.eq(Cat(*flattened)))
+               else:
+                       assignment_list.append(Cat(*flattened).eq(raw))
+               return raw
+       
        def __repr__(self):
                return repr(self.layout())