I want to read bits in 64 bit data put into corresponding bitfields of the Register class, I don't want to use bit array module, is there any traditional approach in python to achieve this.
I researched on this topic i got the following link -- [1]: How to read bits from a file? [bit field read link][1] but it doesn't help, Example code snippet is highly appreciated.Thanks in advance.
class Register(object):
def __init__(self, x):
self.BitField7= 0
self.BitField6= 0
self.BitField5= 0
self.BitField4= 0
self.BitField3= 0
self.BitField2= 0
self.BitField1= 0
self.fieldwidths = (6,12,6,4,12,8,16)
self.field_names=["BitField1","BitField2","BitField3","BitField4","BitField5","BitField6","BitField7"]
obj= Register('0b11011101110111011101110111011101110011001100110011001100110011001011101110111011101110111011101110101010101010101010101010101010') # input is 0xAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD
print obj # should print 0xAAAAAAAABBBBBBBB
Thanks in advance