def dpd_to_int(dpd):
    """
    Convert DPD encodined value to int (0-999)
    dpd: DPD encoded value. 10bit unsigned int
    """
    b = [None] * 10
    b[9] = 1 if dpd & 0b1000000000 else 0
    b[8] = 1 if dpd & 0b0100000000 else 0
    b[7] = 1 if dpd & 0b0010000000 else 0
    b[6] = 1 if dpd & 0b0001000000 else 0
    b[5] = 1 if dpd & 0b0000100000 else 0
    b[4] = 1 if dpd & 0b0000010000 else 0
    b[3] = 1 if dpd & 0b0000001000 else 0
    b[2] = 1 if dpd & 0b0000000100 else 0
    b[1] = 1 if dpd & 0b0000000010 else 0
    b[0] = 1 if dpd & 0b0000000001 else 0

    d = [None] * 3
    if b[3] == 0:
        d[2] = b[9] * 4 + b[8] * 2 + b[7]
        d[1] = b[6] * 4 + b[5] * 2 + b[4]
        d[0] = b[2] * 4 + b[1] * 2 + b[0]
    elif (b[3], b[2], b[1]) == (1, 0, 0):
        d[2] = b[9] * 4 + b[8] * 2 + b[7]
        d[1] = b[6] * 4 + b[5] * 2 + b[4]
        d[0] = 8 + b[0]
    elif (b[3], b[2], b[1]) == (1, 0, 1):
        d[2] = b[9] * 4 + b[8] * 2 + b[7]
        d[1] = 8 + b[4]
        d[0] = b[6] * 4 + b[5] * 2 + b[0]
    elif (b[3], b[2], b[1]) == (1, 1, 0):
        d[2] = 8 + b[7]
        d[1] = b[6] * 4 + b[5] * 2 + b[4]
        d[0] = b[9] * 4 + b[8] * 2 + b[0]
    elif (b[6], b[5], b[3], b[2], b[1]) == (0, 0, 1, 1, 1):
        d[2] = 8 + b[7]
        d[1] = 8 + b[4]
        d[0] = b[9] * 4 + b[8] * 2 + b[0]
    elif (b[6], b[5], b[3], b[2], b[1]) == (0, 1, 1, 1, 1):
        d[2] = 8 + b[7]
        d[1] = b[9] * 4 + b[8] * 2 + b[4]
        d[0] = 8 + b[0]
    elif (b[6], b[5], b[3], b[2], b[1]) == (1, 0, 1, 1, 1):
        d[2] = b[9] * 4 + b[8] * 2 + b[7]
        d[1] = 8 + b[4]
        d[0] = 8 + b[0]
    elif (b[6], b[5], b[3], b[2], b[1]) == (1, 1, 1, 1, 1):
        d[2] = 8 + b[7]
        d[1] = 8 + b[4]
        d[0] = 8 + b[0]
    else:
        raise ValueError('Invalid DPD encoding')

    return d[2] * 100 + d[1] * 10 + d[0]