sv_binutils: calculate reserved bits
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Sun, 9 Jan 2022 16:17:53 +0000 (16:17 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Sun, 9 Jan 2022 16:36:40 +0000 (16:36 +0000)
src/openpower/sv/sv_binutils.py

index 185d33dccbab815edfcee7d0cf984ed6b82cc452..bd3faa2d7f9cf80d975e0263254425b086caf1a9 100644 (file)
@@ -189,13 +189,18 @@ class Entry:
 
     @classmethod
     def c_decl(cls):
+        bits_all = 0
         yield f"struct svp64_entry {{"
         for field in _dataclasses.fields(cls):
             if issubclass(field.type, Enum):
                 bits = len(field.type).bit_length()
                 yield from indent([f"uint64_t {field.name} : {bits};"])
+                bits_all += bits
             else:
                 yield from indent(field.type.c_var(name=field.name))
+        bits_rsvd = (64 - (bits_all % 64))
+        if bits_rsvd:
+            yield from indent([f"uint64_t : {bits_rsvd};"])
         yield f"}};"
 
     def c_value(self, prefix="", suffix=""):