sim: add step input to gtx

This commit is contained in:
morgan 2024-01-26 13:27:25 +08:00
parent 39bb656f85
commit 547a02e6d3
2 changed files with 13 additions and 0 deletions

View File

@ -51,6 +51,9 @@ class Timesim_Config(object):
helper_PI: PI_Config,
main_PI: PI_Config,
has_jitter: bool,
step_input_time: float64,
step_frequency: float64,
step_phase: float64,
):
# jitter << timestep_size
# otherwise simulation will add negative phase to Phase_Accumlator
@ -60,6 +63,11 @@ class Timesim_Config(object):
self.main_PI = main_PI
self.has_jitter = has_jitter
# step input
self.step_input_time = step_input_time
self.step_frequency = step_frequency
self.step_phase = step_phase
# preset
self.beating_period = 32768
self.blind_period = 200

View File

@ -40,6 +40,7 @@ class WRPLL_Timesim(object):
cfg = self.cfg
timestep_size = cfg.timestep_size
step_input_time = self.seconds_to_step(cfg.step_input_time)
irq_delay = self.seconds_to_step(cfg.irq_delay)
i2c_comm_delay = self.seconds_to_step(cfg.i2c_comm_delay)
@ -61,6 +62,10 @@ class WRPLL_Timesim(object):
print("Running...")
for i in range(cfg.sim_length):
if i == step_input_time:
gtx.set_freq(gtx.freq + cfg.step_frequency)
gtx.set_phase(gtx.phase + cfg.step_phase)
if cfg.has_jitter:
gtx.update(timestep_size + rng.normal(0, cfg.gtx_jitter))
helper.update(timestep_size + rng.normal(0, cfg.dcxo_jitter))