mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Add "wbflip" command
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
		
							parent
							
								
									8f93999129
								
							
						
					
					
						commit
						5b915f0153
					
				
					 3 changed files with 45 additions and 3 deletions
				
			
		|  | @ -207,9 +207,12 @@ bool RTLIL::Const::is_fully_undef() const | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id) | void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id, bool value) | ||||||
| { | { | ||||||
| 	attributes[id] = RTLIL::Const(1); | 	if (value) | ||||||
|  | 		attributes[id] = RTLIL::Const(1); | ||||||
|  | 	else if (attributes.count(id)) | ||||||
|  | 		attributes.erase(id); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool RTLIL::AttrObject::get_bool_attribute(RTLIL::IdString id) const | bool RTLIL::AttrObject::get_bool_attribute(RTLIL::IdString id) const | ||||||
|  |  | ||||||
|  | @ -566,7 +566,7 @@ struct RTLIL::AttrObject | ||||||
| { | { | ||||||
| 	dict<RTLIL::IdString, RTLIL::Const> attributes; | 	dict<RTLIL::IdString, RTLIL::Const> attributes; | ||||||
| 
 | 
 | ||||||
| 	void set_bool_attribute(RTLIL::IdString id); | 	void set_bool_attribute(RTLIL::IdString id, bool value=true); | ||||||
| 	bool get_bool_attribute(RTLIL::IdString id) const; | 	bool get_bool_attribute(RTLIL::IdString id) const; | ||||||
| 
 | 
 | ||||||
| 	bool get_blackbox_attribute(bool ignore_wb=false) const { | 	bool get_blackbox_attribute(bool ignore_wb=false) const { | ||||||
|  |  | ||||||
|  | @ -128,6 +128,45 @@ struct SetattrPass : public Pass { | ||||||
| 	} | 	} | ||||||
| } SetattrPass; | } SetattrPass; | ||||||
| 
 | 
 | ||||||
|  | struct WbflipPass : public Pass { | ||||||
|  | 	WbflipPass() : Pass("wbflip", "flip the whitebox attribute") { } | ||||||
|  | 	void help() YS_OVERRIDE | ||||||
|  | 	{ | ||||||
|  | 		//   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
 | ||||||
|  | 		log("\n"); | ||||||
|  | 		log("    wbflip [selection]\n"); | ||||||
|  | 		log("\n"); | ||||||
|  | 		log("Flip the whitebox attribute on selected cells. I.e. if it's set, unset it, and\n"); | ||||||
|  | 		log("vice-versa. Blackbox cells are not effected by this command.\n"); | ||||||
|  | 		log("\n"); | ||||||
|  | 	} | ||||||
|  | 	void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE | ||||||
|  | 	{ | ||||||
|  | 		size_t argidx; | ||||||
|  | 		for (argidx = 1; argidx < args.size(); argidx++) | ||||||
|  | 		{ | ||||||
|  | 			std::string arg = args[argidx]; | ||||||
|  | 			// if (arg == "-mod") {
 | ||||||
|  | 			// 	flag_mod = true;
 | ||||||
|  | 			// 	continue;
 | ||||||
|  | 			// }
 | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		extra_args(args, argidx, design); | ||||||
|  | 
 | ||||||
|  | 		for (Module *module : design->modules()) | ||||||
|  | 		{ | ||||||
|  | 			if (!design->selected(module)) | ||||||
|  | 				continue; | ||||||
|  | 
 | ||||||
|  | 			if (module->get_bool_attribute("\\blackbox")) | ||||||
|  | 				continue; | ||||||
|  | 
 | ||||||
|  | 			module->set_bool_attribute("\\whitebox", !module->get_bool_attribute("\\whitebox")); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } WbflipPass; | ||||||
|  | 
 | ||||||
| struct SetparamPass : public Pass { | struct SetparamPass : public Pass { | ||||||
| 	SetparamPass() : Pass("setparam", "set/unset parameters on objects") { } | 	SetparamPass() : Pass("setparam", "set/unset parameters on objects") { } | ||||||
| 	void help() YS_OVERRIDE | 	void help() YS_OVERRIDE | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue