B.1 BCD-to-DPD Translation; B.2 DPD-to-BCD Translation

The following describes conversions between 3-digit BCD and 10-bit DPD formats.

def BCD_TO_DPD( BCD ):
    a <- BCD[0]
    b <- BCD[1]
    c <- BCD[2]
    d <- BCD[3]
    e <- BCD[4]
    f <- BCD[5]
    g <- BCD[6]
    h <- BCD[7]
    i <- BCD[8]
    j <- BCD[9]
    k <- BCD[10]
    m <- BCD[11]

    p <- ((f & a & i & ¬e) | (j & a & ¬i) | (b & ¬a))
    q <- ((g & a & i & ¬e) | (k & a & ¬i) | (c & ¬a))
    r <- d

    s <- ((j & ¬a & e & ¬i) | (f & ¬i & ¬e) |
        (f & ¬a & ¬e) | (e & i))
    t <- ((k & ¬a & e & ¬i) | (g & ¬i & ¬e) |
        (g & ¬a & ¬e) | (a & i))

    u <- h

    v <- (a | e | i)

    w <- ((¬e & j & ¬i) | (e & i) | a)
    x <- ((¬a & k & ¬i) | (a & i) | e)
    y <- m

    return (p || q || r || s || t || u || v || w || x || y)
def DPD_TO_BCD(DPD):
    p <- DPD[0]
    q <- DPD[1]
    r <- DPD[2]
    s <- DPD[3]
    t <- DPD[4]
    u <- DPD[5]
    v <- DPD[6]
    w <- DPD[7]
    x <- DPD[8]
    y <- DPD[9]

    a <- ((¬s & v & w) | (t & v & w & s) | (v & w & ¬x))
    b <- ((p & s & x & ¬t) | (p & ¬w) | (p & ¬v))
    c <- ((q & s & x & ¬t) | (q & ¬w) | (q & ¬v))
    d <- r

    e <- ((v & ¬w & x) | (s & v & w & x) |
        (¬t & v & x & w))
    f <- ((p & t & v & w & x & ¬s) | (s & ¬x & v) |
        (s & ¬v))
    g <- ((q & t & w & v & x & ¬s) | (t & ¬x & v) |
        (t & ¬v))
    h <- u

    i <- ((t & v & w & x) | (s & v & w & x) |
        (v & ¬w & ¬x))
    j <- ((p & ¬s & ¬t & w & v) | (s & v & ¬w & x) |
        (p & w & ¬x & v) | (w & ¬v))
    k <- ((q & ¬s & ¬t & v & w) | (t & v & ¬w & x) |
        (q & v & w & ¬x) | (x & ¬v))
    m <- y

    return (a || b || c || d || e || f || g || h || i || j || k || m)