genlib/record: support passing params in same object
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 Oct 2013 20:05:28 +0000 (22:05 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 Oct 2013 20:05:28 +0000 (22:05 +0200)
migen/genlib/record.py

index 10e3a43cf186714954b53a01bf8a6dbce9c4289c..521dcb2c12976a5fb7cd7d5362abf87a4cc73b28 100644 (file)
@@ -56,11 +56,21 @@ def layout_partial(layout, *elements):
                insert_ref.append(layout_get(copy_ref, last))
        return r
 
+class LayoutP:
+       def __init__(self, layout, **layout_dict):
+               self.layout = layout
+               self.layout_dict = layout_dict
+
 class Record:
        def __init__(self, layout, name=None, **layout_dict):
                self.name = get_obj_var_name(name, "")
-               self.layout = layout
-               self.layout_dict = layout_dict
+               if isinstance(layout, LayoutP):
+                       self.layout = layout.layout
+                       self.layout_dict = layout.layout_dict
+                       assert(not layout_dict)
+               else:
+                       self.layout = layout
+                       self.layout_dict = layout_dict
 
                if self.name:
                        prefix = self.name + "_"