Пример #1
0
def undo(data: bits, coding_rate='1/2') -> bits:
    # un-puncturing process i.e. add 'X' bits, which are basically just ignored by the conv decoder
    if coding_rate == '3/4':
        data = [d[:3] + '??' + d[3] for d in bitstr.split(data, 4)]
    elif coding_rate == '2/3':
        data = [d + '?' for d in bitstr.split(data, 3)]
    return bitstr.merge(data)
Пример #2
0
def do(data: bits, data_rate: int):
    data_len_bytes = len(bitstr.split(data, 8))
    conf = Config.from_data_rate(data_rate)
    """ Bit-domain """
    data, n_pad = padder.do(data, conf.data_bits_per_ofdm_symbol)
    data = scrambler.do(data)
    data = data[:-n_pad -
                6] + '000000' + data[-n_pad:]  # Refer to 17.3.5.3 for details.
    data = convolutional_coder.do(data)
    data = puncturer.do(data, conf.coding_rate)
    data = interleaver.do(data, conf.coded_bits_per_ofdm_symbol,
                          conf.coded_bits_per_carrier_symbol)
    symbols = header.do(data_rate, data_len_bytes) + modulator.do(
        data, conf.coded_bits_per_carrier_symbol)
    """ Frequency-domain """
    carriers = subcarrier_mapping.do(symbols)
    carriers = pilots.do(carriers)
    frames = to_time_domain.do(carriers)
    """ Time-domain """
    frames = guard_interval.do(frames)
    result = merger.do(preambler.short_training_sequence(),
                       preambler.long_training_sequence(), frames)

    logger.info(
        f'{data_len_bytes}B @ {data_rate}MB/s ({conf.modulation}, {conf.coding_rate})'
    )
    return result
Пример #3
0
def undo(data: bits, coded_bits_ofdm_symbol: int,
         coded_bits_subcarrier: int) -> bits:
    result = [
        undo_one(group, coded_bits_ofdm_symbol, coded_bits_subcarrier)
        for group in bitstr.split(data, coded_bits_ofdm_symbol)
    ]
    return bitstr.merge(result)
Пример #4
0
def do(data: bits, coded_bits_ofdm_symbol: int,
       coded_bits_subcarrier: int) -> bits:
    result = [
        do_one(interleaving_group, coded_bits_ofdm_symbol,
               coded_bits_subcarrier)
        for interleaving_group in bitstr.split(data, coded_bits_ofdm_symbol)
    ]
    return bitstr.merge(result)
Пример #5
0
def undo(data: bits) -> bits:
    LUT = {
        '00': 0,
        '01': 1,
        '10': 2,
        '11': 3,
        '0?': 4,
        '1?': 5,
        '?0': 6,
        '?1': 7
    }
    data = [
        LUT[state_transition] for state_transition in bitstr.split(data, 2)
    ]

    out, error_score = trellis_kernel(data)
    # logger.debug(f'{len(out)//8}B, error_score={int(error_score)}')
    return bitstr.from_list(out)
Пример #6
0
def do(data: bits, bits_per_symbol: int) -> List[Symbol]:
    indexes = [bitstr.to_int(group) for group in bitstr.split(data, bits_per_symbol)]
    symbols = [LUT[bits_per_symbol][index] for index in indexes]
    return symbols