@@ -280,7 +280,8 @@ void greenpak4_counters_worker(
280
280
ModIndex& index,
281
281
Cell *cell,
282
282
unsigned int & total_counters,
283
- pool<Cell*>& cells_to_remove)
283
+ pool<Cell*>& cells_to_remove,
284
+ pool<pair<Cell*, string>>& cells_to_rename)
284
285
{
285
286
SigMap& sigmap = index .sigmap ;
286
287
@@ -376,6 +377,9 @@ void greenpak4_counters_worker(
376
377
if (extract.width > 8 )
377
378
celltype = " \\ GP_COUNT14" ;
378
379
380
+ // Get new cell name
381
+ string countname = string (" $auto$GP_COUNTx$" ) + log_id (extract.rwire ->name .str ());
382
+
379
383
// Log it
380
384
total_counters ++;
381
385
string reset_type = " non-resettable" ;
@@ -384,9 +388,10 @@ void greenpak4_counters_worker(
384
388
// TODO: support other kind of reset
385
389
reset_type = " async resettable" ;
386
390
}
387
- log (" Found %d-bit %s down counter (counting from %d) for register %s declared at %s\n " ,
391
+ log (" Found %d-bit %s down counter %s (counting from %d) for register %s declared at %s\n " ,
388
392
extract.width ,
389
393
reset_type.c_str (),
394
+ countname.c_str (),
390
395
extract.count_value ,
391
396
log_id (extract.rwire ->name ),
392
397
count_reg_src.c_str ());
@@ -445,6 +450,9 @@ void greenpak4_counters_worker(
445
450
cells_to_remove.insert (extract.count_mux );
446
451
cells_to_remove.insert (extract.count_reg );
447
452
cells_to_remove.insert (extract.underflow_inv );
453
+
454
+ // Finally, rename the cell
455
+ cells_to_rename.insert (pair<Cell*, string>(cell, countname));
448
456
}
449
457
450
458
struct Greenpak4CountersPass : public Pass {
@@ -478,13 +486,23 @@ struct Greenpak4CountersPass : public Pass {
478
486
for (auto module : design->selected_modules ())
479
487
{
480
488
pool<Cell*> cells_to_remove;
489
+ pool<pair<Cell*, string>> cells_to_rename;
481
490
482
491
ModIndex index (module);
483
492
for (auto cell : module->selected_cells ())
484
- greenpak4_counters_worker (index , cell, total_counters, cells_to_remove);
493
+ greenpak4_counters_worker (index , cell, total_counters, cells_to_remove, cells_to_rename );
485
494
486
495
for (auto cell : cells_to_remove)
496
+ {
497
+ // log("Removing cell %s\n", log_id(cell->name));
487
498
module->remove (cell);
499
+ }
500
+
501
+ for (auto cpair : cells_to_rename)
502
+ {
503
+ // log("Renaming cell %s to %s\n", log_id(cpair.first->name), cpair.second.c_str());
504
+ module->rename (cpair.first , cpair.second );
505
+ }
488
506
}
489
507
490
508
if (total_counters)
0 commit comments