formatting: add flake8-black
py: format using black poetry: add flake8-black flake: add buildInputs for flake8-black
This commit is contained in:
parent
f58ab13e9b
commit
203bff205d
@ -36,6 +36,11 @@
|
||||
# fail to build
|
||||
preferWheel = true;
|
||||
};
|
||||
flake8-black = super.flake8-black.overridePythonAttrs (
|
||||
# ModuleNotFoundError: No module named 'setuptools'
|
||||
old: {
|
||||
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
135
poetry.lock
generated
135
poetry.lock
generated
@ -204,6 +204,50 @@ soupsieve = ">1.2"
|
||||
html5lib = ["html5lib"]
|
||||
lxml = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
name = "black"
|
||||
version = "23.12.1"
|
||||
description = "The uncompromising code formatter."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"},
|
||||
{file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"},
|
||||
{file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"},
|
||||
{file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"},
|
||||
{file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"},
|
||||
{file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"},
|
||||
{file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"},
|
||||
{file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"},
|
||||
{file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"},
|
||||
{file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"},
|
||||
{file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"},
|
||||
{file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"},
|
||||
{file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"},
|
||||
{file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"},
|
||||
{file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"},
|
||||
{file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"},
|
||||
{file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"},
|
||||
{file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"},
|
||||
{file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"},
|
||||
{file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"},
|
||||
{file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"},
|
||||
{file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=8.0.0"
|
||||
mypy-extensions = ">=0.4.3"
|
||||
packaging = ">=22.0"
|
||||
pathspec = ">=0.9.0"
|
||||
platformdirs = ">=2"
|
||||
|
||||
[package.extras]
|
||||
colorama = ["colorama (>=0.4.3)"]
|
||||
d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"]
|
||||
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
||||
uvloop = ["uvloop (>=0.15.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "bleach"
|
||||
version = "6.1.0"
|
||||
@ -593,6 +637,40 @@ files = [
|
||||
[package.extras]
|
||||
devel = ["colorama", "json-spec", "jsonschema", "pylint", "pytest", "pytest-benchmark", "pytest-cache", "validictory"]
|
||||
|
||||
[[package]]
|
||||
name = "flake8"
|
||||
version = "7.0.0"
|
||||
description = "the modular source code checker: pep8 pyflakes and co"
|
||||
optional = false
|
||||
python-versions = ">=3.8.1"
|
||||
files = [
|
||||
{file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"},
|
||||
{file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
mccabe = ">=0.7.0,<0.8.0"
|
||||
pycodestyle = ">=2.11.0,<2.12.0"
|
||||
pyflakes = ">=3.2.0,<3.3.0"
|
||||
|
||||
[[package]]
|
||||
name = "flake8-black"
|
||||
version = "0.3.6"
|
||||
description = "flake8 plugin to call black as a code style validator"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "flake8-black-0.3.6.tar.gz", hash = "sha256:0dfbca3274777792a5bcb2af887a4cad72c72d0e86c94e08e3a3de151bb41c34"},
|
||||
{file = "flake8_black-0.3.6-py3-none-any.whl", hash = "sha256:fe8ea2eca98d8a504f22040d9117347f6b367458366952862ac3586e7d4eeaca"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
black = ">=22.1.0"
|
||||
flake8 = ">=3"
|
||||
|
||||
[package.extras]
|
||||
develop = ["build", "twine"]
|
||||
|
||||
[[package]]
|
||||
name = "flask"
|
||||
version = "3.0.0"
|
||||
@ -1247,6 +1325,17 @@ files = [
|
||||
[package.dependencies]
|
||||
traitlets = "*"
|
||||
|
||||
[[package]]
|
||||
name = "mccabe"
|
||||
version = "0.7.0"
|
||||
description = "McCabe checker, plugin for flake8"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
|
||||
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mistune"
|
||||
version = "3.0.2"
|
||||
@ -1258,6 +1347,17 @@ files = [
|
||||
{file = "mistune-3.0.2.tar.gz", hash = "sha256:fc7f93ded930c92394ef2cb6f04a8aabab4117a91449e72dcc8dfa646a508be8"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mypy-extensions"
|
||||
version = "1.0.0"
|
||||
description = "Type system extensions for programs checked with the mypy type checker."
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
files = [
|
||||
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nbclient"
|
||||
version = "0.9.0"
|
||||
@ -1642,6 +1742,17 @@ files = [
|
||||
qa = ["flake8 (==3.8.3)", "mypy (==0.782)"]
|
||||
testing = ["docopt", "pytest (<6.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pathspec"
|
||||
version = "0.12.1"
|
||||
description = "Utility library for gitignore style pattern matching of file paths."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"},
|
||||
{file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pexpect"
|
||||
version = "4.9.0"
|
||||
@ -1790,6 +1901,17 @@ files = [
|
||||
[package.extras]
|
||||
tests = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "pycodestyle"
|
||||
version = "2.11.1"
|
||||
description = "Python style guide checker"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"},
|
||||
{file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pycparser"
|
||||
version = "2.21"
|
||||
@ -1801,6 +1923,17 @@ files = [
|
||||
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyflakes"
|
||||
version = "3.2.0"
|
||||
description = "passive checker of Python programs"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"},
|
||||
{file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pygments"
|
||||
version = "2.17.2"
|
||||
@ -2739,4 +2872,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "121a69b8179bfa06910de0f2fd41aa135a5a4822061538b5c021ba0641e5fa1a"
|
||||
content-hash = "2e8cf0f012eb436a406a3d71375e72462cde7ca7669bb85afc9a074b2bae6a2d"
|
||||
|
@ -16,6 +16,7 @@ numba = "^0.58.1"
|
||||
pandas = "^2.1.4"
|
||||
plotly = "^5.18.0"
|
||||
plotly-resampler = "^0.9.1"
|
||||
flake8-black = "^0.3.6"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
@ -26,9 +26,8 @@ def simulation_jit(
|
||||
dcxo_settling_delay,
|
||||
blind_period,
|
||||
start_up_delay,
|
||||
helper_init_freq=0
|
||||
helper_init_freq=0,
|
||||
):
|
||||
|
||||
arr_len = len(time)
|
||||
|
||||
main = np.zeros(arr_len, dtype=np.int8)
|
||||
@ -71,7 +70,9 @@ def simulation_jit(
|
||||
if main_pll and not helper_pll:
|
||||
helper_freq = helper_init_freq
|
||||
else:
|
||||
helper_freq = dcxo_freq * (1 + base_adpll * 0.0001164 / 1_000_000) * ((N-1) / N)
|
||||
helper_freq = (
|
||||
dcxo_freq * (1 + base_adpll * 0.0001164 / 1_000_000) * ((N - 1) / N)
|
||||
)
|
||||
main_freq = dcxo_freq * (1 + base_adpll * 0.0001164 / 1_000_000)
|
||||
|
||||
last_gtx_tag = last_gtx_FF = last_gtx_beat = 0
|
||||
@ -106,10 +107,11 @@ def simulation_jit(
|
||||
phase_colr_arm = m_i2c_active = False
|
||||
|
||||
adpll_max = 8161512
|
||||
def clip(n, minn, maxn): return max(min(maxn, n), minn)
|
||||
|
||||
def clip(n, minn, maxn):
|
||||
return max(min(maxn, n), minn)
|
||||
|
||||
for i, t in enumerate(time):
|
||||
|
||||
h_phase += 360 * helper_freq * (timestep + h_jitter[i])
|
||||
helper[i] = square(h_phase)
|
||||
|
||||
@ -120,27 +122,64 @@ def simulation_jit(
|
||||
gtx[i] = square(gtx_phase)
|
||||
|
||||
if not last_helper and helper[i]:
|
||||
|
||||
gtx_FF, gtx_beating[i] = DDMTD(gtx[i], last_gtx_FF)
|
||||
main_FF, main_beating[i] = DDMTD(main[i], last_main_FF)
|
||||
|
||||
gtx_tag, gtx_ready, gtx_blind_counter, gtx_blinded = Deglitcher(gtx_beating[i], gtx_tag, gtx_ready,
|
||||
gtx_blind_counter, gtx_blinded, blind_period,
|
||||
last_gtx_beat, last_gtx_tag, counter)
|
||||
gtx_tag, gtx_ready, gtx_blind_counter, gtx_blinded = Deglitcher(
|
||||
gtx_beating[i],
|
||||
gtx_tag,
|
||||
gtx_ready,
|
||||
gtx_blind_counter,
|
||||
gtx_blinded,
|
||||
blind_period,
|
||||
last_gtx_beat,
|
||||
last_gtx_tag,
|
||||
counter,
|
||||
)
|
||||
|
||||
main_tag, main_ready, main_blind_counter, main_blinded = Deglitcher(main_beating[i], main_tag, main_ready,
|
||||
main_blind_counter, main_blinded, blind_period,
|
||||
last_main_beat, last_main_tag, counter)
|
||||
main_tag, main_ready, main_blind_counter, main_blinded = Deglitcher(
|
||||
main_beating[i],
|
||||
main_tag,
|
||||
main_ready,
|
||||
main_blind_counter,
|
||||
main_blinded,
|
||||
blind_period,
|
||||
last_main_beat,
|
||||
last_main_tag,
|
||||
counter,
|
||||
)
|
||||
|
||||
phase_collector_r, wait_gtx, wait_main, colr_gtx_tag, colr_main_tag, phase_collector_state = phase_collector_FSM(gtx_ready, main_ready, gtx_tag, main_tag,
|
||||
wait_gtx, wait_main, colr_gtx_tag, colr_main_tag, phase_collector_state)
|
||||
(
|
||||
phase_collector_r,
|
||||
wait_gtx,
|
||||
wait_main,
|
||||
colr_gtx_tag,
|
||||
colr_main_tag,
|
||||
phase_collector_state,
|
||||
) = phase_collector_FSM(
|
||||
gtx_ready,
|
||||
main_ready,
|
||||
gtx_tag,
|
||||
main_tag,
|
||||
wait_gtx,
|
||||
wait_main,
|
||||
colr_gtx_tag,
|
||||
colr_main_tag,
|
||||
phase_collector_state,
|
||||
)
|
||||
|
||||
if phase_collector_r:
|
||||
FW_gtx_tag = colr_gtx_tag
|
||||
FW_main_tag = colr_main_tag
|
||||
|
||||
period_collector_r, colr_last_gtx_tag, beating_period, period_collector_state = period_collector_FSM(gtx_ready, gtx_tag,
|
||||
colr_last_gtx_tag, period_collector_state)
|
||||
(
|
||||
period_collector_r,
|
||||
colr_last_gtx_tag,
|
||||
beating_period,
|
||||
period_collector_state,
|
||||
) = period_collector_FSM(
|
||||
gtx_ready, gtx_tag, colr_last_gtx_tag, period_collector_state
|
||||
)
|
||||
|
||||
counter += 1
|
||||
|
||||
@ -161,14 +200,12 @@ def simulation_jit(
|
||||
main_tag = last_main_tag
|
||||
|
||||
if i > start_up_delay:
|
||||
|
||||
if i % adpll_write_period == 0:
|
||||
period_colr_arm = phase_colr_arm = True
|
||||
|
||||
# Firmware filters
|
||||
|
||||
if period_colr_arm and period_collector_r:
|
||||
|
||||
period_colr_arm = False
|
||||
period_err = N - beating_period
|
||||
|
||||
@ -177,15 +214,18 @@ def simulation_jit(
|
||||
h_integrator += period_err * h_KI
|
||||
h_derivative = (period_err - last_period_err) * h_KD
|
||||
|
||||
h_adpll = clip(int(base_adpll + h_prop + h_integrator + h_derivative), -adpll_max, adpll_max)
|
||||
h_adpll = clip(
|
||||
int(base_adpll + h_prop + h_integrator + h_derivative),
|
||||
-adpll_max,
|
||||
adpll_max,
|
||||
)
|
||||
last_period_err = period_err
|
||||
h_i2c_active_index = i
|
||||
h_i2c_active = True
|
||||
|
||||
if phase_colr_arm and phase_collector_r:
|
||||
|
||||
phase_colr_arm = False
|
||||
tag_diff = ((FW_main_tag - FW_gtx_tag) % N)
|
||||
tag_diff = (FW_main_tag - FW_gtx_tag) % N
|
||||
if tag_diff > N / 2:
|
||||
phase_err = tag_diff - N
|
||||
else:
|
||||
@ -196,7 +236,11 @@ def simulation_jit(
|
||||
m_integrator += phase_err * m_KI
|
||||
m_derivative = (phase_err - last_phase_err) * m_KD
|
||||
|
||||
m_adpll = clip(int(base_adpll + m_prop + m_integrator + m_derivative), -adpll_max, adpll_max)
|
||||
m_adpll = clip(
|
||||
int(base_adpll + m_prop + m_integrator + m_derivative),
|
||||
-adpll_max,
|
||||
adpll_max,
|
||||
)
|
||||
last_phase_err = phase_err
|
||||
|
||||
m_i2c_active_index = i
|
||||
@ -204,11 +248,19 @@ def simulation_jit(
|
||||
|
||||
# i2c communication delay
|
||||
|
||||
if h_i2c_active and i >= i2c_comm_delay + dcxo_settling_delay + h_i2c_active_index:
|
||||
helper_freq = dcxo_freq * (1 + h_adpll * 0.0001164 / 1_000_000) * ((N-1) / N)
|
||||
if (
|
||||
h_i2c_active
|
||||
and i >= i2c_comm_delay + dcxo_settling_delay + h_i2c_active_index
|
||||
):
|
||||
helper_freq = (
|
||||
dcxo_freq * (1 + h_adpll * 0.0001164 / 1_000_000) * ((N - 1) / N)
|
||||
)
|
||||
h_i2c_active = False
|
||||
|
||||
if m_i2c_active and i >= i2c_comm_delay + dcxo_settling_delay + m_i2c_active_index:
|
||||
if (
|
||||
m_i2c_active
|
||||
and i >= i2c_comm_delay + dcxo_settling_delay + m_i2c_active_index
|
||||
):
|
||||
main_freq = dcxo_freq * (1 + m_adpll * 0.0001164 / 1_000_000)
|
||||
m_i2c_active = False
|
||||
|
||||
@ -222,7 +274,19 @@ def simulation_jit(
|
||||
helperfreq[i] = helper_freq
|
||||
mainfreq[i] = main_freq
|
||||
|
||||
return period_err_arr, phase_err_arr, helper_adpll_arr, main_adpll_arr, gtx_beating, main_beating, gtx, helper, main, helperfreq, mainfreq
|
||||
return (
|
||||
period_err_arr,
|
||||
phase_err_arr,
|
||||
helper_adpll_arr,
|
||||
main_adpll_arr,
|
||||
gtx_beating,
|
||||
main_beating,
|
||||
gtx,
|
||||
helper,
|
||||
main,
|
||||
helperfreq,
|
||||
mainfreq,
|
||||
)
|
||||
|
||||
|
||||
@njit
|
||||
@ -231,8 +295,17 @@ def DDMTD(sig_in, last_FF):
|
||||
|
||||
|
||||
@njit
|
||||
def Deglitcher(beating, t_out, t_ready, blind_counter, blinded, blind_period, last_beat, last_tag, counter):
|
||||
|
||||
def Deglitcher(
|
||||
beating,
|
||||
t_out,
|
||||
t_ready,
|
||||
blind_counter,
|
||||
blinded,
|
||||
blind_period,
|
||||
last_beat,
|
||||
last_tag,
|
||||
counter,
|
||||
):
|
||||
if blind_counter == 0 and beating and not last_beat: # rising
|
||||
t_out = counter
|
||||
t_ready = 1
|
||||
@ -251,8 +324,17 @@ def Deglitcher(beating, t_out, t_ready, blind_counter, blinded, blind_period, la
|
||||
|
||||
|
||||
@njit
|
||||
def phase_collector_FSM(g_tag_r, m_tag_r, gtx_tag, main_tag, wait_gtx, wait_main, colr_gtx_tag, colr_main_tag, FSM_state):
|
||||
|
||||
def phase_collector_FSM(
|
||||
g_tag_r,
|
||||
m_tag_r,
|
||||
gtx_tag,
|
||||
main_tag,
|
||||
wait_gtx,
|
||||
wait_main,
|
||||
colr_gtx_tag,
|
||||
colr_main_tag,
|
||||
FSM_state,
|
||||
):
|
||||
collector_r = 0
|
||||
|
||||
match FSM_state:
|
||||
|
@ -1,9 +1,7 @@
|
||||
import numpy as np
|
||||
import numba as nb
|
||||
from numba import njit
|
||||
|
||||
|
||||
|
||||
def gussian_jitter(RMS_jitter, size, seed=None):
|
||||
return np.random.default_rng(seed).normal(0, RMS_jitter / 2, size)
|
||||
|
||||
@ -14,7 +12,7 @@ def square_with_jitter(time, freq, jitter):
|
||||
wave = np.empty(n)
|
||||
timestep = time[1] - time[0]
|
||||
|
||||
phase = 0.
|
||||
phase = 0.0
|
||||
for i in range(n):
|
||||
phase += 360 * freq * (timestep + jitter[i])
|
||||
wave[i] = square(phase)
|
||||
|
@ -3,8 +3,7 @@ from wrpll_simulation.sim import simulation_jit
|
||||
from wrpll_simulation.wave_gen import gussian_jitter
|
||||
|
||||
|
||||
class WRPLL_simulator():
|
||||
|
||||
class WRPLL_simulator:
|
||||
def __init__(
|
||||
self,
|
||||
timestep,
|
||||
@ -24,9 +23,8 @@ class WRPLL_simulator():
|
||||
N=4069,
|
||||
blind_period=128,
|
||||
helper_init_freq=None,
|
||||
seed=None
|
||||
seed=None,
|
||||
):
|
||||
|
||||
self.time = np.linspace(0, timestep * total_steps, total_steps)
|
||||
self.sim_mode = sim_mode
|
||||
self.h_KP = helper_filter["KP"]
|
||||
@ -47,8 +45,13 @@ class WRPLL_simulator():
|
||||
self.helper_init_freq = helper_init_freq
|
||||
|
||||
# freq_acquisition() error
|
||||
freq_diff = gtx_freq - dcxo_freq + \
|
||||
np.random.default_rng(seed).uniform(-freq_acquisition_error, freq_acquisition_error)
|
||||
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))
|
||||
|
||||
# sim config
|
||||
@ -67,7 +70,7 @@ class WRPLL_simulator():
|
||||
elif self.sim_mode.lower() == "helper_pll":
|
||||
self.helper_pll = True
|
||||
elif self.sim_mode.lower() == "main_pll":
|
||||
if self.helper_init_freq == None:
|
||||
if self.helper_init_freq is None:
|
||||
raise ValueError("main pll mode need to set a helper frequency")
|
||||
self.main_pll = True
|
||||
else:
|
||||
@ -75,7 +78,19 @@ class WRPLL_simulator():
|
||||
|
||||
def run(self):
|
||||
print("running simulation...")
|
||||
self.period_err, self.phase_err, self.helper_adpll, self.main_adpll, self.gtx_beating, self.main_beating, self.gtx, self.helper, self.main, self.helperfreq, self.mainfreq = simulation_jit(
|
||||
(
|
||||
self.period_err,
|
||||
self.phase_err,
|
||||
self.helper_adpll,
|
||||
self.main_adpll,
|
||||
self.gtx_beating,
|
||||
self.main_beating,
|
||||
self.gtx,
|
||||
self.helper,
|
||||
self.main,
|
||||
self.helperfreq,
|
||||
self.mainfreq,
|
||||
) = simulation_jit(
|
||||
self.time,
|
||||
self.gtx_freq,
|
||||
self.gtx_jitter,
|
||||
@ -97,6 +112,6 @@ class WRPLL_simulator():
|
||||
self.dcxo_settling_delay,
|
||||
self.blind_period,
|
||||
self.start_up_delay,
|
||||
self.helper_init_freq
|
||||
self.helper_init_freq,
|
||||
)
|
||||
print("Done!")
|
||||
|
Loading…
Reference in New Issue
Block a user