mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Add "write_blif -inames -iattr"
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
		
							parent
							
								
									2d7f3123f0
								
							
						
					
					
						commit
						5ca91ca019
					
				
					 1 changed files with 46 additions and 22 deletions
				
			
		|  | @ -38,8 +38,10 @@ struct BlifDumperConfig | |||
| 	bool impltf_mode; | ||||
| 	bool gates_mode; | ||||
| 	bool cname_mode; | ||||
| 	bool iname_mode; | ||||
| 	bool param_mode; | ||||
| 	bool attr_mode; | ||||
| 	bool iattr_mode; | ||||
| 	bool blackbox_mode; | ||||
| 	bool noalias_mode; | ||||
| 
 | ||||
|  | @ -48,7 +50,8 @@ struct BlifDumperConfig | |||
| 	std::string true_type, true_out, false_type, false_out, undef_type, undef_out; | ||||
| 
 | ||||
| 	BlifDumperConfig() : icells_mode(false), conn_mode(false), impltf_mode(false), gates_mode(false), | ||||
| 			cname_mode(false), param_mode(false), attr_mode(false), blackbox_mode(false), noalias_mode(false) { } | ||||
| 			cname_mode(false), iname_mode(false), param_mode(false), attr_mode(false), iattr_mode(false), | ||||
| 			blackbox_mode(false), noalias_mode(false) { } | ||||
| }; | ||||
| 
 | ||||
| struct BlifDumper | ||||
|  | @ -240,118 +243,118 @@ struct BlifDumper | |||
| 			if (!config->icells_mode && cell->type == "$_NOT_") { | ||||
| 				f << stringf(".names %s %s\n0 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_AND_") { | ||||
| 				f << stringf(".names %s %s %s\n11 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_OR_") { | ||||
| 				f << stringf(".names %s %s %s\n1- 1\n-1 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_XOR_") { | ||||
| 				f << stringf(".names %s %s %s\n10 1\n01 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_NAND_") { | ||||
| 				f << stringf(".names %s %s %s\n0- 1\n-0 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_NOR_") { | ||||
| 				f << stringf(".names %s %s %s\n00 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_XNOR_") { | ||||
| 				f << stringf(".names %s %s %s\n11 1\n00 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_ANDNOT_") { | ||||
| 				f << stringf(".names %s %s %s\n10 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_ORNOT_") { | ||||
| 				f << stringf(".names %s %s %s\n1- 1\n-0 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_AOI3_") { | ||||
| 				f << stringf(".names %s %s %s %s\n-00 1\n0-0 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\C")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_OAI3_") { | ||||
| 				f << stringf(".names %s %s %s %s\n00- 1\n--0 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), cstr(cell->getPort("\\C")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_AOI4_") { | ||||
| 				f << stringf(".names %s %s %s %s %s\n-0-0 1\n-00- 1\n0--0 1\n0-0- 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), | ||||
| 						cstr(cell->getPort("\\C")), cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_OAI4_") { | ||||
| 				f << stringf(".names %s %s %s %s %s\n00-- 1\n--00 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), | ||||
| 						cstr(cell->getPort("\\C")), cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_MUX_") { | ||||
| 				f << stringf(".names %s %s %s %s\n1-0 1\n-11 1\n", | ||||
| 						cstr(cell->getPort("\\A")), cstr(cell->getPort("\\B")), | ||||
| 						cstr(cell->getPort("\\S")), cstr(cell->getPort("\\Y"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_FF_") { | ||||
| 				f << stringf(".latch %s %s%s\n", cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Q")), | ||||
| 						cstr_init(cell->getPort("\\Q"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_DFF_N_") { | ||||
| 				f << stringf(".latch %s %s fe %s%s\n", cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Q")), | ||||
| 						cstr(cell->getPort("\\C")), cstr_init(cell->getPort("\\Q"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_DFF_P_") { | ||||
| 				f << stringf(".latch %s %s re %s%s\n", cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Q")), | ||||
| 						cstr(cell->getPort("\\C")), cstr_init(cell->getPort("\\Q"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_DLATCH_N_") { | ||||
| 				f << stringf(".latch %s %s al %s%s\n", cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Q")), | ||||
| 						cstr(cell->getPort("\\E")), cstr_init(cell->getPort("\\Q"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$_DLATCH_P_") { | ||||
| 				f << stringf(".latch %s %s ah %s%s\n", cstr(cell->getPort("\\D")), cstr(cell->getPort("\\Q")), | ||||
| 						cstr(cell->getPort("\\E")), cstr_init(cell->getPort("\\Q"))); | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$lut") { | ||||
|  | @ -373,7 +376,7 @@ struct BlifDumper | |||
| 						} | ||||
| 						f << " 1\n"; | ||||
| 					} | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!config->icells_mode && cell->type == "$sop") { | ||||
|  | @ -401,7 +404,7 @@ struct BlifDumper | |||
| 					} | ||||
| 					f << " 1\n"; | ||||
| 				} | ||||
| 				continue; | ||||
| 				goto internal_cell; | ||||
| 			} | ||||
| 
 | ||||
| 			f << stringf(".%s %s", subckt_or_gate(cell->type.str()), cstr(cell->type)); | ||||
|  | @ -421,6 +424,14 @@ struct BlifDumper | |||
| 				dump_params(".attr", cell->attributes); | ||||
| 			if (config->param_mode) | ||||
| 				dump_params(".param", cell->parameters); | ||||
| 
 | ||||
| 			if (0) { | ||||
| 		internal_cell: | ||||
| 				if (config->iname_mode) | ||||
| 					f << stringf(".cname %s\n", cstr(cell->name)); | ||||
| 				if (config->iattr_mode) | ||||
| 					dump_params(".attr", cell->attributes); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		for (auto &conn : module->connections()) | ||||
|  | @ -511,6 +522,11 @@ struct BlifBackend : public Backend { | |||
| 		log("    -cname\n"); | ||||
| 		log("        use the non-standard .cname statement to write cell names\n"); | ||||
| 		log("\n"); | ||||
| 		log("    -iname, -iattr\n"); | ||||
| 		log("        enable -cname and -attr functionality for .names statements\n"); | ||||
| 		log("        (the .cname and .attr statements will be included in the BLIF\n"); | ||||
| 		log("        output after the truth table for the .names statement)\n"); | ||||
| 		log("\n"); | ||||
| 		log("    -blackbox\n"); | ||||
| 		log("        write blackbox cells with .blackbox statement.\n"); | ||||
| 		log("\n"); | ||||
|  | @ -587,6 +603,14 @@ struct BlifBackend : public Backend { | |||
| 				config.attr_mode = true; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-iname") { | ||||
| 				config.iname_mode = true; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-iattr") { | ||||
| 				config.iattr_mode = true; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-blackbox") { | ||||
| 				config.blackbox_mode = true; | ||||
| 				continue; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue