mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	greenpak4_counters: Changed generation of primitive names so that the absorbed register's name is included
This commit is contained in:
		
							parent
							
								
									155a80dfb7
								
							
						
					
					
						commit
						cbdddc3af9
					
				
					 1 changed files with 21 additions and 3 deletions
				
			
		|  | @ -280,7 +280,8 @@ void greenpak4_counters_worker( | ||||||
| 	ModIndex& index, | 	ModIndex& index, | ||||||
| 	Cell *cell, | 	Cell *cell, | ||||||
| 	unsigned int& total_counters, | 	unsigned int& total_counters, | ||||||
| 	pool<Cell*>& cells_to_remove) | 	pool<Cell*>& cells_to_remove, | ||||||
|  | 	pool<pair<Cell*, string>>& cells_to_rename) | ||||||
| { | { | ||||||
| 	SigMap& sigmap = index.sigmap; | 	SigMap& sigmap = index.sigmap; | ||||||
| 
 | 
 | ||||||
|  | @ -376,6 +377,9 @@ void greenpak4_counters_worker( | ||||||
| 	if(extract.width > 8) | 	if(extract.width > 8) | ||||||
| 		celltype = "\\GP_COUNT14"; | 		celltype = "\\GP_COUNT14"; | ||||||
| 
 | 
 | ||||||
|  | 	//Get new cell name
 | ||||||
|  | 	string countname = string("$auto$GP_COUNTx$") + log_id(extract.rwire->name.str()); | ||||||
|  | 
 | ||||||
| 	//Log it
 | 	//Log it
 | ||||||
| 	total_counters ++; | 	total_counters ++; | ||||||
| 	string reset_type = "non-resettable"; | 	string reset_type = "non-resettable"; | ||||||
|  | @ -384,9 +388,10 @@ void greenpak4_counters_worker( | ||||||
| 		//TODO: support other kind of reset
 | 		//TODO: support other kind of reset
 | ||||||
| 		reset_type = "async resettable"; | 		reset_type = "async resettable"; | ||||||
| 	} | 	} | ||||||
| 	log("  Found %d-bit %s down counter (counting from %d) for register %s declared at %s\n", | 	log("  Found %d-bit %s down counter %s (counting from %d) for register %s declared at %s\n", | ||||||
| 		extract.width, | 		extract.width, | ||||||
| 		reset_type.c_str(), | 		reset_type.c_str(), | ||||||
|  | 		countname.c_str(), | ||||||
| 		extract.count_value, | 		extract.count_value, | ||||||
| 		log_id(extract.rwire->name), | 		log_id(extract.rwire->name), | ||||||
| 		count_reg_src.c_str()); | 		count_reg_src.c_str()); | ||||||
|  | @ -445,6 +450,9 @@ void greenpak4_counters_worker( | ||||||
| 	cells_to_remove.insert(extract.count_mux); | 	cells_to_remove.insert(extract.count_mux); | ||||||
| 	cells_to_remove.insert(extract.count_reg); | 	cells_to_remove.insert(extract.count_reg); | ||||||
| 	cells_to_remove.insert(extract.underflow_inv); | 	cells_to_remove.insert(extract.underflow_inv); | ||||||
|  | 
 | ||||||
|  | 	//Finally, rename the cell
 | ||||||
|  | 	cells_to_rename.insert(pair<Cell*, string>(cell, countname)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct Greenpak4CountersPass : public Pass { | struct Greenpak4CountersPass : public Pass { | ||||||
|  | @ -478,15 +486,25 @@ struct Greenpak4CountersPass : public Pass { | ||||||
| 		for (auto module : design->selected_modules()) | 		for (auto module : design->selected_modules()) | ||||||
| 		{ | 		{ | ||||||
| 			pool<Cell*> cells_to_remove; | 			pool<Cell*> cells_to_remove; | ||||||
|  | 			pool<pair<Cell*, string>> cells_to_rename; | ||||||
| 
 | 
 | ||||||
| 			ModIndex index(module); | 			ModIndex index(module); | ||||||
| 			for (auto cell : module->selected_cells()) | 			for (auto cell : module->selected_cells()) | ||||||
| 				greenpak4_counters_worker(index, cell, total_counters, cells_to_remove); | 				greenpak4_counters_worker(index, cell, total_counters, cells_to_remove, cells_to_rename); | ||||||
| 
 | 
 | ||||||
| 			for(auto cell : cells_to_remove) | 			for(auto cell : cells_to_remove) | ||||||
|  | 			{ | ||||||
|  | 				//log("Removing cell %s\n", log_id(cell->name));
 | ||||||
| 				module->remove(cell); | 				module->remove(cell); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			for(auto cpair : cells_to_rename) | ||||||
|  | 			{ | ||||||
|  | 				//log("Renaming cell %s to %s\n", log_id(cpair.first->name), cpair.second.c_str());
 | ||||||
|  | 				module->rename(cpair.first, cpair.second); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		if(total_counters) | 		if(total_counters) | ||||||
| 			log("Extracted %u counters\n", total_counters); | 			log("Extracted %u counters\n", total_counters); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue