You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to implement code to extend the UInt[N] class to set a specific bit of UInt[N] type data, but it seems that the setitem argument, self, is given a copy of the UInt[N] data as an argument, so the setitem function I could not set a specific bit of UInt[N] type data. After checking with the following simple code, it seems that the cause is that the address of the A variable and the address of self in setitem are different. Is there a way to use setitem to set bits of data of type UInt[N]?
@extend
class UInt:
def __setitem__(self,Slice,val):
print(f"self of A address:{__ptr__(self)} , Slice:{Slice.start}:{Slice.stop}:{Slice.step} , Set value:{val}")
self = UInt[N](int(val))
A = UInt[64](0)
B = UInt[32](1)
A[0:32] = B
print(f"A address:{__ptr__(A)}, Result:{A}")
self of A address:0x7ffe93eecbe8 , Slice:0:32:None , Set value:1
A address:0x7ffe93eecbb8, Result:0
The text was updated successfully, but these errors were encountered:
I tried to implement code to extend the UInt[N] class to set a specific bit of UInt[N] type data, but it seems that the setitem argument, self, is given a copy of the UInt[N] data as an argument, so the setitem function I could not set a specific bit of UInt[N] type data. After checking with the following simple code, it seems that the cause is that the address of the A variable and the address of self in setitem are different. Is there a way to use setitem to set bits of data of type UInt[N]?
The text was updated successfully, but these errors were encountered: