mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	More comments
This commit is contained in:
		
							parent
							
								
									389518a8f0
								
							
						
					
					
						commit
						f6d67ac21e
					
				
					 2 changed files with 19 additions and 6 deletions
				
			
		|  | @ -28,6 +28,8 @@ struct ActivityProp { | |||
| 	Module *module; | ||||
| 	SigMap sigmap; | ||||
| 
 | ||||
| 	// Split a string based on separator, returns a vector of tokens as reference argument
 | ||||
| 	// If skipEmpty is true, return "" for string "    ", when separator is " "
 | ||||
| 	void tokenize(std::string_view str, std::string_view separator, std::vector<std::string> &result, bool skipEmpty) | ||||
| 	{ | ||||
| 		std::string::size_type pos{0}; | ||||
|  | @ -49,6 +51,8 @@ struct ActivityProp { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	// Split a string based on separator, returns a vector of tokens
 | ||||
| 	// If skipEmpty is true, return "" for string "    ", when separator is " "
 | ||||
| 	std::vector<std::string> tokenize(std::string_view str, std::string_view separator, bool skipEmpty) | ||||
| 	{ | ||||
| 		std::vector<std::string> result; | ||||
|  | @ -63,10 +67,14 @@ struct ActivityProp { | |||
| 		// Build {signal bit - activity} map from the wire activities calculated in the sim pass
 | ||||
| 		for (Wire *wire : module->wires()) { | ||||
| 			SigSpec sig(sigmap(wire)); | ||||
| 			// Retrieve the activity/dutycycle attributes created in the sim pass, attached to wires, in the form:
 | ||||
| 			// $ACKT: 0.1 0.2 .... (Each bit in a bus has its own activity, index 0 of the bus is left most)
 | ||||
| 			std::string act = wire->get_string_attribute("$ACKT"); | ||||
| 			std::string duty = wire->get_string_attribute("$DUTY"); | ||||
| 			// Split the activity lists
 | ||||
| 			std::vector<std::string> activities = tokenize(act, " ", true); | ||||
| 			std::vector<std::string> duties = tokenize(duty, " ", true); | ||||
| 			// Assign them to each SigBit (1 signal bit)
 | ||||
| 			for (int i = 0; i < GetSize(sig); i++) { | ||||
| 				SigBit bit(sig[i]); | ||||
| 				ActivityMap.emplace(bit, activities[i]); | ||||
|  | @ -78,6 +86,7 @@ struct ActivityProp { | |||
| 			std::string cell_ports_activity; | ||||
| 			std::string cell_ports_duty; | ||||
| 			for (auto conn : cell->connections()) { | ||||
| 				// Recombine individual bit activities for all cell ports into a list attached to the cell
 | ||||
| 				for (int i = 0; i < GetSize(conn.second); i++) { | ||||
| 					SigBit bit(sigmap(conn.second[i])); | ||||
| 					std::string port_name = std::string(conn.first.c_str()) + "[" + std::to_string(i) + "]"; | ||||
|  | @ -109,6 +118,8 @@ struct ActivityProp { | |||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			// Annotate on cells the complete list of ports activities and dutycycles in the form:
 | ||||
| 			// $ACKT: \P1=0.1 \P2=0.2 ....
 | ||||
| 			cell->set_string_attribute("$ACKT:", cell_ports_activity); | ||||
| 			cell->set_string_attribute("$DUTY:", cell_ports_duty); | ||||
| 		} | ||||
|  |  | |||
|  | @ -2449,9 +2449,9 @@ struct AnnotateActivity : public OutputWriter { | |||
| 					continue; | ||||
| 				Const value = data.second; | ||||
| 				SignalActivityDataMap::iterator itr = dataMap.find(sig); | ||||
| 				std::vector<uint32_t> &lastVals = (*itr).second.lastValues; | ||||
| 				std::vector<uint32_t> &toggleCounts = (*itr).second.toggleCounts; | ||||
| 				std::vector<uint32_t> &highTimes = (*itr).second.highTimes; | ||||
| 				std::vector<uint32_t> &lastVals = itr->second.lastValues; | ||||
| 				std::vector<uint32_t> &toggleCounts = itr->second.toggleCounts; | ||||
| 				std::vector<uint32_t> &highTimes = itr->second.highTimes; | ||||
| 				for (int i = GetSize(value) - 1; i >= 0; i--) { | ||||
| 					int val = '-'; | ||||
| 					switch (value[i]) { | ||||
|  | @ -2467,6 +2467,7 @@ struct AnnotateActivity : public OutputWriter { | |||
| 					default: | ||||
| 						val = 'z'; | ||||
| 					} | ||||
| 					// If signal toggled
 | ||||
| 					if (val != lastVals[i]) { | ||||
| 						toggleCounts[i]++; | ||||
| 						if (toggleCounts[i] > highest_toggle) { | ||||
|  | @ -2492,11 +2493,12 @@ struct AnnotateActivity : public OutputWriter { | |||
| 		if (timescale == "fs") | ||||
| 			real_timescale = 1e-15; | ||||
| 
 | ||||
| 		// TODO: remove all debug sections when dev is completed
 | ||||
| 		bool debug = false; | ||||
| 
 | ||||
| 		// Compute clock period, find the highest toggling signal and compute its average period
 | ||||
| 		SignalActivityDataMap::iterator itr = dataMap.find(clk); | ||||
| 		std::vector<uint32_t> &clktoggleCounts = (*itr).second.toggleCounts; | ||||
| 		std::vector<uint32_t> &clktoggleCounts = itr->second.toggleCounts; | ||||
| 		double clk_period = real_timescale * (double)max_time / (clktoggleCounts[0] / 2); | ||||
| 		if (debug) { | ||||
| 			std::cout << "Clock toggle count: " << clktoggleCounts[0] << "\n"; | ||||
|  | @ -2518,8 +2520,8 @@ struct AnnotateActivity : public OutputWriter { | |||
| 					return; | ||||
| 				std::string full_name = form_vcd_name(name, size, w); | ||||
| 				SignalActivityDataMap::const_iterator itr = dataMap.find(id); | ||||
| 				const std::vector<uint32_t> &toggleCounts = (*itr).second.toggleCounts; | ||||
| 				const std::vector<uint32_t> &highTimes = (*itr).second.highTimes; | ||||
| 				const std::vector<uint32_t> &toggleCounts = itr->second.toggleCounts; | ||||
| 				const std::vector<uint32_t> &highTimes = itr->second.highTimes; | ||||
| 				if (debug) { | ||||
| 					std::cout << full_name << ":\n"; | ||||
| 					std::cout << "     TC: "; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue