wrapper: QoL improvement
time array is generated inside of wrapper set default value for RNGs and ddmtd config adpll_write_period and start_up_delay argument use seconds as their unit freq_diff_error RNG now used the seed argument and uniform RNG
This commit is contained in:
parent
0a66f4c343
commit
0b724e84da
30
src/wrpll.py
30
src/wrpll.py
@ -7,24 +7,25 @@ class WRPLL_simulator():
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
time,
|
timestep,
|
||||||
|
total_steps,
|
||||||
sim_mode,
|
sim_mode,
|
||||||
helper_filter,
|
helper_filter,
|
||||||
main_filter,
|
main_filter,
|
||||||
gtx_freq,
|
gtx_freq,
|
||||||
gtx_jitter,
|
|
||||||
dcxo_freq,
|
|
||||||
dcxo_jitter,
|
|
||||||
freq_acquisition_SD,
|
|
||||||
N,
|
|
||||||
adpll_write_period,
|
adpll_write_period,
|
||||||
blind_period,
|
|
||||||
start_up_delay,
|
start_up_delay,
|
||||||
|
gtx_jitter=370e-15,
|
||||||
|
dcxo_freq=125_000_000,
|
||||||
|
dcxo_jitter=95e-15,
|
||||||
|
freq_acquisition_error=100,
|
||||||
|
N=4069,
|
||||||
|
blind_period=128,
|
||||||
helper_init_freq=None,
|
helper_init_freq=None,
|
||||||
seed=None
|
seed=None
|
||||||
):
|
):
|
||||||
|
|
||||||
self.time = time
|
self.time = np.linspace(0, timestep*total_steps, total_steps)
|
||||||
self.sim_mode = sim_mode
|
self.sim_mode = sim_mode
|
||||||
self.h_KP = helper_filter["KP"]
|
self.h_KP = helper_filter["KP"]
|
||||||
self.h_KI = helper_filter["KI"]
|
self.h_KI = helper_filter["KI"]
|
||||||
@ -35,22 +36,23 @@ class WRPLL_simulator():
|
|||||||
|
|
||||||
# init condition
|
# init condition
|
||||||
self.gtx_freq = gtx_freq
|
self.gtx_freq = gtx_freq
|
||||||
self.gtx_jitter = white_noise(-gtx_jitter, gtx_jitter, len(time), seed)
|
self.gtx_jitter = white_noise(-gtx_jitter, gtx_jitter, len(self.time), seed)
|
||||||
|
|
||||||
self.dcxo_freq = dcxo_freq
|
self.dcxo_freq = dcxo_freq
|
||||||
self.h_jitter = white_noise(-dcxo_jitter, dcxo_jitter, len(time), seed)
|
self.h_jitter = white_noise(-dcxo_jitter, dcxo_jitter, len(self.time), seed)
|
||||||
self.m_jitter = white_noise(-dcxo_jitter, dcxo_jitter, len(time), seed)
|
self.m_jitter = white_noise(-dcxo_jitter, dcxo_jitter, len(self.time), seed)
|
||||||
self.N = N
|
self.N = N
|
||||||
self.helper_init_freq = helper_init_freq
|
self.helper_init_freq = helper_init_freq
|
||||||
|
|
||||||
# freq_acquisition() error
|
# freq_acquisition() error
|
||||||
freq_diff = gtx_freq - dcxo_freq + np.random.normal(0, freq_acquisition_SD)
|
freq_diff = gtx_freq - dcxo_freq + \
|
||||||
|
np.random.default_rng(seed).uniform(-freq_acquisition_error, freq_acquisition_error)
|
||||||
self.base_adpll = int(freq_diff * (1 / dcxo_freq) * (1e6 / 0.0001164))
|
self.base_adpll = int(freq_diff * (1 / dcxo_freq) * (1e6 / 0.0001164))
|
||||||
|
|
||||||
# sim config
|
# sim config
|
||||||
self.adpll_write_period = adpll_write_period
|
|
||||||
self.blind_period = blind_period
|
self.blind_period = blind_period
|
||||||
self.start_up_delay = start_up_delay
|
self.adpll_write_period = int(adpll_write_period/timestep)
|
||||||
|
self.start_up_delay = int(start_up_delay/timestep)
|
||||||
|
|
||||||
if type(self.sim_mode) is not str:
|
if type(self.sim_mode) is not str:
|
||||||
raise ValueError(f"pll_type {type(self.sim_mode)} is not a string")
|
raise ValueError(f"pll_type {type(self.sim_mode)} is not a string")
|
||||||
|
Loading…
Reference in New Issue
Block a user