#
# Copyright 2023 Ettus Research, a National Instruments Company
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
"""
X4xx Clock parameter lookup tables
These lookup tables are pre-calculated and fixed for the hardware we use.
"""

MMCM_LOCKGROUP_LOOKUP = ( \
    # This table is composed of:
    # LockRefDly_LockFBDly_LockCnt_LockSatHigh_UnlockCnt
    0b00110_00110_1111101000_1111101001_0000000001,      # M=1 (not allowed)
    0b00110_00110_1111101000_1111101001_0000000001,      # M=2
    0b01000_01000_1111101000_1111101001_0000000001,      # M=3
    0b01011_01011_1111101000_1111101001_0000000001,      # M=4
    0b01110_01110_1111101000_1111101001_0000000001,      # M=5
    0b10001_10001_1111101000_1111101001_0000000001,      # M=6
    0b10011_10011_1111101000_1111101001_0000000001,      # M=7
    0b10110_10110_1111101000_1111101001_0000000001,      # M=8
    0b11001_11001_1111101000_1111101001_0000000001,      # M=9
    0b11100_11100_1111101000_1111101001_0000000001,      # M=10
    0b11111_11111_1110000100_1111101001_0000000001,      # M=11
    0b11111_11111_1100111001_1111101001_0000000001,      # M=12
    0b11111_11111_1011101110_1111101001_0000000001,      # M=13
    0b11111_11111_1010111100_1111101001_0000000001,
    0b11111_11111_1010001010_1111101001_0000000001,
    0b11111_11111_1001110001_1111101001_0000000001,
    0b11111_11111_1000111111_1111101001_0000000001,
    0b11111_11111_1000100110_1111101001_0000000001,
    0b11111_11111_1000001101_1111101001_0000000001,
    0b11111_11111_0111110100_1111101001_0000000001,
    0b11111_11111_0111011011_1111101001_0000000001,
    0b11111_11111_0111000010_1111101001_0000000001,
    0b11111_11111_0110101001_1111101001_0000000001,
    0b11111_11111_0110010000_1111101001_0000000001,
    0b11111_11111_0110010000_1111101001_0000000001,
    0b11111_11111_0101110111_1111101001_0000000001,
    0b11111_11111_0101011110_1111101001_0000000001,
    0b11111_11111_0101011110_1111101001_0000000001,
    0b11111_11111_0101000101_1111101001_0000000001,
    0b11111_11111_0101000101_1111101001_0000000001,
    0b11111_11111_0100101100_1111101001_0000000001,
    0b11111_11111_0100101100_1111101001_0000000001,
    0b11111_11111_0100101100_1111101001_0000000001,
    0b11111_11111_0100010011_1111101001_0000000001,
    0b11111_11111_0100010011_1111101001_0000000001,
    0b11111_11111_0100010011_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,
    0b11111_11111_0011111010_1111101001_0000000001,      # M=127
    0b11111_11111_0011111010_1111101001_0000000001       # M=128
)

MMCM_FILTERGROUP_LOOKUP = ( \
    #This table corresponds to optimized filter mode. 
    #CP_RES_LFHF
    0b0111_1111_11,    # M=1 - not legal
    0b0111_1111_11,    # M=2
    0b1110_1111_11,    # M=3
    0b1111_1111_11,    # M=4
    0b1111_1011_11,    # M=5
    0b1111_1101_11,    # M=6
    0b1111_0011_11,    # M=7
    0b1110_0101_11,    #8
    0b1111_1001_11,    #9
    0b1111_1001_11,    #10
    0b1110_1110_11,    #11
    0b1111_1110_11,    #12
    0b1111_0001_11,    #13
    0b1111_0001_11,
    0b1111_0001_11,
    0b1110_0110_11,
    0b1110_0110_11,
    0b1111_0110_11,
    0b1110_1010_11,
    0b1110_1010_11,
    0b1111_1010_11,
    0b1111_1010_11,
    0b1111_1010_11,
    0b1111_1010_11,
    0b1111_1010_11,
    0b1101_1100_11,
    0b1101_1100_11,
    0b1101_1100_11,
    0b1110_1100_11,
    0b1110_1100_11,
    0b1110_1100_11,
    0b1111_1100_11,
    0b1111_1100_11,
    0b1111_1100_11,
    0b1111_1100_11,
    0b1111_1100_11,
    0b1111_1100_11,
    0b1110_0010_11,
    0b1110_0010_11,
    0b1110_0010_11,
    0b1110_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1111_0010_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1100_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1101_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1110_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1111_0100_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11,
    0b1101_1000_11     # M=128
)
