// Parameter definitions
def Fo = 2.44e9 // Free running DCO frequency
def TV = 1/Fo
def FR = 26e6 // Reference frequency
def TR = 1/FR
def Fdes = 2e9 // Desired DCO frequency
def FCW = Fdes/FREF // Frequency command word
for every FR
RR = RR + FCW // Reference phase accumulation; RR initially
// set to 0
tR = tR + TR // Reference time stamps; tR initially set to 0
while tV < tR
RV = RV + 1 // Variable phase accumulation; RV initially set
// to 0
tV = tV + TV + TDEV // Variable time stamps; tV initially set to 0
end
dtr = tR - tV // Time difference between first rising edge of
// FR and DCO clocks
e = my_TDC(dtr) // Fractional phase error converted to digital
// by my_TDC
PHE = RR - (RV + e) // Phase error
NTW = a*PHE // Normalized tuning word: Type-I PLL
FDEV = NTW*FR // Frequency deviation
TDEV = - FDEV/Fo^2 // Frequency deviation converted to period
// deviation
end