import math
#page 520
#problem 10.3
# Part (a)
#Input SNR SNR_ip
SNR_ip = 1000.;
#Beta B
B = 10.;
#Output SNR SNR_op
SNR_op = (1.5*(B**2)*SNR_ip)/(1 + (12*B/math.pi)*(SNR_ip)*math.exp(-0.5*(1/(B+1))*(SNR_ip)));
print 'Output SNR is %.4f'%(10*math.log10(SNR_op)),' dB'
# Part (b)
#Input SNR SNR_ip
SNR_ip = 10;
#Output SNR SNR_op
SNR_op = (1.5*(B**2)*SNR_ip)/(1 + (12*B/math.pi)*(SNR_ip)*math.exp(-0.5*(1/(B+1))*(SNR_ip)));
print 'Output SNR is %.4f'%(10*math.log10(SNR_op)),' dB',
#Given reference frequency is fref = 10 MHz
fref = 10. * 10**6;
#Given step frequency is fstep = 100 KHz
fstep = 100. * 10**3;
#Division ratio M
M = fref/fstep;
#Required output frequency F = 100.6 MHz
F = 100.6 * 10**6;
N = F/fstep;
#Given P = 64
P = 64;
#Truncating value B = 15
B = 15;
A = N - P*B;
print 'The value of A is ',A
print 'The value of B is ',B
print 'The value of M is ',M
#Given reference frequency for PLL is fref = 0.48 MHz
fref = 0.48 * 10**6;
#Frequency divider N = 2000
N = 2000;
#Output Frequency fout
fout = fref*N;
#Output Frequency favg
favg = (2000*15 + 2001*1)*(0.48/16) * 10**6;
print 'Output frequency is ',fout,' Hz'
#Reference frequency is not subdivided before going to comparator and it is an integer divider in the feedback path the frequency resolution fres = 0.48 * 10**6;
fres = 0.48 * 10**6;
print 'Frequency resolution is ',fres,' Hz'
print 'Output frequency resolution is ',favg - fout,' Hz'