Skip to content

Repository files navigation

Python-polar-coding

A package for Polar codes simulation.

Installation

pip install python-polar-coding

Example

Here is a simple example of simulation using python_polar_coding.

Binary messages encoded with Polar code, modulated using BPSK, transmitted over channel with AWGN and decoded using Fast SSC algorithm.

frompython_polar_coding.channelsimportSimpleBPSKModulationAWGNfrompython_polar_coding.polar_codesimportFastSSCPolarCodecfrompython_polar_coding.simulation.functionsimport (
compute_fails,
generate_binary_message,
)
N=128K=64design_snr=0.0messages=1000# SNR in [.0, .5, ..., 4.5, 5]snr_range= [i/2foriinrange(11)]
codec=FastSSCPolarCodec(N=N, K=K, design_snr=design_snr)
bpsk=SimpleBPSKModulationAWGN(fec_rate=K/N)
result_ber=dict()
result_fer=dict()
print('Python polar coding simulation')
print(f'Simulating ({codec.N}, {codec.K}) systematic polar code with Design SNR {codec.design_snr} dB')
print()
print('\tSNR (dB)|\tBER\t|\tFER')
forsnrinsnr_range:
ber=0fer=0for_inrange(messages):
msg=generate_binary_message(size=K)
encoded=codec.encode(msg)
transmitted=bpsk.transmit(message=encoded, snr_db=snr)
decoded=codec.decode(transmitted)
bit_errors, frame_error=compute_fails(msg, decoded)
ber+=bit_errorsfer+=frame_errorresult_ber[snr] =ber/ (messages*codec.K)
result_fer[snr] =fer/messagesprint(f'\t{snr}\t|\t{result_ber[snr]:.4f}\t|\t{result_fer[snr]:.4f}')

Current progress

Polar code construction

Decoding

Modulation

  • BPSK

TODO

Polar code construction

Decoding

Modulation

  • Q-PSK
  • 4-QAM

License

MIT License

About

A model of Polar encoder/decoder

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages