UOMOP
Linear Block Coding Comparison (6, 3) vs (7, 4) 본문
def forward_6(input_sig, SNR, mod_mode, rayleigh, chcode_mode):
error = 0
if chcode_mode == "LDPC":
encoded_sig, redund_bit = Tx.LDPC_Encode(input_sig)
elif chcode_mode == "block":
block_level = 6
encoded_sig = Tx.block_encode(input_sig, n=block_level)
modulated_sig, table_for_demod = Tx.Modulation(input_sig=encoded_sig, mode=mod_mode)
if rayleigh == "Yes" :
AWGN_input = Fading_Channel.rayleigh(modulated_sig)
elif rayleigh == "No" :
AWGN_input = modulated_sig
AWGN_output = Noise.AWGN(AWGN_input, SNR_dB=SNR)
demodulated_sig = Rx.DeModulation(AWGN_output, mod_mode, table_for_demod)
if chcode_mode == "LDPC":
decoded_sig = Rx.LDPC_Decode(demodulated_sig, redund_bit)
elif chcode_mode == "block":
decoded_sig = Rx.Block_Decode(demodulated_sig, n=block_level)
BER = BER_Check(input_sig, decoded_sig)
return input_sig, decoded_sig, BER
def forward_7(input_sig, SNR, mod_mode, rayleigh, chcode_mode):
error = 0
if chcode_mode == "LDPC":
encoded_sig, redund_bit = Tx.LDPC_Encode(input_sig)
elif chcode_mode == "block":
block_level = 7
encoded_sig = Tx.block_encode(input_sig, n=block_level)
modulated_sig, table_for_demod = Tx.Modulation(input_sig=encoded_sig, mode=mod_mode)
if rayleigh == "Yes" :
AWGN_input = Fading_Channel.rayleigh(modulated_sig)
elif rayleigh == "No" :
AWGN_input = modulated_sig
AWGN_output = Noise.AWGN(AWGN_input, SNR_dB=SNR)
demodulated_sig = Rx.DeModulation(AWGN_output, mod_mode, table_for_demod)
if chcode_mode == "LDPC":
decoded_sig = Rx.LDPC_Decode(demodulated_sig, redund_bit)
elif chcode_mode == "block":
decoded_sig = Rx.Block_Decode(demodulated_sig, n=block_level)
BER = BER_Check(input_sig, decoded_sig)
return input_sig, decoded_sig, BER
list_6 = list()
list_7 = list()
input_sig = Bit_Gen(120000)
for i in range(20) :
input_sig, output_sig, BER = forward_6(input_sig = input_sig, SNR = i, mod_mode = "4-PSK", rayleigh = "No", chcode_mode = "block")
list_6.append(round(BER, 6))
input_sig, output_sig, BER = forward_7(input_sig = input_sig, SNR = i, mod_mode = "4-PSK", rayleigh = "No", chcode_mode = "block")
list_7.append(round(BER, 6))
print("SNR : {} Complete!".format(i))
print(list_6)
print(list_7)
SNR_list = list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
plt.plot(SNR_list, list_6, marker='o', linestyle='dashed', color='blue', label='(6, 3)coding')
plt.plot(SNR_list, list_7, marker='x', linestyle='dotted', color='red', label='(7, 4)coding')
plt.axis([0, SNR_list[-1] + 1, 1e-6, 1])
plt.xscale('linear')
plt.yscale('log')
plt.xlabel('EbNo(dB)')
plt.ylabel('BER')
plt.grid(True)
plt.legend()
plt.show()
4-PSK
8-PSK
'Wireless Comm. > Python' 카테고리의 다른 글
LPDC (n, k) comparison (0) | 2023.05.03 |
---|---|
save2 (0) | 2023.05.03 |
save1 (0) | 2023.05.02 |
16/64QAM (0) | 2023.05.02 |
def Restore_Image(input, c_or_g) (0) | 2023.05.01 |
Comments