def uint_to_slv(uint, width, allow_undefined=True):
    """
    Convert an unsigned integer to a string of '0' and '1'.

    >>> uint_to_slv(10, width=6)
    '001010'
    >>> uint_to_slv(3, width=3)
    '011'
    """
    if uint is None:
        slv = 'U' * width
        assert allow_undefined
    else:
        bits = []
        for w in range(width):
            bits.append('1' if uint % 2 else '0')
            uint //= 2
        slv = ''.join(reversed(bits))
    return slv
