Commit e482b043 authored by Michael Büsch's avatar Michael Büsch

AwlOffset: Add bit-offset methods

Signed-off-by: Michael Büsch's avatarMichael Buesch <[email protected]>
parent c79f7531
......@@ -72,6 +72,13 @@ class AwlOffset(DynAttrs): #+cdef
return ((self.byteOffset << 3) & 0x0007FFF8) |\
(self.bitOffset & 0x7)
@classmethod
def fromBitOffset(cls, bitOffset):
return cls(bitOffset // 8, bitOffset % 8)
def toBitOffset(self):
return self.byteOffset * 8 + self.bitOffset
def __add__(self, other):
bitOffset = (self.byteOffset + other.byteOffset) * 8 +\
self.bitOffset + other.bitOffset
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment