mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	sim: Include $display output in JSON summary
This allows tools like SBY to capture the $display output independent from anything else sim might log. Additionally it provides source and hierarchy locations for everything printed.
This commit is contained in:
		
							parent
							
								
									eeadbb583e
								
							
						
					
					
						commit
						57b4e16acd
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		|  | @ -88,6 +88,17 @@ struct TriggeredAssertion { | |||
| 	{ } | ||||
| }; | ||||
| 
 | ||||
| struct DisplayOutput { | ||||
| 	int step; | ||||
| 	SimInstance *instance; | ||||
| 	Cell *cell; | ||||
| 	std::string output; | ||||
| 
 | ||||
| 	DisplayOutput(int step, SimInstance *instance, Cell *cell, std::string output) : | ||||
| 		step(step), instance(instance), cell(cell), output(output) | ||||
| 	{ } | ||||
| }; | ||||
| 
 | ||||
| struct SimShared | ||||
| { | ||||
| 	bool debug = false; | ||||
|  | @ -110,6 +121,7 @@ struct SimShared | |||
| 	int next_output_id = 0; | ||||
| 	int step = 0; | ||||
| 	std::vector<TriggeredAssertion> triggered_assertions; | ||||
| 	std::vector<DisplayOutput> display_output; | ||||
| 	bool serious_asserts = false; | ||||
| 	bool initstate = true; | ||||
| }; | ||||
|  | @ -870,6 +882,7 @@ struct SimInstance | |||
| 
 | ||||
| 				std::string rendered = print.fmt.render(); | ||||
| 				log("%s", rendered.c_str()); | ||||
| 				shared->display_output.emplace_back(shared->step, this, cell, rendered); | ||||
| 			} | ||||
| 
 | ||||
| 		update_print: | ||||
|  | @ -2055,6 +2068,20 @@ struct SimWorker : SimShared | |||
| 			json.end_object(); | ||||
| 		} | ||||
| 		json.end_array(); | ||||
| 		json.name("display_output"); | ||||
| 		json.begin_array(); | ||||
| 		for (auto &output : display_output) { | ||||
| 			json.begin_object(); | ||||
| 			json.entry("step", output.step); | ||||
| 			json.entry("path", output.instance->witness_full_path(output.cell)); | ||||
| 			auto src = output.cell->get_string_attribute(ID::src); | ||||
| 			if (!src.empty()) { | ||||
| 				json.entry("src", src); | ||||
| 			} | ||||
| 			json.entry("output", output.output); | ||||
| 			json.end_object(); | ||||
| 		} | ||||
| 		json.end_array(); | ||||
| 		json.end_object(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue