bank/description: pad unaligned multi-word registers at the top
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 May 2012 20:55:23 +0000 (22:55 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 May 2012 20:55:23 +0000 (22:55 +0200)
migen/bank/description.py

index 4c9b5b6d5d7ba79942f142697f5c48a6a0560b3b..01d59017d4884378c2f55f3b2548f0b2e8efa6ac 100644 (file)
@@ -61,6 +61,13 @@ def expand_description(description, busword):
                        for field in reg.fields:
                                size += field.size
                                if size > busword:
+                                       # add padding
+                                       totalsize = sum([field.size for field in reg.fields])
+                                       padding = busword - (totalsize % busword)
+                                       if padding == busword:
+                                               padding = 0
+                                       size += padding
+                                       
                                        top = field.size
                                        while size > busword:
                                                slice1 = busword - size + top