mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Add "mutate -s <filename>"
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
		
							parent
							
								
									2cf71e2a7b
								
							
						
					
					
						commit
						59c44bb61a
					
				
					 1 changed files with 24 additions and 2 deletions
				
			
		| 
						 | 
					@ -422,8 +422,9 @@ void database_reduce(std::vector<mutate_t> &database, const mutate_opts_t &opts,
 | 
				
			||||||
	log("Covered %d/%d wire bits (%.2f%%).\n", covered_wirebit_cnt, GetSize(coverdb.wirebit_db), 100.0 * covered_wirebit_cnt / GetSize(coverdb.wirebit_db));
 | 
						log("Covered %d/%d wire bits (%.2f%%).\n", covered_wirebit_cnt, GetSize(coverdb.wirebit_db), 100.0 * covered_wirebit_cnt / GetSize(coverdb.wirebit_db));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void mutate_list(Design *design, const mutate_opts_t &opts, const string &filename, int N)
 | 
					void mutate_list(Design *design, const mutate_opts_t &opts, const string &filename, const string &srcsfile, int N)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						pool<string> sources;
 | 
				
			||||||
	std::vector<mutate_t> database;
 | 
						std::vector<mutate_t> database;
 | 
				
			||||||
	xs128_t rng(opts.seed);
 | 
						xs128_t rng(opts.seed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -497,6 +498,9 @@ void mutate_list(Design *design, const mutate_opts_t &opts, const string &filena
 | 
				
			||||||
						entry.wirebit = bit.offset;
 | 
											entry.wirebit = bit.offset;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (!srcsfile.empty())
 | 
				
			||||||
 | 
											sources.insert(entry.src.begin(), entry.src.end());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					entry.mode = "inv";
 | 
										entry.mode = "inv";
 | 
				
			||||||
					database_add(database, opts, entry);
 | 
										database_add(database, opts, entry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -526,6 +530,16 @@ void mutate_list(Design *design, const mutate_opts_t &opts, const string &filena
 | 
				
			||||||
		log("Reduced database size: %d\n", GetSize(database));
 | 
							log("Reduced database size: %d\n", GetSize(database));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!srcsfile.empty()) {
 | 
				
			||||||
 | 
							std::ofstream sout;
 | 
				
			||||||
 | 
							sout.open(srcsfile, std::ios::out | std::ios::trunc);
 | 
				
			||||||
 | 
							if (!sout.is_open())
 | 
				
			||||||
 | 
								log_error("Could not open file \"%s\" with write access.\n", srcsfile.c_str());
 | 
				
			||||||
 | 
							sources.sort();
 | 
				
			||||||
 | 
							for (auto &s : sources)
 | 
				
			||||||
 | 
								sout << s << std::endl;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::ofstream fout;
 | 
						std::ofstream fout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!filename.empty()) {
 | 
						if (!filename.empty()) {
 | 
				
			||||||
| 
						 | 
					@ -710,6 +724,9 @@ struct MutatePass : public Pass {
 | 
				
			||||||
		log("    -o filename\n");
 | 
							log("    -o filename\n");
 | 
				
			||||||
		log("        Write list to this file instead of console output\n");
 | 
							log("        Write list to this file instead of console output\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
 | 
							log("    -s filename\n");
 | 
				
			||||||
 | 
							log("        Write a list of all src tags found in the design to the specified file\n");
 | 
				
			||||||
 | 
							log("\n");
 | 
				
			||||||
		log("    -seed N\n");
 | 
							log("    -seed N\n");
 | 
				
			||||||
		log("        RNG seed for selecting mutations\n");
 | 
							log("        RNG seed for selecting mutations\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
| 
						 | 
					@ -761,6 +778,7 @@ struct MutatePass : public Pass {
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		mutate_opts_t opts;
 | 
							mutate_opts_t opts;
 | 
				
			||||||
		string filename;
 | 
							string filename;
 | 
				
			||||||
 | 
							string srcsfile;
 | 
				
			||||||
		int N = -1;
 | 
							int N = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log_header(design, "Executing MUTATE pass.\n");
 | 
							log_header(design, "Executing MUTATE pass.\n");
 | 
				
			||||||
| 
						 | 
					@ -776,6 +794,10 @@ struct MutatePass : public Pass {
 | 
				
			||||||
				filename = args[++argidx];
 | 
									filename = args[++argidx];
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (args[argidx] == "-s" && argidx+1 < args.size()) {
 | 
				
			||||||
 | 
									srcsfile = args[++argidx];
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if (args[argidx] == "-seed" && argidx+1 < args.size()) {
 | 
								if (args[argidx] == "-seed" && argidx+1 < args.size()) {
 | 
				
			||||||
				opts.seed = atoi(args[++argidx].c_str());
 | 
									opts.seed = atoi(args[++argidx].c_str());
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
| 
						 | 
					@ -879,7 +901,7 @@ struct MutatePass : public Pass {
 | 
				
			||||||
		extra_args(args, argidx, design);
 | 
							extra_args(args, argidx, design);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (N >= 0) {
 | 
							if (N >= 0) {
 | 
				
			||||||
			mutate_list(design, opts, filename, N);
 | 
								mutate_list(design, opts, filename, srcsfile, N);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue