mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	new option for "stat" to write to a file
This commit is contained in:
		
							parent
							
								
									68c99bf734
								
							
						
					
					
						commit
						86f3e2402f
					
				
					 1 changed files with 25 additions and 0 deletions
				
			
		| 
						 | 
					@ -154,6 +154,9 @@ struct StatPass : public Pass {
 | 
				
			||||||
		log("        selected and a module has the 'top' attribute set, this module is used\n");
 | 
							log("        selected and a module has the 'top' attribute set, this module is used\n");
 | 
				
			||||||
		log("        default value for this option.\n");
 | 
							log("        default value for this option.\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
 | 
							log("    -o <filename>\n");
 | 
				
			||||||
 | 
							log("        additionally write output to the given file\n");
 | 
				
			||||||
 | 
							log("\n");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
 | 
						virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -161,6 +164,7 @@ struct StatPass : public Pass {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		RTLIL::Module *top_mod = NULL;
 | 
							RTLIL::Module *top_mod = NULL;
 | 
				
			||||||
		std::map<RTLIL::IdString, statdata_t> mod_stat;
 | 
							std::map<RTLIL::IdString, statdata_t> mod_stat;
 | 
				
			||||||
 | 
							FILE* outfile = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		size_t argidx;
 | 
							size_t argidx;
 | 
				
			||||||
		for (argidx = 1; argidx < args.size(); argidx++)
 | 
							for (argidx = 1; argidx < args.size(); argidx++)
 | 
				
			||||||
| 
						 | 
					@ -171,6 +175,16 @@ struct StatPass : public Pass {
 | 
				
			||||||
				top_mod = design->modules.at(RTLIL::escape_id(args[++argidx]));
 | 
									top_mod = design->modules.at(RTLIL::escape_id(args[++argidx]));
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (args[argidx] == "-o" && argidx+1 < args.size()) {
 | 
				
			||||||
 | 
									++argidx;
 | 
				
			||||||
 | 
									outfile = fopen(args[argidx].c_str(), "wt");
 | 
				
			||||||
 | 
									if (outfile == NULL) {
 | 
				
			||||||
 | 
										log_cmd_error("Can't create file %s.\n",args[argidx].c_str());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									// append our logfile to the log_files vector
 | 
				
			||||||
 | 
									log_files.push_back(outfile);
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		extra_args(args, argidx, design);
 | 
							extra_args(args, argidx, design);
 | 
				
			||||||
| 
						 | 
					@ -206,6 +220,17 @@ struct StatPass : public Pass {
 | 
				
			||||||
			data.log_data();
 | 
								data.log_data();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (outfile != NULL)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								// remove outfile from log_files
 | 
				
			||||||
 | 
								if (log_files.back() != outfile) {
 | 
				
			||||||
 | 
									log_cmd_error("List of log files has changed.\n");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								log_files.pop_back();
 | 
				
			||||||
 | 
								fclose(outfile);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} StatPass;
 | 
					} StatPass;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue