mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	Added log_const() API
This commit is contained in:
		
							parent
							
								
									3c6d31fd06
								
							
						
					
					
						commit
						39da8eddae
					
				
					 2 changed files with 19 additions and 0 deletions
				
			
		|  | @ -414,6 +414,24 @@ const char *log_signal(const RTLIL::SigSpec &sig, bool autoint) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const char *log_const(const RTLIL::Const &value, bool autoint) | ||||||
|  | { | ||||||
|  | 	if ((value.flags & RTLIL::CONST_FLAG_STRING) == 0) | ||||||
|  | 		return log_signal(value, autoint); | ||||||
|  | 
 | ||||||
|  | 	std::string str = "\"" + value.decode_string() + "\""; | ||||||
|  | 
 | ||||||
|  | 	if (string_buf.size() < 100) { | ||||||
|  | 		string_buf.push_back(str); | ||||||
|  | 		return string_buf.back().c_str(); | ||||||
|  | 	} else { | ||||||
|  | 		if (++string_buf_index == 100) | ||||||
|  | 			string_buf_index = 0; | ||||||
|  | 		string_buf[string_buf_index] = str; | ||||||
|  | 		return string_buf[string_buf_index].c_str(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| const char *log_id(RTLIL::IdString str) | const char *log_id(RTLIL::IdString str) | ||||||
| { | { | ||||||
| 	log_id_cache.insert(str); | 	log_id_cache.insert(str); | ||||||
|  |  | ||||||
|  | @ -79,6 +79,7 @@ void log_reset_stack(); | ||||||
| void log_flush(); | void log_flush(); | ||||||
| 
 | 
 | ||||||
| const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); | const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); | ||||||
|  | const char *log_const(const RTLIL::Const &value, bool autoint = true); | ||||||
| const char *log_id(RTLIL::IdString id); | const char *log_id(RTLIL::IdString id); | ||||||
| 
 | 
 | ||||||
| template<typename T> static inline const char *log_id(T *obj) { | template<typename T> static inline const char *log_id(T *obj) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue