diff --git a/gateware/sim/util/i2s.py b/gateware/sim/util/i2s.py index ecc3ac3..bda3a78 100644 --- a/gateware/sim/util/i2s.py +++ b/gateware/sim/util/i2s.py @@ -21,13 +21,16 @@ async def i2s_clock_in_u32(bick, sdin): def bits_not(n, width): """Bitwise NOT from positive integer of `width` bits.""" + n = int(n) return (1 << width) - 1 - n def bits_from_signed(n, width): + n = int(n) """Bits (2s complement) of `width` from signed integer.""" return n if n >= 0 else bits_not(-n, width) + 1 def signed_from_bits(n, width): + n = int(n) """Signed integer from (2s complement) bits of `width`.""" if (1 << (width-1) & n) > 0: return -int(bits_not(n, width) + 1)