def format_feature_value(bits, start_bit=0):
    """
    Formats a FASM feature value assignment according to the given bits
    as a string or any iterable yeilding "0" and "1". The iterable must return
    bits starting from LSB and ending on MSB. The yieled bit count determines
    the FASM feature assignment width - there is no padding. Optionally the
    start_bit parameter can be used for offset.
    """
    bits = list(bits)

    count = len(bits)
    value = "".join(bits[::-1])

    if count == 1:
        bitrange = "[{}]".format(start_bit)
    elif count > 1:
        bitrange = "[{}:{}]".format(count - 1 + start_bit, start_bit)
    else:
        assert False, count

    return "{}={}'b{}".format(bitrange, count, value)