sim: replace beating period error formula

This commit is contained in:
morgan 2024-01-25 16:34:26 +08:00
parent 5a9fa937ee
commit 39bb656f85

View File

@ -120,7 +120,6 @@ class EventManager_IRQ(object):
@jitclass
class Tag_Collector(object):
setpt_beating_period: int64
last_gtx: int32
gtx_tag_ready: bool
gtx_tag: int32
@ -129,7 +128,6 @@ class Tag_Collector(object):
def __init__(self, setpt_beating_period: int64):
self.setpt_beating_period = setpt_beating_period
self.last_gtx = 0
# for main PLL
self.gtx_tag_ready = False
@ -138,7 +136,6 @@ class Tag_Collector(object):
self.main_tag = 0
def collect_gtx_tag(self, tag: int32):
self.last_gtx = self.gtx
self.gtx_tag = tag
self.gtx_tag_ready = True
@ -147,7 +144,13 @@ class Tag_Collector(object):
self.main_tag_ready = True
def get_period_error(self) -> int32:
return self.set_phase_error_ready - (self.gtx - self.last_gtx)
# period_error = n * ideal_beating - GTX_tag(n)
period_error = (-self.gtx_tag) % self.setpt_beating_period
if period_error > self.setpt_beating_period / 2:
return period_error - self.setpt_beating_period
return period_error
def get_phase_error(self) -> int32:
# tag_diff = main_tag(n) - gtx_tag(n)