Package: rs-fec-conv
rs_fec_convGetting StartedThe package rs_fec_conv is a rust binding built withpyo3.
rs_fec_conv is intended to be used in parallel with thescikit-dsp-commpackage.
The rust binding improve the processing time of the conv_encoder and viterbi_decoder algorithms.Rust InstallRust is not needed on the system to execute the binaries since the functions are already pre-compiled.
Although,Rustcan be downloaded online or
installed on Windows Subsystem for Linux.curl--proto'=https'--tlsv1.2-sSfhttps://sh.rustup.rs|shPackage RequirementsThis package requires Python 3.7.x.rs_fec_conv InstallYou can download the package rs_fec_conv from PyPiPyPi,
or by the commandpipinstallrs_fec_convNote: The preferred method is to download from PyPi.
If downloading directly from GitHub you will need to install Rust prior.ResultsBEP Simulation (EbN0=4,100000 bits)  G, depthPython Time (sec)Rust Time (sec)Rust Speed Factor Increase('111', '101'), 1039.880.7950.24('11111','11011','10101'), 25675.0021.3231.66('1111001','1011011'), 25217.029.2723.41TutorialConvolutional EncoderThe function conv_encoder_rs can be implementedimportnumpyasnp
importmatplotlib.pyplotasplt
importsk_dsp_comm.rs_fec_convasrs_fec# Generate random dataN=20x=randint(0,2,N)# Initialize fec_conv object with either G length 2 or 3G=('111','101')# G = ('11110111','11011001','10010101')cc1=rs_fec.fec_conv(G,10)state='00'# Convolutionally Encode Signaly,state=cc1.conv_encoder(x,state)# Plot input signalsubplot(211)stem(x)xlabel('Number of Samples')ylabel('x')title('Input Signal')# Plot convolutionally encoded signalsubplot(212)stem(y)xlabel('Number of Samples')ylabel('y')title('Convolutionally Encoded Signal')tight_layout()savefig('conv_enc.png')Viterbi DecoderThe function viterbi_decoder_rs can be implemented by# Viterbi decodez=cc1.viterbi_decoder(y.astype(int),'hard',3)# Plot input signalsubplot(211)stem(x[:11])xlabel('Number of Samples')ylabel('x')title('Input Signal')xlim([0,10])# Plot viterbi decoded signalsubplot(212)stem(z)xlabel('Number of Samples')ylabel('z')title('Viterbi decoded Signal')xlim([0,10])tight_layout()savefig('viterbi_dec.png')Since there is no channel noise added to the signal the Viterbi decoded signal results
in no bit errors from the original signal.Channel SimulationA simulation using AWGN can be done using by integrating with other functions provided
in the scikit-dsp-comm toolbox# Soft decision rate 1/2 simulationN_bits_per_frame=100000EbN0=4total_bit_errors=0total_bit_count=0cc1=rs_fec.fec_conv(('11101','10011'),25)# Encode with shift register starting state of '0000'state='0000'whiletotal_bit_errors<100:# Create 100000 random 0/1 bitsx=randint(0,2,N_bits_per_frame)y,state=cc1.conv_encoder(x,state)# Add channel noise to bits, include antipodal level shift to [-1,1]# Channel SNR is 3 dB less for rate 1/2yn_soft=dc.cpx_AWGN(2*y-1,EbN0-3,1)yn_hard=((np.sign(yn_soft.real)+1)/2).astype(int)z=cc1.viterbi_decoder(yn_hard,'hard')# Count bit errorsbit_count,bit_errors=dc.bit_errors(x,z)total_bit_errors+=bit_errorstotal_bit_count+=bit_countprint('Bits Received = %d, Bit errors = %d, BEP = %1.2e'%\(total_bit_count,total_bit_errors,\total_bit_errors/total_bit_count))print('*****************************************************')print('Bits Received = %d, Bit errors = %d, BEP = %1.2e'%\(total_bit_count,total_bit_errors,\total_bit_errors/total_bit_count))Rate 1/2 Objectkmax =  0, taumax = 0Bits Received = 99976, Bit errors = 845, BEP = 8.45e-03Bits Received = 99976, Bit errors = 845, BEP = 8.45e-03