def run_test(const, ebn0=range(21), syms=1000000):
m = len(const)
n = const.shape[1] if const.ndim == 2 else 1
ber = []
for s in ebn0:
# eb is divided across n samples, and each symbol has m bits
snr_per_sample = s + pow2db(np.log2(m)/n)
d1 = comms.random_data(syms, m)
x = comms.modulate(d1, const)
if pb:
x = comms.upconvert(x, fs_by_fd, fc, fs, pulse)
# 3 dB extra SNR per sample needed to account for conjugate noise spectrum
x = comms.awgn(x, snr_per_sample+3, complex=False)
x = comms.downconvert(x, fs_by_fd, fc, fs, pulse)
x = x[2*pulse_delay:-2*pulse_delay]
else:
x = comms.awgn(x, snr_per_sample, complex=True)
d2 = comms.demodulate(x, const)
ber.append(comms.ber(d1, d2, m))
return ebn0, ber
评论列表
文章目录