def undiff(usbp, usbn):
    """Convert P/N diff pair bits into J/K encoding.

    >>> from cocotb_usb.usb.pp_packet import pp_packet
    >>> undiff(
    ...   #EJK_
    ...   '1100', # p
    ...   '1010', # n
    ... )
    'EJK_'
    >>> print(pp_packet(undiff(
    ...   #KJKJKJKKJJKJJKKK__J - ACK handshake packet
    ...   '0101010011011000001', # p
    ...   '1010101100100111000', # n
    ... ), cycles=1))
    -
    K 1 Sync
    J 2 Sync
    K 3 Sync
    J 4 Sync
    K 5 Sync
    J 6 Sync
    K 7 Sync
    K 8 Sync
    -
    J 1 PID (PID.ACK)
    J 2 PID
    K 3 PID
    J 4 PID
    J 5 PID
    K 6 PID
    K 7 PID
    K 8 PID
    -
    _ SE0
    _ SE0
    J END
    >>> print(pp_packet(undiff(*diff(wrap_packet(sof_packet(0))))))
    ----
    KKKK 1 Sync
    JJJJ 2 Sync
    KKKK 3 Sync
    JJJJ 4 Sync
    KKKK 5 Sync
    JJJJ 6 Sync
    KKKK 7 Sync
    KKKK 8 Sync
    ----
    KKKK 1 PID (PID.SOF)
    JJJJ 2 PID
    JJJJ 3 PID
    KKKK 4 PID
    JJJJ 5 PID
    JJJJ 6 PID
    KKKK 7 PID
    KKKK 8 PID
    ----
    JJJJ  1 Frame #
    KKKK  2 Frame #
    JJJJ  3 Frame #
    KKKK  4 Frame #
    JJJJ  5 Frame #
    KKKK  6 Frame #
    JJJJ  7 Frame #
    KKKK  8 Frame #
    ----
    JJJJ  9 Frame #
    KKKK 10 Frame #
    JJJJ 11 Frame #
    KKKK 1 CRC5
    KKKK 2 CRC5
    JJJJ 3 CRC5
    KKKK 4 CRC5
    JJJJ 5 CRC5
    ----
    ____ SE0
    ____ SE0
    JJJJ END
    """
    assert len(usbp) == len(
        usbn), "Sequence different lengths!\n%s\n%s\n" % (usbp, usbn)
    value = []
    for i in range(0, len(usbp)):
        p = usbp[i]
        n = usbn[i]
        value.append({
            # pn
            '00': '_',
            '11': 'E',
            '10': 'J',
            '01': 'K',
        }[p + n])
    return "".join(value)