Skip to content

Commit cbdddc3

Browse files
committedJun 24, 2017
greenpak4_counters: Changed generation of primitive names so that the absorbed register's name is included
1 parent 155a80d commit cbdddc3

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed
 

Diff for: ‎techlibs/greenpak4/greenpak4_counters.cc

+21-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void greenpak4_counters_worker(
280280
ModIndex& index,
281281
Cell *cell,
282282
unsigned int& total_counters,
283-
pool<Cell*>& cells_to_remove)
283+
pool<Cell*>& cells_to_remove,
284+
pool<pair<Cell*, string>>& cells_to_rename)
284285
{
285286
SigMap& sigmap = index.sigmap;
286287

@@ -376,6 +377,9 @@ void greenpak4_counters_worker(
376377
if(extract.width > 8)
377378
celltype = "\\GP_COUNT14";
378379

380+
//Get new cell name
381+
string countname = string("$auto$GP_COUNTx$") + log_id(extract.rwire->name.str());
382+
379383
//Log it
380384
total_counters ++;
381385
string reset_type = "non-resettable";
@@ -384,9 +388,10 @@ void greenpak4_counters_worker(
384388
//TODO: support other kind of reset
385389
reset_type = "async resettable";
386390
}
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",
388392
extract.width,
389393
reset_type.c_str(),
394+
countname.c_str(),
390395
extract.count_value,
391396
log_id(extract.rwire->name),
392397
count_reg_src.c_str());
@@ -445,6 +450,9 @@ void greenpak4_counters_worker(
445450
cells_to_remove.insert(extract.count_mux);
446451
cells_to_remove.insert(extract.count_reg);
447452
cells_to_remove.insert(extract.underflow_inv);
453+
454+
//Finally, rename the cell
455+
cells_to_rename.insert(pair<Cell*, string>(cell, countname));
448456
}
449457

450458
struct Greenpak4CountersPass : public Pass {
@@ -478,13 +486,23 @@ struct Greenpak4CountersPass : public Pass {
478486
for (auto module : design->selected_modules())
479487
{
480488
pool<Cell*> cells_to_remove;
489+
pool<pair<Cell*, string>> cells_to_rename;
481490

482491
ModIndex index(module);
483492
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);
485494

486495
for(auto cell : cells_to_remove)
496+
{
497+
//log("Removing cell %s\n", log_id(cell->name));
487498
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+
}
488506
}
489507

490508
if(total_counters)

0 commit comments

Comments
 (0)
Please sign in to comment.