This commit is contained in:
Steven Dan
2025-12-11 09:43:42 +08:00
commit d8b2974133
1822 changed files with 280037 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#**********************
# Gather Sources
#**********************
file(GLOB_RECURSE APP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.c ${CMAKE_CURRENT_LIST_DIR}/src/*.xc)
set(APP_INCLUDES
${CMAKE_CURRENT_LIST_DIR}/src
)
#**********************
# Flags
#**********************
set(APP_COMPILER_FLAGS
-Os
-g
-report
-fxscope
-mcmodel=large
-Wno-xcore-fptrgroup
${CMAKE_CURRENT_LIST_DIR}/src/config.xscope
${CMAKE_CURRENT_LIST_DIR}/src/xvf3800_qf60.xn
)
set(APP_COMPILE_DEFINITIONS
)
set(APP_LINK_OPTIONS
-report
${CMAKE_CURRENT_LIST_DIR}/src/config.xscope
${CMAKE_CURRENT_LIST_DIR}/src/xvf3800_qf60.xn
)
#**********************
# Tile Targets
#**********************
add_executable(i2s_slave_lut)
target_sources(i2s_slave_lut PUBLIC ${APP_SOURCES})
target_include_directories(i2s_slave_lut PUBLIC ${APP_INCLUDES})
target_compile_definitions(i2s_slave_lut PRIVATE ${APP_COMPILE_DEFINITIONS})
target_compile_options(i2s_slave_lut PRIVATE ${APP_COMPILER_FLAGS})
target_link_options(i2s_slave_lut PRIVATE ${APP_LINK_OPTIONS})
target_link_libraries(i2s_slave_lut PUBLIC lib_sw_pll lib_i2s)

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================= -->
<!-- The 'ioMode' attribute on the xSCOPEconfig -->
<!-- element can take the following values: -->
<!-- "none", "basic", "timed" -->
<!-- -->
<!-- The 'type' attribute on Probe -->
<!-- elements can take the following values: -->
<!-- "STARTSTOP", "CONTINUOUS", "DISCRETE", "STATEMACHINE" -->
<!-- -->
<!-- The 'datatype' attribute on Probe -->
<!-- elements can take the following values: -->
<!-- "NONE", "UINT", "INT", "FLOAT" -->
<!-- ======================================================= -->
<xSCOPEconfig ioMode="basic" enabled="true">
<!-- For example: -->
<!-- <Probe name="I2S_RX_0" type="CONTINUOUS" datatype="INT" units="Value" enabled="true"/> -->
<!-- From the target code, call: xscope_int(PROBE_NAME, value); -->
</xSCOPEconfig>

View File

@@ -0,0 +1,417 @@
// Header file listing fraction options searched
// These values to go in the bottom 16 bits of the secondary PLL fractional-n divider register.
short frac_values_80[413] = {
0x0F16, // Index: 0 Fraction: 16/23 = 0.6957
0x364E, // Index: 1 Fraction: 55/79 = 0.6962
0x2637, // Index: 2 Fraction: 39/56 = 0.6964
0x1620, // Index: 3 Fraction: 23/33 = 0.6970
0x344B, // Index: 4 Fraction: 53/76 = 0.6974
0x1D2A, // Index: 5 Fraction: 30/43 = 0.6977
0x2434, // Index: 6 Fraction: 37/53 = 0.6981
0x2B3E, // Index: 7 Fraction: 44/63 = 0.6984
0x3248, // Index: 8 Fraction: 51/73 = 0.6986
0x0609, // Index: 9 Fraction: 7/10 = 0.7000
0x354C, // Index: 10 Fraction: 54/77 = 0.7013
0x2E42, // Index: 11 Fraction: 47/67 = 0.7015
0x2738, // Index: 12 Fraction: 40/57 = 0.7018
0x202E, // Index: 13 Fraction: 33/47 = 0.7021
0x1924, // Index: 14 Fraction: 26/37 = 0.7027
0x2C3F, // Index: 15 Fraction: 45/64 = 0.7031
0x121A, // Index: 16 Fraction: 19/27 = 0.7037
0x3146, // Index: 17 Fraction: 50/71 = 0.7042
0x1E2B, // Index: 18 Fraction: 31/44 = 0.7045
0x2A3C, // Index: 19 Fraction: 43/61 = 0.7049
0x364D, // Index: 20 Fraction: 55/78 = 0.7051
0x0B10, // Index: 21 Fraction: 12/17 = 0.7059
0x344A, // Index: 22 Fraction: 53/75 = 0.7067
0x2839, // Index: 23 Fraction: 41/58 = 0.7069
0x1C28, // Index: 24 Fraction: 29/41 = 0.7073
0x2D40, // Index: 25 Fraction: 46/65 = 0.7077
0x1017, // Index: 26 Fraction: 17/24 = 0.7083
0x374E, // Index: 27 Fraction: 56/79 = 0.7089
0x2636, // Index: 28 Fraction: 39/55 = 0.7091
0x151E, // Index: 29 Fraction: 22/31 = 0.7097
0x3044, // Index: 30 Fraction: 49/69 = 0.7101
0x1A25, // Index: 31 Fraction: 27/38 = 0.7105
0x1F2C, // Index: 32 Fraction: 32/45 = 0.7111
0x2433, // Index: 33 Fraction: 37/52 = 0.7115
0x293A, // Index: 34 Fraction: 42/59 = 0.7119
0x2E41, // Index: 35 Fraction: 47/66 = 0.7121
0x3348, // Index: 36 Fraction: 52/73 = 0.7123
0x384F, // Index: 37 Fraction: 57/80 = 0.7125
0x0406, // Index: 38 Fraction: 5/7 = 0.7143
0x3449, // Index: 39 Fraction: 53/74 = 0.7162
0x2F42, // Index: 40 Fraction: 48/67 = 0.7164
0x2A3B, // Index: 41 Fraction: 43/60 = 0.7167
0x2534, // Index: 42 Fraction: 38/53 = 0.7170
0x202D, // Index: 43 Fraction: 33/46 = 0.7174
0x1B26, // Index: 44 Fraction: 28/39 = 0.7179
0x3246, // Index: 45 Fraction: 51/71 = 0.7183
0x161F, // Index: 46 Fraction: 23/32 = 0.7188
0x2838, // Index: 47 Fraction: 41/57 = 0.7193
0x1118, // Index: 48 Fraction: 18/25 = 0.7200
0x3043, // Index: 49 Fraction: 49/68 = 0.7206
0x1E2A, // Index: 50 Fraction: 31/43 = 0.7209
0x2B3C, // Index: 51 Fraction: 44/61 = 0.7213
0x384E, // Index: 52 Fraction: 57/79 = 0.7215
0x0C11, // Index: 53 Fraction: 13/18 = 0.7222
0x2E40, // Index: 54 Fraction: 47/65 = 0.7231
0x212E, // Index: 55 Fraction: 34/47 = 0.7234
0x364B, // Index: 56 Fraction: 55/76 = 0.7237
0x141C, // Index: 57 Fraction: 21/29 = 0.7241
0x3144, // Index: 58 Fraction: 50/69 = 0.7246
0x1C27, // Index: 59 Fraction: 29/40 = 0.7250
0x2432, // Index: 60 Fraction: 37/51 = 0.7255
0x2C3D, // Index: 61 Fraction: 45/62 = 0.7258
0x3448, // Index: 62 Fraction: 53/73 = 0.7260
0x070A, // Index: 63 Fraction: 8/11 = 0.7273
0x3245, // Index: 64 Fraction: 51/70 = 0.7286
0x2A3A, // Index: 65 Fraction: 43/59 = 0.7288
0x222F, // Index: 66 Fraction: 35/48 = 0.7292
0x1A24, // Index: 67 Fraction: 27/37 = 0.7297
0x2D3E, // Index: 68 Fraction: 46/63 = 0.7302
0x1219, // Index: 69 Fraction: 19/26 = 0.7308
0x3042, // Index: 70 Fraction: 49/67 = 0.7313
0x1D28, // Index: 71 Fraction: 30/41 = 0.7317
0x2837, // Index: 72 Fraction: 41/56 = 0.7321
0x3346, // Index: 73 Fraction: 52/71 = 0.7324
0x0A0E, // Index: 74 Fraction: 11/15 = 0.7333
0x394E, // Index: 75 Fraction: 58/79 = 0.7342
0x2E3F, // Index: 76 Fraction: 47/64 = 0.7344
0x2330, // Index: 77 Fraction: 36/49 = 0.7347
0x1821, // Index: 78 Fraction: 25/34 = 0.7353
0x2634, // Index: 79 Fraction: 39/53 = 0.7358
0x3447, // Index: 80 Fraction: 53/72 = 0.7361
0x0D12, // Index: 81 Fraction: 14/19 = 0.7368
0x3A4F, // Index: 82 Fraction: 59/80 = 0.7375
0x2C3C, // Index: 83 Fraction: 45/61 = 0.7377
0x1E29, // Index: 84 Fraction: 31/42 = 0.7381
0x2F40, // Index: 85 Fraction: 48/65 = 0.7385
0x1016, // Index: 86 Fraction: 17/23 = 0.7391
0x3548, // Index: 87 Fraction: 54/73 = 0.7397
0x2431, // Index: 88 Fraction: 37/50 = 0.7400
0x384C, // Index: 89 Fraction: 57/77 = 0.7403
0x131A, // Index: 90 Fraction: 20/27 = 0.7407
0x2A39, // Index: 91 Fraction: 43/58 = 0.7414
0x161E, // Index: 92 Fraction: 23/31 = 0.7419
0x3041, // Index: 93 Fraction: 49/66 = 0.7424
0x1922, // Index: 94 Fraction: 26/35 = 0.7429
0x3649, // Index: 95 Fraction: 55/74 = 0.7432
0x1C26, // Index: 96 Fraction: 29/39 = 0.7436
0x1F2A, // Index: 97 Fraction: 32/43 = 0.7442
0x222E, // Index: 98 Fraction: 35/47 = 0.7447
0x2532, // Index: 99 Fraction: 38/51 = 0.7451
0x2836, // Index: 100 Fraction: 41/55 = 0.7455
0x2B3A, // Index: 101 Fraction: 44/59 = 0.7458
0x2E3E, // Index: 102 Fraction: 47/63 = 0.7460
0x3142, // Index: 103 Fraction: 50/67 = 0.7463
0x3446, // Index: 104 Fraction: 53/71 = 0.7465
0x374A, // Index: 105 Fraction: 56/75 = 0.7467
0x3A4E, // Index: 106 Fraction: 59/79 = 0.7468
0x0203, // Index: 107 Fraction: 3/4 = 0.7500
0x394C, // Index: 108 Fraction: 58/77 = 0.7532
0x3648, // Index: 109 Fraction: 55/73 = 0.7534
0x3344, // Index: 110 Fraction: 52/69 = 0.7536
0x3040, // Index: 111 Fraction: 49/65 = 0.7538
0x2D3C, // Index: 112 Fraction: 46/61 = 0.7541
0x2A38, // Index: 113 Fraction: 43/57 = 0.7544
0x2734, // Index: 114 Fraction: 40/53 = 0.7547
0x2430, // Index: 115 Fraction: 37/49 = 0.7551
0x212C, // Index: 116 Fraction: 34/45 = 0.7556
0x1E28, // Index: 117 Fraction: 31/41 = 0.7561
0x3A4D, // Index: 118 Fraction: 59/78 = 0.7564
0x1B24, // Index: 119 Fraction: 28/37 = 0.7568
0x3445, // Index: 120 Fraction: 53/70 = 0.7571
0x1820, // Index: 121 Fraction: 25/33 = 0.7576
0x2E3D, // Index: 122 Fraction: 47/62 = 0.7581
0x151C, // Index: 123 Fraction: 22/29 = 0.7586
0x2835, // Index: 124 Fraction: 41/54 = 0.7593
0x3B4E, // Index: 125 Fraction: 60/79 = 0.7595
0x1218, // Index: 126 Fraction: 19/25 = 0.7600
0x3546, // Index: 127 Fraction: 54/71 = 0.7606
0x222D, // Index: 128 Fraction: 35/46 = 0.7609
0x3242, // Index: 129 Fraction: 51/67 = 0.7612
0x0F14, // Index: 130 Fraction: 16/21 = 0.7619
0x3C4F, // Index: 131 Fraction: 61/80 = 0.7625
0x2C3A, // Index: 132 Fraction: 45/59 = 0.7627
0x1C25, // Index: 133 Fraction: 29/38 = 0.7632
0x2936, // Index: 134 Fraction: 42/55 = 0.7636
0x3647, // Index: 135 Fraction: 55/72 = 0.7639
0x0C10, // Index: 136 Fraction: 13/17 = 0.7647
0x303F, // Index: 137 Fraction: 49/64 = 0.7656
0x232E, // Index: 138 Fraction: 36/47 = 0.7660
0x3A4C, // Index: 139 Fraction: 59/77 = 0.7662
0x161D, // Index: 140 Fraction: 23/30 = 0.7667
0x3748, // Index: 141 Fraction: 56/73 = 0.7671
0x202A, // Index: 142 Fraction: 33/43 = 0.7674
0x2A37, // Index: 143 Fraction: 43/56 = 0.7679
0x3444, // Index: 144 Fraction: 53/69 = 0.7681
0x090C, // Index: 145 Fraction: 10/13 = 0.7692
0x3849, // Index: 146 Fraction: 57/74 = 0.7703
0x2E3C, // Index: 147 Fraction: 47/61 = 0.7705
0x242F, // Index: 148 Fraction: 37/48 = 0.7708
0x1A22, // Index: 149 Fraction: 27/35 = 0.7714
0x2B38, // Index: 150 Fraction: 44/57 = 0.7719
0x3C4E, // Index: 151 Fraction: 61/79 = 0.7722
0x1015, // Index: 152 Fraction: 17/22 = 0.7727
0x394A, // Index: 153 Fraction: 58/75 = 0.7733
0x2834, // Index: 154 Fraction: 41/53 = 0.7736
0x171E, // Index: 155 Fraction: 24/31 = 0.7742
0x3646, // Index: 156 Fraction: 55/71 = 0.7746
0x1E27, // Index: 157 Fraction: 31/40 = 0.7750
0x2530, // Index: 158 Fraction: 38/49 = 0.7755
0x2C39, // Index: 159 Fraction: 45/58 = 0.7759
0x3342, // Index: 160 Fraction: 52/67 = 0.7761
0x3A4B, // Index: 161 Fraction: 59/76 = 0.7763
0x0608, // Index: 162 Fraction: 7/9 = 0.7778
0x3B4C, // Index: 163 Fraction: 60/77 = 0.7792
0x3443, // Index: 164 Fraction: 53/68 = 0.7794
0x2D3A, // Index: 165 Fraction: 46/59 = 0.7797
0x2631, // Index: 166 Fraction: 39/50 = 0.7800
0x1F28, // Index: 167 Fraction: 32/41 = 0.7805
0x3848, // Index: 168 Fraction: 57/73 = 0.7808
0x181F, // Index: 169 Fraction: 25/32 = 0.7812
0x2A36, // Index: 170 Fraction: 43/55 = 0.7818
0x3C4D, // Index: 171 Fraction: 61/78 = 0.7821
0x1116, // Index: 172 Fraction: 18/23 = 0.7826
0x2E3B, // Index: 173 Fraction: 47/60 = 0.7833
0x1C24, // Index: 174 Fraction: 29/37 = 0.7838
0x2732, // Index: 175 Fraction: 40/51 = 0.7843
0x3240, // Index: 176 Fraction: 51/65 = 0.7846
0x3D4E, // Index: 177 Fraction: 62/79 = 0.7848
0x0A0D, // Index: 178 Fraction: 11/14 = 0.7857
0x3A4A, // Index: 179 Fraction: 59/75 = 0.7867
0x2F3C, // Index: 180 Fraction: 48/61 = 0.7869
0x242E, // Index: 181 Fraction: 37/47 = 0.7872
0x3E4F, // Index: 182 Fraction: 63/80 = 0.7875
0x1920, // Index: 183 Fraction: 26/33 = 0.7879
0x2833, // Index: 184 Fraction: 41/52 = 0.7885
0x3746, // Index: 185 Fraction: 56/71 = 0.7887
0x0E12, // Index: 186 Fraction: 15/19 = 0.7895
0x303D, // Index: 187 Fraction: 49/62 = 0.7903
0x212A, // Index: 188 Fraction: 34/43 = 0.7907
0x3442, // Index: 189 Fraction: 53/67 = 0.7910
0x1217, // Index: 190 Fraction: 19/24 = 0.7917
0x3C4C, // Index: 191 Fraction: 61/77 = 0.7922
0x2934, // Index: 192 Fraction: 42/53 = 0.7925
0x161C, // Index: 193 Fraction: 23/29 = 0.7931
0x313E, // Index: 194 Fraction: 50/63 = 0.7937
0x1A21, // Index: 195 Fraction: 27/34 = 0.7941
0x3948, // Index: 196 Fraction: 58/73 = 0.7945
0x1E26, // Index: 197 Fraction: 31/39 = 0.7949
0x222B, // Index: 198 Fraction: 35/44 = 0.7955
0x2630, // Index: 199 Fraction: 39/49 = 0.7959
0x2A35, // Index: 200 Fraction: 43/54 = 0.7963
0x2E3A, // Index: 201 Fraction: 47/59 = 0.7966
0x323F, // Index: 202 Fraction: 51/64 = 0.7969
0x3644, // Index: 203 Fraction: 55/69 = 0.7971
0x3A49, // Index: 204 Fraction: 59/74 = 0.7973
0x3E4E, // Index: 205 Fraction: 63/79 = 0.7975
0x0304, // Index: 206 Fraction: 4/5 = 0.8000
0x3C4B, // Index: 207 Fraction: 61/76 = 0.8026
0x3846, // Index: 208 Fraction: 57/71 = 0.8028
0x3441, // Index: 209 Fraction: 53/66 = 0.8030
0x303C, // Index: 210 Fraction: 49/61 = 0.8033
0x2C37, // Index: 211 Fraction: 45/56 = 0.8036
0x2832, // Index: 212 Fraction: 41/51 = 0.8039
0x242D, // Index: 213 Fraction: 37/46 = 0.8043
0x2028, // Index: 214 Fraction: 33/41 = 0.8049
0x3D4C, // Index: 215 Fraction: 62/77 = 0.8052
0x1C23, // Index: 216 Fraction: 29/36 = 0.8056
0x3542, // Index: 217 Fraction: 54/67 = 0.8060
0x181E, // Index: 218 Fraction: 25/31 = 0.8065
0x2D38, // Index: 219 Fraction: 46/57 = 0.8070
0x1419, // Index: 220 Fraction: 21/26 = 0.8077
0x3A48, // Index: 221 Fraction: 59/73 = 0.8082
0x252E, // Index: 222 Fraction: 38/47 = 0.8085
0x3643, // Index: 223 Fraction: 55/68 = 0.8088
0x1014, // Index: 224 Fraction: 17/21 = 0.8095
0x3F4E, // Index: 225 Fraction: 64/79 = 0.8101
0x2E39, // Index: 226 Fraction: 47/58 = 0.8103
0x1D24, // Index: 227 Fraction: 30/37 = 0.8108
0x2A34, // Index: 228 Fraction: 43/53 = 0.8113
0x3744, // Index: 229 Fraction: 56/69 = 0.8116
0x0C0F, // Index: 230 Fraction: 13/16 = 0.8125
0x3C4A, // Index: 231 Fraction: 61/75 = 0.8133
0x2F3A, // Index: 232 Fraction: 48/59 = 0.8136
0x222A, // Index: 233 Fraction: 35/43 = 0.8140
0x3845, // Index: 234 Fraction: 57/70 = 0.8143
0x151A, // Index: 235 Fraction: 22/27 = 0.8148
0x3440, // Index: 236 Fraction: 53/65 = 0.8154
0x1E25, // Index: 237 Fraction: 31/38 = 0.8158
0x2730, // Index: 238 Fraction: 40/49 = 0.8163
0x303B, // Index: 239 Fraction: 49/60 = 0.8167
0x3946, // Index: 240 Fraction: 58/71 = 0.8169
0x080A, // Index: 241 Fraction: 9/11 = 0.8182
0x3A47, // Index: 242 Fraction: 59/72 = 0.8194
0x313C, // Index: 243 Fraction: 50/61 = 0.8197
0x2831, // Index: 244 Fraction: 41/50 = 0.8200
0x1F26, // Index: 245 Fraction: 32/39 = 0.8205
0x3642, // Index: 246 Fraction: 55/67 = 0.8209
0x161B, // Index: 247 Fraction: 23/28 = 0.8214
0x3B48, // Index: 248 Fraction: 60/73 = 0.8219
0x242C, // Index: 249 Fraction: 37/45 = 0.8222
0x323D, // Index: 250 Fraction: 51/62 = 0.8226
0x404E, // Index: 251 Fraction: 65/79 = 0.8228
0x0D10, // Index: 252 Fraction: 14/17 = 0.8235
0x3C49, // Index: 253 Fraction: 61/74 = 0.8243
0x2E38, // Index: 254 Fraction: 47/57 = 0.8246
0x2027, // Index: 255 Fraction: 33/40 = 0.8250
0x333E, // Index: 256 Fraction: 52/63 = 0.8254
0x1216, // Index: 257 Fraction: 19/23 = 0.8261
0x3D4A, // Index: 258 Fraction: 62/75 = 0.8267
0x2A33, // Index: 259 Fraction: 43/52 = 0.8269
0x171C, // Index: 260 Fraction: 24/29 = 0.8276
0x343F, // Index: 261 Fraction: 53/64 = 0.8281
0x1C22, // Index: 262 Fraction: 29/35 = 0.8286
0x3E4B, // Index: 263 Fraction: 63/76 = 0.8289
0x2128, // Index: 264 Fraction: 34/41 = 0.8293
0x262E, // Index: 265 Fraction: 39/47 = 0.8298
0x2B34, // Index: 266 Fraction: 44/53 = 0.8302
0x303A, // Index: 267 Fraction: 49/59 = 0.8305
0x3540, // Index: 268 Fraction: 54/65 = 0.8308
0x3A46, // Index: 269 Fraction: 59/71 = 0.8310
0x3F4C, // Index: 270 Fraction: 64/77 = 0.8312
0x0405, // Index: 271 Fraction: 5/6 = 0.8333
0x414E, // Index: 272 Fraction: 66/79 = 0.8354
0x3C48, // Index: 273 Fraction: 61/73 = 0.8356
0x3742, // Index: 274 Fraction: 56/67 = 0.8358
0x323C, // Index: 275 Fraction: 51/61 = 0.8361
0x2D36, // Index: 276 Fraction: 46/55 = 0.8364
0x2830, // Index: 277 Fraction: 41/49 = 0.8367
0x232A, // Index: 278 Fraction: 36/43 = 0.8372
0x424F, // Index: 279 Fraction: 67/80 = 0.8375
0x1E24, // Index: 280 Fraction: 31/37 = 0.8378
0x3843, // Index: 281 Fraction: 57/68 = 0.8382
0x191E, // Index: 282 Fraction: 26/31 = 0.8387
0x2E37, // Index: 283 Fraction: 47/56 = 0.8393
0x1418, // Index: 284 Fraction: 21/25 = 0.8400
0x3944, // Index: 285 Fraction: 58/69 = 0.8406
0x242B, // Index: 286 Fraction: 37/44 = 0.8409
0x343E, // Index: 287 Fraction: 53/63 = 0.8413
0x0F12, // Index: 288 Fraction: 16/19 = 0.8421
0x3A45, // Index: 289 Fraction: 59/70 = 0.8429
0x2A32, // Index: 290 Fraction: 43/51 = 0.8431
0x1A1F, // Index: 291 Fraction: 27/32 = 0.8438
0x404C, // Index: 292 Fraction: 65/77 = 0.8442
0x252C, // Index: 293 Fraction: 38/45 = 0.8444
0x3039, // Index: 294 Fraction: 49/58 = 0.8448
0x3B46, // Index: 295 Fraction: 60/71 = 0.8451
0x0A0C, // Index: 296 Fraction: 11/13 = 0.8462
0x3C47, // Index: 297 Fraction: 61/72 = 0.8472
0x313A, // Index: 298 Fraction: 50/59 = 0.8475
0x262D, // Index: 299 Fraction: 39/46 = 0.8478
0x424E, // Index: 300 Fraction: 67/79 = 0.8481
0x1B20, // Index: 301 Fraction: 28/33 = 0.8485
0x2C34, // Index: 302 Fraction: 45/53 = 0.8491
0x3D48, // Index: 303 Fraction: 62/73 = 0.8493
0x1013, // Index: 304 Fraction: 17/20 = 0.8500
0x3842, // Index: 305 Fraction: 57/67 = 0.8507
0x272E, // Index: 306 Fraction: 40/47 = 0.8511
0x3E49, // Index: 307 Fraction: 63/74 = 0.8514
0x161A, // Index: 308 Fraction: 23/27 = 0.8519
0x333C, // Index: 309 Fraction: 52/61 = 0.8525
0x1C21, // Index: 310 Fraction: 29/34 = 0.8529
0x3F4A, // Index: 311 Fraction: 64/75 = 0.8533
0x2228, // Index: 312 Fraction: 35/41 = 0.8537
0x282F, // Index: 313 Fraction: 41/48 = 0.8542
0x2E36, // Index: 314 Fraction: 47/55 = 0.8545
0x343D, // Index: 315 Fraction: 53/62 = 0.8548
0x3A44, // Index: 316 Fraction: 59/69 = 0.8551
0x404B, // Index: 317 Fraction: 65/76 = 0.8553
0x0506, // Index: 318 Fraction: 6/7 = 0.8571
0x424D, // Index: 319 Fraction: 67/78 = 0.8590
0x3C46, // Index: 320 Fraction: 61/71 = 0.8592
0x363F, // Index: 321 Fraction: 55/64 = 0.8594
0x3038, // Index: 322 Fraction: 49/57 = 0.8596
0x2A31, // Index: 323 Fraction: 43/50 = 0.8600
0x242A, // Index: 324 Fraction: 37/43 = 0.8605
0x434E, // Index: 325 Fraction: 68/79 = 0.8608
0x1E23, // Index: 326 Fraction: 31/36 = 0.8611
0x3740, // Index: 327 Fraction: 56/65 = 0.8615
0x181C, // Index: 328 Fraction: 25/29 = 0.8621
0x444F, // Index: 329 Fraction: 69/80 = 0.8625
0x2B32, // Index: 330 Fraction: 44/51 = 0.8627
0x3E48, // Index: 331 Fraction: 63/73 = 0.8630
0x1215, // Index: 332 Fraction: 19/22 = 0.8636
0x323A, // Index: 333 Fraction: 51/59 = 0.8644
0x1F24, // Index: 334 Fraction: 32/37 = 0.8649
0x2C33, // Index: 335 Fraction: 45/52 = 0.8654
0x3942, // Index: 336 Fraction: 58/67 = 0.8657
0x0C0E, // Index: 337 Fraction: 13/15 = 0.8667
0x3A43, // Index: 338 Fraction: 59/68 = 0.8676
0x2D34, // Index: 339 Fraction: 46/53 = 0.8679
0x2025, // Index: 340 Fraction: 33/38 = 0.8684
0x343C, // Index: 341 Fraction: 53/61 = 0.8689
0x1316, // Index: 342 Fraction: 20/23 = 0.8696
0x424C, // Index: 343 Fraction: 67/77 = 0.8701
0x2E35, // Index: 344 Fraction: 47/54 = 0.8704
0x1A1E, // Index: 345 Fraction: 27/31 = 0.8710
0x3C45, // Index: 346 Fraction: 61/70 = 0.8714
0x2126, // Index: 347 Fraction: 34/39 = 0.8718
0x282E, // Index: 348 Fraction: 41/47 = 0.8723
0x2F36, // Index: 349 Fraction: 48/55 = 0.8727
0x363E, // Index: 350 Fraction: 55/63 = 0.8730
0x3D46, // Index: 351 Fraction: 62/71 = 0.8732
0x444E, // Index: 352 Fraction: 69/79 = 0.8734
0x0607, // Index: 353 Fraction: 7/8 = 0.8750
0x3F48, // Index: 354 Fraction: 64/73 = 0.8767
0x3840, // Index: 355 Fraction: 57/65 = 0.8769
0x3138, // Index: 356 Fraction: 50/57 = 0.8772
0x2A30, // Index: 357 Fraction: 43/49 = 0.8776
0x2328, // Index: 358 Fraction: 36/41 = 0.8780
0x4049, // Index: 359 Fraction: 65/74 = 0.8784
0x1C20, // Index: 360 Fraction: 29/33 = 0.8788
0x3239, // Index: 361 Fraction: 51/58 = 0.8793
0x1518, // Index: 362 Fraction: 22/25 = 0.8800
0x3A42, // Index: 363 Fraction: 59/67 = 0.8806
0x2429, // Index: 364 Fraction: 37/42 = 0.8810
0x333A, // Index: 365 Fraction: 52/59 = 0.8814
0x424B, // Index: 366 Fraction: 67/76 = 0.8816
0x0E10, // Index: 367 Fraction: 15/17 = 0.8824
0x434C, // Index: 368 Fraction: 68/77 = 0.8831
0x343B, // Index: 369 Fraction: 53/60 = 0.8833
0x252A, // Index: 370 Fraction: 38/43 = 0.8837
0x3C44, // Index: 371 Fraction: 61/69 = 0.8841
0x1619, // Index: 372 Fraction: 23/26 = 0.8846
0x353C, // Index: 373 Fraction: 54/61 = 0.8852
0x1E22, // Index: 374 Fraction: 31/35 = 0.8857
0x454E, // Index: 375 Fraction: 70/79 = 0.8861
0x262B, // Index: 376 Fraction: 39/44 = 0.8864
0x2E34, // Index: 377 Fraction: 47/53 = 0.8868
0x363D, // Index: 378 Fraction: 55/62 = 0.8871
0x3E46, // Index: 379 Fraction: 63/71 = 0.8873
0x464F, // Index: 380 Fraction: 71/80 = 0.8875
0x0708, // Index: 381 Fraction: 8/9 = 0.8889
0x4048, // Index: 382 Fraction: 65/73 = 0.8904
0x383F, // Index: 383 Fraction: 57/64 = 0.8906
0x3036, // Index: 384 Fraction: 49/55 = 0.8909
0x282D, // Index: 385 Fraction: 41/46 = 0.8913
0x2024, // Index: 386 Fraction: 33/37 = 0.8919
0x3940, // Index: 387 Fraction: 58/65 = 0.8923
0x181B, // Index: 388 Fraction: 25/28 = 0.8929
0x424A, // Index: 389 Fraction: 67/75 = 0.8933
0x292E, // Index: 390 Fraction: 42/47 = 0.8936
0x3A41, // Index: 391 Fraction: 59/66 = 0.8939
0x1012, // Index: 392 Fraction: 17/19 = 0.8947
0x3B42, // Index: 393 Fraction: 60/67 = 0.8955
0x2A2F, // Index: 394 Fraction: 43/48 = 0.8958
0x444C, // Index: 395 Fraction: 69/77 = 0.8961
0x191C, // Index: 396 Fraction: 26/29 = 0.8966
0x3C43, // Index: 397 Fraction: 61/68 = 0.8971
0x2226, // Index: 398 Fraction: 35/39 = 0.8974
0x2B30, // Index: 399 Fraction: 44/49 = 0.8980
0x343A, // Index: 400 Fraction: 53/59 = 0.8983
0x3D44, // Index: 401 Fraction: 62/69 = 0.8986
0x464E, // Index: 402 Fraction: 71/79 = 0.8987
0x0809, // Index: 403 Fraction: 9/10 = 0.9000
0x3F46, // Index: 404 Fraction: 64/71 = 0.9014
0x363C, // Index: 405 Fraction: 55/61 = 0.9016
0x2D32, // Index: 406 Fraction: 46/51 = 0.9020
0x2428, // Index: 407 Fraction: 37/41 = 0.9024
0x4047, // Index: 408 Fraction: 65/72 = 0.9028
0x1B1E, // Index: 409 Fraction: 28/31 = 0.9032
0x2E33, // Index: 410 Fraction: 47/52 = 0.9038
0x4148, // Index: 411 Fraction: 66/73 = 0.9041
0x1214, // Index: 412 Fraction: 19/21 = 0.9048
};

View File

@@ -0,0 +1,229 @@
// Copyright 2022-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <xscope.h>
#include <xs1.h>
#include <xcore/assert.h>
#include "sw_pll.h"
#include "i2s.h"
#define MCLK_FREQUENCY 12288000
#define I2S_FREQUENCY 48000
#define PLL_RATIO (MCLK_FREQUENCY / I2S_FREQUENCY)
#define BCLKS_PER_LRCLK 64
#define CONTROL_LOOP_COUNT 512
#define PPM_RANGE 150
#define NUM_I2S_CHANNELS 2
#define NUM_I2S_LINES ((NUM_I2S_CHANNELS + 1) / 2)
// These are generated from sw_pll_sim.py
#include "fractions.h"
#include "register_setup.h"
void setup_recovered_ref_clock_output(port_t p_recovered_ref_clk, xclock_t clk_recovered_ref_clk, port_t p_mclk, unsigned divider, port_t p_lrclk)
{
xassert(divider < 512);
// Connect clock block with divide to mclk
clock_enable(clk_recovered_ref_clk);
clock_set_source_port(clk_recovered_ref_clk, p_mclk);
clock_set_divide(clk_recovered_ref_clk, divider / 2);
printf("Divider: %u\n", divider);
// Output the divided mclk on a port
port_enable(p_recovered_ref_clk);
port_set_clock(p_recovered_ref_clk, clk_recovered_ref_clk);
port_set_out_clock(p_recovered_ref_clk);
// Wait for LR_CLK transition so they are synched on scope
port_enable(p_lrclk);
port_set_trigger_in_equal(p_lrclk, 0);
(void) port_in(p_lrclk);
port_set_trigger_in_equal(p_lrclk, 1);
(void) port_in(p_lrclk);
clock_start(clk_recovered_ref_clk);
}
typedef struct i2s_callback_args_t {
bool did_restart; // Set by init
int curr_lock_status;
int32_t loopback_samples[NUM_I2S_CHANNELS];
port_t p_mclk_count; // Used for keeping track of MCLK output for sw_pll
port_t p_bclk_count; // Used for keeping track of BCLK input for sw_pll
xclock_t i2s_ck_bclk;
sw_pll_state_t *sw_pll; // Pointer to sw_pll state (if used)
} i2s_callback_args_t;
uint32_t random = 0x80085; //Initial seed
void pseudo_rand_uint32(uint32_t *r){
#define CRC_POLY (0xEB31D82E)
asm volatile("crc32 %0, %2, %3" : "=r" (*r) : "0" (*r), "r" (-1), "r" (CRC_POLY));
}
I2S_CALLBACK_ATTR
static void i2s_init(void *app_data, i2s_config_t *i2s_config){
printf("I2S init\n");
i2s_callback_args_t *cb_args = app_data;
i2s_config->mode = I2S_MODE_I2S;
i2s_config->mclk_bclk_ratio = (MCLK_FREQUENCY / I2S_FREQUENCY);
cb_args->did_restart = true;
}
I2S_CALLBACK_ATTR
static i2s_restart_t i2s_restart_check(void *app_data){
i2s_callback_args_t *cb_args = app_data;
// Add random jitter
hwtimer_t tmr = hwtimer_alloc();
pseudo_rand_uint32(&random);
hwtimer_delay(tmr, random & 0x3f);
hwtimer_free(tmr);
static uint16_t old_mclk_pt = 0;
static uint16_t old_bclk_pt = 0;
port_clear_buffer(cb_args->p_bclk_count);
port_in(cb_args->p_bclk_count); // Block until BCLK transition to synchronise
uint16_t mclk_pt = port_get_trigger_time(cb_args->p_mclk_count); // Immediately sample mclk_count
uint16_t bclk_pt = port_get_trigger_time(cb_args->p_bclk_count); // Now grab bclk_count (which won't have changed)
old_mclk_pt = mclk_pt;
old_bclk_pt = bclk_pt;
sw_pll_lut_do_control(cb_args->sw_pll, mclk_pt, bclk_pt);
if(cb_args->sw_pll->lock_status != cb_args->curr_lock_status){
cb_args->curr_lock_status = cb_args->sw_pll->lock_status;
const char msg[3][16] = {"UNLOCKED LOW", "LOCKED", "UNLOCKED HIGH"};
printf("%s\n", msg[cb_args->curr_lock_status+1]);
}
// Debug only. Print raw error term to check jitter on mclk sampling
// static int cnt=0; if(++cnt == CONTROL_LOOP_COUNT) {cnt=0;printintln(cb_args->sw_pll->mclk_diff);}
return I2S_NO_RESTART;
}
I2S_CALLBACK_ATTR
static void i2s_send(void *app_data, size_t num_out, int32_t *i2s_sample_buf){
i2s_callback_args_t *cb_args = app_data;
for(int i = 0; i < NUM_I2S_CHANNELS; i++){
i2s_sample_buf[i] = cb_args->loopback_samples[i];
}
}
I2S_CALLBACK_ATTR
static void i2s_receive(void *app_data, size_t num_in, const int32_t *i2s_sample_buf){
i2s_callback_args_t *cb_args = app_data;
for(int i = 0; i < NUM_I2S_CHANNELS; i++){
cb_args->loopback_samples[i] = i2s_sample_buf[i];
}
}
void sw_pll_test(void){
// I2S resources
port_t p_i2s_dout[NUM_I2S_LINES] = {PORT_I2S_DATA1};
port_t p_i2s_din[NUM_I2S_LINES] = {PORT_I2S_DATA0};
port_t p_bclk = PORT_I2S_BCLK;
port_t p_lrclk = PORT_I2S_LRCLK;
xclock_t i2s_ck_bclk = XS1_CLKBLK_1;
port_enable(p_bclk);
// NOTE: p_lrclk does not need to be enabled by the caller
// sw-pll resources
port_t p_mclk = PORT_MCLK;
port_t p_mclk_count = PORT_MCLK_COUNT;
xclock_t clk_mclk = XS1_CLKBLK_2;
port_t p_bclk_count = XS1_PORT_16A; // Any unused port
// Create clock from mclk port and use it to clock clk_mclk.
port_enable(p_mclk);
clock_enable(clk_mclk);
clock_set_source_port(clk_mclk, p_mclk);
// Clock p_mclk_count from clk_mclk
port_enable(p_mclk_count);
port_set_clock(p_mclk_count, clk_mclk);
clock_start(clk_mclk);
// Enable p_bclk_count to count bclks cycles
port_enable(p_bclk_count);
port_set_clock(p_bclk_count, i2s_ck_bclk);
printf("Initialising SW PLL\n");
sw_pll_state_t sw_pll;
sw_pll_lut_init(&sw_pll,
SW_PLL_15Q16(0.0),
SW_PLL_15Q16(1.0),
SW_PLL_15Q16(0.0),
CONTROL_LOOP_COUNT,
PLL_RATIO,
BCLKS_PER_LRCLK,
frac_values_80,
SW_PLL_NUM_LUT_ENTRIES(frac_values_80),
APP_PLL_CTL_REG,
APP_PLL_DIV_REG,
SW_PLL_NUM_LUT_ENTRIES(frac_values_80) / 2,
PPM_RANGE);
printf("i_windup_limit: %ld\n", sw_pll.pi_state.i_windup_limit);
// Initialise app_data
i2s_callback_args_t app_data = {
.did_restart = false,
.curr_lock_status = SW_PLL_UNLOCKED_LOW,
.loopback_samples = {0},
.p_mclk_count = p_mclk_count,
.p_bclk_count = p_bclk_count,
.i2s_ck_bclk = i2s_ck_bclk,
.sw_pll = &sw_pll
};
// Initialise callback function pointers
i2s_callback_group_t i2s_cb_group;
i2s_cb_group.init = i2s_init;
i2s_cb_group.restart_check = i2s_restart_check;
i2s_cb_group.receive = i2s_receive;
i2s_cb_group.send = i2s_send;
i2s_cb_group.app_data = &app_data;
printf("Starting I2S slave\n");
// Make a test output to observe the recovered mclk divided down to the refclk frequency
xclock_t clk_recovered_ref_clk = XS1_CLKBLK_3;
port_t p_recovered_ref_clk = PORT_I2S_DATA2;
setup_recovered_ref_clock_output(p_recovered_ref_clk, clk_recovered_ref_clk, p_mclk, PLL_RATIO, p_lrclk);
i2s_slave(
&i2s_cb_group,
p_i2s_dout,
NUM_I2S_LINES,
p_i2s_din,
NUM_I2S_LINES,
p_bclk,
p_lrclk,
i2s_ck_bclk);
}

View File

@@ -0,0 +1,20 @@
// Copyright 2022-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <platform.h>
#include <xs1.h>
extern void sw_pll_test(void);
int main(void)
{
par
{
on tile[0]: par {
}
on tile[1]: par {
sw_pll_test();
}
}
return 0;
}

View File

@@ -0,0 +1,16 @@
/* Autogenerated by app_pll_model.py using command:
/Users/ed/sandboxes/lib_sw_pll/python/sw_pll/pll_calc.py -i 24.0 -a -m 80 -t 12.288 -p 6.0 -e 5 -r --fracmin 0.695 --fracmax 0.905 --header
Picked output solution #62
Input freq: 24000000
F: 203
R: 1
f: 3
p: 4
OD: 1
ACD: 24
Output freq: 12288000.0
VCO freq: 2457600000.0 */
#define APP_PLL_CTL_REG 0x0880CB01
#define APP_PLL_DIV_REG 0x80000018
#define APP_PLL_FRAC_REG 0x80000304

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmos.com http://www.xmos.com" ManuallySpecifiedRouting="true">
<Type>Board</Type>
<Name>XS3 MC Audio</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS3-UnA-1024-QF60A">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="800MHz" referencefrequency="100MHz">
<Boot>
<Source Location="SPI:bootFlash"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<!-- USB Ports -->
<Port Location="XS1_PORT_1H" Name="PORT_USB_TX_READYIN"/>
<Port Location="XS1_PORT_1J" Name="PORT_USB_CLK"/>
<Port Location="XS1_PORT_1K" Name="PORT_USB_TX_READYOUT"/>
<Port Location="XS1_PORT_1I" Name="PORT_USB_RX_READY"/>
<Port Location="XS1_PORT_1E" Name="PORT_USB_FLAG0"/>
<Port Location="XS1_PORT_1F" Name="PORT_USB_FLAG1"/>
<Port Location="XS1_PORT_8A" Name="PORT_USB_TXD"/>
<Port Location="XS1_PORT_8B" Name="PORT_USB_RXD"/>
<!-- QSPI Ports -->
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
<!-- Mic related ports -->
<Port Location="XS1_PORT_1M" Name="PORT_PDM_CLK"/>
<Port Location="XS1_PORT_8D" Name="PORT_PDM_DATA"/> <!-- only bits 4,5,6 & 7 are used due to overlap with 1b ports -->
<Port Location="XS1_PORT_1L" Name="PORT_PDM_MCLK"/>
<!-- I2C Master Ports -->
<Port Location="XS1_PORT_1N" Name="PORT_I2C_SCL"/>
<Port Location="XS1_PORT_1O" Name="PORT_I2C_SDA"/>
<!-- SPI Slave Ports -->
<Port Location="XS1_PORT_1A" Name="PORT_SPI_SLAVE_CS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SPI_SLAVE_SCLK"/>
<Port Location="XS1_PORT_1D" Name="PORT_SPI_SLAVE_MOSI"/>
<Port Location="XS1_PORT_1P" Name="PORT_SPI_SLAVE_MISO"/>
<!-- GPIO Ports -->
<Port Location="XS1_PORT_8C" Name="GPO_TILE_0_PORT_8C"/> <!-- only bits 3,4,5,6 & 7 brought out on pckg -->
</Tile>
<Tile Number="1" Reference="tile[1]">
<!-- Audio Ports -->
<Port Location="XS1_PORT_1D" Name="PORT_MCLK"/>
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
<Port Location="XS1_PORT_1A" Name="PORT_I2S_DATA0"/>
<Port Location="XS1_PORT_1G" Name="PORT_I2S_DATA1"/>
<Port Location="XS1_PORT_1K" Name="PORT_I2S_DATA2"/> <!-- Optional in some configs. NOTE shared with GPIO_TILE_1_PORT_1K -->
<!-- MCLK recovery port. This is used internally to count MCLKs and isn't pinned out -->
<Port Location="XS1_PORT_32A" Name="PORT_MCLK_COUNT"/>
<!-- GPIO Ports -->
<Port Location="XS1_PORT_4A" Name="GPI_TILE_1_PORT_4A"/> <!-- only bit 3 is pinned out on package -->
<Port Location="XS1_PORT_1F" Name="GPIO_TILE_1_PORT_1F"/>
<Port Location="XS1_PORT_1K" Name="GPIO_TILE_1_PORT_1K"/> <!-- NOTE shared with PORT_I2S_DATA2 -->
</Tile>
</Node>
</Nodes>
</Package>
</Packages>
<Nodes>
<Node Id="2" Type="device:" RoutingId="0x8000">
<Service Id="0" Proto="xscope_host_data(chanend c);">
<Chanend Identifier="c" end="3"/>
</Service>
</Node>
</Nodes>
<Links>
<Link Encoding="2wire" Delays="4,4" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="XL0"/>
<LinkEndpoint NodeId="2" Chanend="1"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash">
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>
</Network>