bit = Bits(8, 12)
left = Bits(16, 0)
right = Bits(16, 8)
bit [ left : right ]
Then in Bits.py line 296, "ones = (1 << nbits) - 1" will raise an error because nbits should be an integer.
The semantics are to capture bit [ 0 : 8 ], but the type of nbits ("nbits = stop - start" in line 284) after this subtraction is still Bits.
I think it is useful to cast nbits to integer here because in some circumstances programmers may get the left and right range from an input port and may forget to cast Bits to integer.
See this code fragment:
Then in Bits.py line 296, "ones = (1 << nbits) - 1" will raise an error because nbits should be an integer.
The semantics are to capture bit [ 0 : 8 ], but the type of nbits ("nbits = stop - start" in line 284) after this subtraction is still Bits.
I think it is useful to cast nbits to integer here because in some circumstances programmers may get the left and right range from an input port and may forget to cast Bits to integer.
Suggestion: nbits = stop - start --> nbits= (int)(stop-start)