mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	Merge pull request #1929 from YosysHQ/eddie/select_unset
select: add select -unset option
This commit is contained in:
		
						commit
						31e3e52988
					
				
					 4 changed files with 43 additions and 3 deletions
				
			
		|  | @ -65,6 +65,7 @@ Yosys 0.9 .. Yosys 0.9-dev | ||||||
|     - Added "logger" pass |     - Added "logger" pass | ||||||
|     - Removed "dffsr2dff" (use opt_rmdff instead) |     - Removed "dffsr2dff" (use opt_rmdff instead) | ||||||
|     - Added "design -delete" |     - Added "design -delete" | ||||||
|  |     - Added "select -unset" | ||||||
| 
 | 
 | ||||||
| Yosys 0.8 .. Yosys 0.9 | Yosys 0.8 .. Yosys 0.9 | ||||||
| ---------------------- | ---------------------- | ||||||
|  |  | ||||||
|  | @ -1007,6 +1007,7 @@ struct SelectPass : public Pass { | ||||||
| 		//   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
 | 		//   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
 | ||||||
| 		log("\n"); | 		log("\n"); | ||||||
| 		log("    select [ -add | -del | -set <name> ] {-read <filename> | <selection>}\n"); | 		log("    select [ -add | -del | -set <name> ] {-read <filename> | <selection>}\n"); | ||||||
|  | 		log("    select [ -unset <name> ]\n"); | ||||||
| 		log("    select [ <assert_option> ] {-read <filename> | <selection>}\n"); | 		log("    select [ <assert_option> ] {-read <filename> | <selection>}\n"); | ||||||
| 		log("    select [ -list | -write <filename> | -count | -clear ]\n"); | 		log("    select [ -list | -write <filename> | -count | -clear ]\n"); | ||||||
| 		log("    select -module <modname>\n"); | 		log("    select -module <modname>\n"); | ||||||
|  | @ -1029,6 +1030,10 @@ struct SelectPass : public Pass { | ||||||
| 		log("        under the given name (see @<name> below). to save the current selection,\n"); | 		log("        under the given name (see @<name> below). to save the current selection,\n"); | ||||||
| 		log("        use \"select -set <name> %%\"\n"); | 		log("        use \"select -set <name> %%\"\n"); | ||||||
| 		log("\n"); | 		log("\n"); | ||||||
|  | 		log("    -unset <name>\n"); | ||||||
|  | 		log("        do not modify the current selection. instead remove a previously saved\n"); | ||||||
|  | 		log("        selection under the given name (see @<name> below)."); | ||||||
|  | 		log("\n"); | ||||||
| 		log("    -assert-none\n"); | 		log("    -assert-none\n"); | ||||||
| 		log("        do not modify the current selection. instead assert that the given\n"); | 		log("        do not modify the current selection. instead assert that the given\n"); | ||||||
| 		log("        selection is empty. i.e. produce an error if any object matching the\n"); | 		log("        selection is empty. i.e. produce an error if any object matching the\n"); | ||||||
|  | @ -1238,7 +1243,7 @@ struct SelectPass : public Pass { | ||||||
| 		int assert_max = -1; | 		int assert_max = -1; | ||||||
| 		int assert_min = -1; | 		int assert_min = -1; | ||||||
| 		std::string write_file, read_file; | 		std::string write_file, read_file; | ||||||
| 		std::string set_name, sel_str; | 		std::string set_name, unset_name, sel_str; | ||||||
| 
 | 
 | ||||||
| 		work_stack.clear(); | 		work_stack.clear(); | ||||||
| 
 | 
 | ||||||
|  | @ -1310,6 +1315,10 @@ struct SelectPass : public Pass { | ||||||
| 				set_name = RTLIL::escape_id(args[++argidx]); | 				set_name = RTLIL::escape_id(args[++argidx]); | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
|  | 			if (arg == "-unset" && argidx+1 < args.size()) { | ||||||
|  | 				unset_name = RTLIL::escape_id(args[++argidx]); | ||||||
|  | 				continue; | ||||||
|  | 			} | ||||||
| 			if (arg.size() > 0 && arg[0] == '-') | 			if (arg.size() > 0 && arg[0] == '-') | ||||||
| 				log_cmd_error("Unknown option %s.\n", arg.c_str()); | 				log_cmd_error("Unknown option %s.\n", arg.c_str()); | ||||||
| 			bool disable_empty_warning = count_mode || assert_none || assert_any || (assert_count != -1) || (assert_max != -1) || (assert_min != -1); | 			bool disable_empty_warning = count_mode || assert_none || assert_any || (assert_count != -1) || (assert_max != -1) || (assert_min != -1); | ||||||
|  | @ -1358,8 +1367,11 @@ struct SelectPass : public Pass { | ||||||
| 		if ((list_mode || !write_file.empty() || count_mode) && (add_mode || del_mode || assert_none || assert_any || assert_count >= 0 || assert_max >= 0 || assert_min >= 0)) | 		if ((list_mode || !write_file.empty() || count_mode) && (add_mode || del_mode || assert_none || assert_any || assert_count >= 0 || assert_max >= 0 || assert_min >= 0)) | ||||||
| 			log_cmd_error("Options -list, -write and -count can not be combined with -add, -del, -assert-none, -assert-any, assert-count, -assert-max, or -assert-min.\n"); | 			log_cmd_error("Options -list, -write and -count can not be combined with -add, -del, -assert-none, -assert-any, assert-count, -assert-max, or -assert-min.\n"); | ||||||
| 
 | 
 | ||||||
| 		if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || del_mode || assert_none || assert_any || assert_count >= 0 || assert_max >= 0 || assert_min >= 0)) | 		if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || !unset_name.empty() || del_mode || assert_none || assert_any || assert_count >= 0 || assert_max >= 0 || assert_min >= 0)) | ||||||
| 			log_cmd_error("Option -set can not be combined with -list, -write, -count, -add, -del, -assert-none, -assert-any, -assert-count, -assert-max, or -assert-min.\n"); | 			log_cmd_error("Option -set can not be combined with -list, -write, -count, -add, -del, -unset, -assert-none, -assert-any, -assert-count, -assert-max, or -assert-min.\n"); | ||||||
|  | 
 | ||||||
|  | 		if (!unset_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || !set_name.empty() || del_mode || assert_none || assert_any || assert_count >= 0 || assert_max >= 0 || assert_min >= 0)) | ||||||
|  | 			log_cmd_error("Option -unset can not be combined with -list, -write, -count, -add, -del, -set, -assert-none, -assert-any, -assert-count, -assert-max, or -assert-min.\n"); | ||||||
| 
 | 
 | ||||||
| 		if (work_stack.size() == 0 && got_module) { | 		if (work_stack.size() == 0 && got_module) { | ||||||
| 			RTLIL::Selection sel; | 			RTLIL::Selection sel; | ||||||
|  | @ -1527,6 +1539,13 @@ struct SelectPass : public Pass { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		if (!unset_name.empty()) | ||||||
|  | 		{ | ||||||
|  | 			if (!design->selection_vars.erase(unset_name)) | ||||||
|  | 				log_error("Selection '%s' does not exist!\n", unset_name.c_str()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		if (work_stack.size() == 0) { | 		if (work_stack.size() == 0) { | ||||||
| 			RTLIL::Selection &sel = design->selection_stack.back(); | 			RTLIL::Selection &sel = design->selection_stack.back(); | ||||||
| 			if (sel.full_selection) | 			if (sel.full_selection) | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								tests/select/unset.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								tests/select/unset.ys
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | read_verilog <<EOT | ||||||
|  | module top(input i, output o); | ||||||
|  | assign o = i; | ||||||
|  | endmodule | ||||||
|  | EOT | ||||||
|  | select -set foo w:* | ||||||
|  | select -assert-any @foo | ||||||
|  | select -unset foo | ||||||
|  | logger -expect error "Selection '\\foo' does not exist!" 1 | ||||||
|  | select -unset foo | ||||||
							
								
								
									
										10
									
								
								tests/select/unset2.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								tests/select/unset2.ys
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | read_verilog <<EOT | ||||||
|  | module top(input i, output o); | ||||||
|  | assign o = i; | ||||||
|  | endmodule | ||||||
|  | EOT | ||||||
|  | select -set foo w:* | ||||||
|  | select -assert-any @foo | ||||||
|  | select -unset foo | ||||||
|  | logger -expect error "Selection @foo is not defined!" 1 | ||||||
|  | select -list @foo | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue