def repack_source_required(src_width, to_width, length, *,  # noqa: N805
                               start_bit=0):
        """Calculates how many source words would be read for an invocation of
        repack with a given length, including possible partial words at
        the beginning and the end of the repack source.  This can be called
        either on a concrete BinArray instance (assuming its width as the
        source width), or on the BinArray class (providing the source width
        as an extra first argument).  This function doesn't take ``start``
        or ``msb_first`` parameters, since they wouldn't affect the
        computation.
        """
        if isinstance(src_width, BinArray):
            src_width = src_width._width
        src_width = operator.index(src_width)
        to_width = operator.index(to_width)
        length = operator.index(length)
        start_bit = operator.index(start_bit)
        if src_width <= 0:
            raise ValueError('source width must be positive')
        if to_width <= 0:
            raise ValueError('destination width must be positive')
        if length < 0:
            raise ValueError('length must not be negative')
        if start_bit not in range(src_width):
            raise ValueError('start bit must be in [0, src_width)')
        return BinInt(start_bit + to_width * length).ceildiv(src_width)