From b44b8704525a188e0f4446aa22a1502a400dc00a Mon Sep 17 00:00:00 2001 From: hartytp Date: Mon, 5 Oct 2020 22:52:49 +0100 Subject: [PATCH] wrpll.filters: update to match Weida's MatLab simulations --- artiq/gateware/drtio/wrpll/filters.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/artiq/gateware/drtio/wrpll/filters.py b/artiq/gateware/drtio/wrpll/filters.py index 58b664754..41fb06291 100644 --- a/artiq/gateware/drtio/wrpll/filters.py +++ b/artiq/gateware/drtio/wrpll/filters.py @@ -3,8 +3,7 @@ helper_xn2 = 0 helper_yn0 = 0 helper_yn1 = 0 helper_yn2 = 0 - -previous_helper_tag = 0 +helper_out = 0 main_xn1 = 0 main_xn2 = 0 @@ -13,31 +12,31 @@ main_yn1 = 0 main_yn2 = 0 -def helper(helper_tag): +def helper(tag_diff): global helper_xn1, helper_xn2, helper_yn0, \ - helper_yn1, helper_yn2, previous_helper_tag + helper_yn1, helper_yn2, helper_out - helper_xn0 = helper_tag - previous_helper_tag - 32768 + helper_xn0 = 0 - tag_diff # *(2**22) helper_yr = 4294967296 helper_yn2 = helper_yn1 helper_yn1 = helper_yn0 - helper_yn0 = ( - ((284885689*((217319150*helper_xn0 >> 44) + - (-17591968725107*helper_xn1 >> 44))) >> 44) + - (-35184372088832*helper_yn1 >> 44) - - (17592186044416*helper_yn2 >> 44)) + + helper_yn0 = (284885690 * (helper_xn0 + + (217319150 * helper_xn1 >> 44) + - (17591968725108 * helper_xn2 >> 44) + ) >> 44 + ) + (35184372088832*helper_yn1 >> 44) - helper_yn2 helper_xn2 = helper_xn1 helper_xn1 = helper_xn0 - previous_helper_tag = helper_tag - helper_yn0 = min(helper_yn0, helper_yr) helper_yn0 = max(helper_yn0, 0 - helper_yr) + helper_out = 268435456*helper_yn0 >> 44 - return helper_yn0 + return helper_out def main(main_xn0):