@@ -1152,6 +1152,21 @@ PllCfgRecord get_pll_settings(double f_ref, double f_core, int mode, int low_jit
1152
1152
return val;
1153
1153
}
1154
1154
1155
+ template <typename KeyType>
1156
+ int extract_bits_or_default (const dict<KeyType, Property> &ct, const KeyType &key, int start, int bits, int def = 0 )
1157
+ {
1158
+ Property extr = get_or_default (ct, key, Property ()).extract (start, bits);
1159
+
1160
+ if (extr.is_string ) {
1161
+ try {
1162
+ return std::stoi (extr.as_string ());
1163
+ } catch (std::invalid_argument &e) {
1164
+ log_error (" Expecting numeric value but got '%s'.\n " , extr.as_string ().c_str ());
1165
+ }
1166
+ } else
1167
+ return extr.as_int64 ();
1168
+ }
1169
+
1155
1170
void GateMatePacker::pack_pll ()
1156
1171
{
1157
1172
log_info (" Packing PLLss..\n " );
@@ -1268,8 +1283,6 @@ void GateMatePacker::pack_pll()
1268
1283
ci.unsetParam (id_LOW_JITTER);
1269
1284
ci.unsetParam (id_CI_FILTER_CONST);
1270
1285
ci.unsetParam (id_CP_FILTER_CONST);
1271
- // ci.unsetParam(id_PLL_CFG_A);
1272
- // ci.unsetParam(id_PLL_CFG_B);
1273
1286
1274
1287
// ci.cluster = ci.name;
1275
1288
// move_ram_i(&ci, id_CLK0, PLACE_CPE_CLK0_OUT);
@@ -1279,6 +1292,64 @@ void GateMatePacker::pack_pll()
1279
1292
1280
1293
ci.type = id_PLL;
1281
1294
}
1295
+
1296
+ for (auto &cell : ctx->cells ) {
1297
+ CellInfo &ci = *cell.second ;
1298
+ if (!ci.type .in (id_CC_PLL_ADV))
1299
+ continue ;
1300
+
1301
+ disconnect_if_gnd (&ci, id_CLK_REF);
1302
+ disconnect_if_gnd (&ci, id_USR_CLK_REF);
1303
+ disconnect_if_gnd (&ci, id_CLK_FEEDBACK);
1304
+ disconnect_if_gnd (&ci, id_USR_LOCKED_STDY_RST);
1305
+
1306
+ for (int i=0 ;i<2 ;i++) {
1307
+ char cfg = ' A' + i;
1308
+ IdString id = i==0 ? id_PLL_CFG_A : id_PLL_CFG_B;
1309
+ ci.params [ctx->idf (" CFG_%c.CI_FILTER_CONST" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 0 , 5 ) , 5 );
1310
+ ci.params [ctx->idf (" CFG_%c.CP_FILTER_CONST" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 5 , 5 ) , 5 );
1311
+ ci.params [ctx->idf (" CFG_%c.N1" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 10 , 6 ) , 6 );
1312
+ ci.params [ctx->idf (" CFG_%c.N2" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 16 , 10 ) , 10 );
1313
+ ci.params [ctx->idf (" CFG_%c.M1" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 26 , 6 ) , 6 );
1314
+ ci.params [ctx->idf (" CFG_%c.M2" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 32 , 10 ) , 10 );
1315
+ ci.params [ctx->idf (" CFG_%c.K" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 42 , 12 ) , 12 );
1316
+ ci.params [ctx->idf (" CFG_%c.FB_PATH" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 54 , 1 ) , 1 );
1317
+ ci.params [ctx->idf (" CFG_%c.FINE_TUNE" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 55 , 11 ) , 11 );
1318
+ ci.params [ctx->idf (" CFG_%c.COARSE_TUNE" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 66 , 3 ) , 3 );
1319
+ ci.params [ctx->idf (" CFG_%c.AO_SW" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 69 , 5 ) , 5 );
1320
+ ci.params [ctx->idf (" CFG_%c.OPEN_LOOP" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 74 , 1 ) , 1 );
1321
+ ci.params [ctx->idf (" CFG_%c.ENFORCE_LOCK" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 75 , 1 ) , 1 );
1322
+ ci.params [ctx->idf (" CFG_%c.PFD_SEL" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 76 , 1 ) , 1 );
1323
+ ci.params [ctx->idf (" CFG_%c.LOCK_DETECT_WIN" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 77 , 1 ) , 1 );
1324
+ ci.params [ctx->idf (" CFG_%c.SYNC_BYPASS" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 78 , 1 ) , 1 );
1325
+ ci.params [ctx->idf (" CFG_%c.FILTER_SHIFT" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 79 , 2 ) , 2 );
1326
+ ci.params [ctx->idf (" CFG_%c.FAST_LOCK" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 81 , 1 ) , 1 );
1327
+ ci.params [ctx->idf (" CFG_%c.SAR_LIMIT" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 82 , 3 ) , 3 );
1328
+ ci.params [ctx->idf (" CFG_%c.OP_LOCK" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 85 , 1 ) , 1 );
1329
+ ci.params [ctx->idf (" CFG_%c.PDIV1_SEL" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 86 , 1 ) , 1 );
1330
+ ci.params [ctx->idf (" CFG_%c.PDIV0_MUX" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 87 , 1 ) , 1 );
1331
+ ci.params [ctx->idf (" CFG_%c.EN_COARSE_TUNE" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 88 , 1 ) , 1 );
1332
+ ci.params [ctx->idf (" CFG_%c.EN_USR_CFG" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 89 , 1 ) , 1 );
1333
+ ci.params [ctx->idf (" CFG_%c.PLL_EN_SEL" ,cfg)] = Property (extract_bits_or_default (ci.params , id, 90 , 1 ) , 1 );
1334
+ }
1335
+ NetInfo *select_net = ci.getPort (id_USR_SEL_A_B);
1336
+ if (select_net->name == ctx->id (" $PACKER_GND" )) {
1337
+ ci.params [ctx->id (" SET_SEL" )] = Property (0b0 , 1 );
1338
+ ci.params [ctx->id (" USR_SET" )] = Property (0b0 , 1 );
1339
+ ci.disconnectPort (id_USR_SEL_A_B);
1340
+ } else if (select_net->name == ctx->id (" $PACKER_VCC" )) {
1341
+ ci.params [ctx->id (" SET_SEL" )] = Property (0b1 , 1 );
1342
+ ci.params [ctx->id (" USR_SET" )] = Property (0b0 , 1 );
1343
+ ci.disconnectPort (id_USR_SEL_A_B);
1344
+ } else {
1345
+ ci.params [ctx->id (" USR_SET" )] = Property (0b1 , 1 );
1346
+ }
1347
+ ci.params [ctx->id (" LOCK_REQ" )] = Property (0b1 , 1 );
1348
+ ci.unsetParam (id_PLL_CFG_A);
1349
+ ci.unsetParam (id_PLL_CFG_B);
1350
+
1351
+ ci.type = id_PLL;
1352
+ }
1282
1353
}
1283
1354
1284
1355
void GateMatePacker::pack_misc ()
0 commit comments