adapt botchify so it can be used for 31- or 15- etc. etc.
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 16 Feb 2021 16:33:22 +0000 (16:33 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 16 Feb 2021 16:35:33 +0000 (16:35 +0000)
src/soc/consts.py

index 25ce875883082f697776e52fade4b4989fa75dcd..0482125b1add8ae6e6d729b25a60156446595fe9 100644 (file)
@@ -1,9 +1,9 @@
 # sigh create little-ended versions of bitfield flags
-def botchify(bekls, lekls):
+def botchify(bekls, lekls, msb=63):
     for attr in dir(bekls):
         if attr[0] == '_':
             continue
-        setattr(lekls, attr, 63-getattr(bekls, attr))
+        setattr(lekls, attr, msb-getattr(bekls, attr))
 
 
 # Can't think of a better place to put these functions.