mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	100%
This commit is contained in:
		
							parent
							
								
									eeb15ea2a2
								
							
						
					
					
						commit
						65d50db4ef
					
				
					 13 changed files with 74 additions and 67 deletions
				
			
		|  | @ -141,9 +141,10 @@ struct BlifDumper | |||
| 		return "subckt"; | ||||
| 	} | ||||
| 
 | ||||
| 	void dump_params(const char *command, dict<IdString, Const> ¶ms) | ||||
| 	template <typename SmellsLikeDict> | ||||
| 	void dump_params(const char *command, SmellsLikeDict ¶ms) | ||||
| 	{ | ||||
| 		for (auto ¶m : params) { | ||||
| 		for (auto param : params) { | ||||
| 			f << stringf("%s %s ", command, log_id(param.first)); | ||||
| 			if (param.second.flags & RTLIL::CONST_FLAG_STRING) { | ||||
| 				std::string str = param.second.decode_string(); | ||||
|  |  | |||
|  | @ -2326,7 +2326,8 @@ struct CxxrtlWorker { | |||
| 		f << escape_c_string(data); | ||||
| 	} | ||||
| 
 | ||||
| 	void dump_metadata_map(const dict<RTLIL::IdString, RTLIL::Const> &metadata_map) { | ||||
| 	template <typename SmellsLikeDict> | ||||
| 	void dump_metadata_map(const SmellsLikeDict &metadata_map) { | ||||
| 		if (metadata_map.empty()) { | ||||
| 			f << "metadata_map()"; | ||||
| 		} else { | ||||
|  |  | |||
|  | @ -480,17 +480,17 @@ struct FirrtlWorker | |||
| 		wire_exprs.push_back(stringf("%s" "inst %s%s of %s %s", indent.c_str(), cell_name.c_str(), cell_name_comment.c_str(), instanceName.c_str(), cellFileinfo.c_str())); | ||||
| 
 | ||||
| 		for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) { | ||||
| 			if (it->second.size() > 0) { | ||||
| 				const SigSpec &secondSig = it->second; | ||||
| 				const std::string firstName = cell_name + "." + make_id(it->first); | ||||
| 			if ((*it).second.size() > 0) { | ||||
| 				const SigSpec &secondSig = (*it).second; | ||||
| 				const std::string firstName = cell_name + "." + make_id((*it).first); | ||||
| 				const std::string secondExpr = make_expr(secondSig); | ||||
| 				// Find the direction for this port.
 | ||||
| 				FDirection dir = getPortFDirection(it->first, instModule); | ||||
| 				FDirection dir = getPortFDirection((*it).first, instModule); | ||||
| 				std::string sourceExpr, sinkExpr; | ||||
| 				const SigSpec *sinkSig = nullptr; | ||||
| 				switch (dir) { | ||||
| 					case FD_INOUT: | ||||
| 						log_warning("Instance port connection %s.%s is INOUT; treating as OUT\n", cell_type.c_str(), log_signal(it->second)); | ||||
| 						log_warning("Instance port connection %s.%s is INOUT; treating as OUT\n", cell_type.c_str(), log_signal((*it).second)); | ||||
| 						YS_FALLTHROUGH | ||||
| 					case FD_OUT: | ||||
| 						sourceExpr = firstName; | ||||
|  | @ -498,14 +498,14 @@ struct FirrtlWorker | |||
| 						sinkSig = &secondSig; | ||||
| 						break; | ||||
| 					case FD_NODIRECTION: | ||||
| 						log_warning("Instance port connection %s.%s is NODIRECTION; treating as IN\n", cell_type.c_str(), log_signal(it->second)); | ||||
| 						log_warning("Instance port connection %s.%s is NODIRECTION; treating as IN\n", cell_type.c_str(), log_signal((*it).second)); | ||||
| 						YS_FALLTHROUGH | ||||
| 					case FD_IN: | ||||
| 						sourceExpr = secondExpr; | ||||
| 						sinkExpr = firstName; | ||||
| 						break; | ||||
| 					default: | ||||
| 						log_error("Instance port %s.%s unrecognized connection direction 0x%x !\n", cell_type.c_str(), log_signal(it->second), dir); | ||||
| 						log_error("Instance port %s.%s unrecognized connection direction 0x%x !\n", cell_type.c_str(), log_signal((*it).second), dir); | ||||
| 						break; | ||||
| 				} | ||||
| 				// Check for subfield assignment.
 | ||||
|  | @ -849,7 +849,7 @@ struct FirrtlWorker | |||
| 				} | ||||
| 
 | ||||
| 				auto it = cell->parameters.find(ID::B_SIGNED); | ||||
| 				if (it == cell->parameters.end() || !it->second.as_bool()) { | ||||
| 				if (it == cell->parameters.end() || !(*it).second.as_bool()) { | ||||
| 					b_expr = "asUInt(" + b_expr + ")"; | ||||
| 				} | ||||
| 
 | ||||
|  | @ -881,7 +881,7 @@ struct FirrtlWorker | |||
| 			if (cell->type.in(ID($mux), ID($_MUX_))) | ||||
| 			{ | ||||
| 				auto it = cell->parameters.find(ID::WIDTH); | ||||
| 				int width = it == cell->parameters.end()? 1 : it->second.as_int(); | ||||
| 				int width = it == cell->parameters.end()? 1 : (*it).second.as_int(); | ||||
| 				string a_expr = make_expr(cell->getPort(ID::A)); | ||||
| 				string b_expr = make_expr(cell->getPort(ID::B)); | ||||
| 				string s_expr = make_expr(cell->getPort(ID::S)); | ||||
|  |  | |||
|  | @ -342,11 +342,12 @@ struct JnyWriter | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     void write_prams(dict<RTLIL::IdString, RTLIL::Const>& params, uint16_t indent_level = 0) { | ||||
|     template <typename SmellsLikeDict> | ||||
|     void write_prams(SmellsLikeDict& params, uint16_t indent_level = 0) { | ||||
|         const auto _indent = gen_indent(indent_level); | ||||
| 
 | ||||
|         bool first_param{true}; | ||||
|         for (auto& param : params) { | ||||
|         for (auto param : params) { | ||||
|             if (!first_param) | ||||
|                 f << stringf(",\n"); | ||||
|             const auto param_val = param.second; | ||||
|  |  | |||
|  | @ -128,11 +128,11 @@ struct JsonWriter | |||
| 			f << get_string(value.as_string()); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	void write_parameters(const dict<IdString, Const> ¶meters, bool for_module=false) | ||||
| 	template <typename SmellsLikeDict> | ||||
| 	void write_parameters(const SmellsLikeDict ¶meters, bool for_module=false) | ||||
| 	{ | ||||
| 		bool first = true; | ||||
| 		for (auto ¶m : parameters) { | ||||
| 		for (auto param : parameters) { | ||||
| 			f << stringf("%s\n", first ? "" : ","); | ||||
| 			f << stringf("        %s%s: ", for_module ? "" : "    ", get_name(param.first).c_str()); | ||||
| 			write_parameter_value(param.second); | ||||
|  |  | |||
|  | @ -1895,9 +1895,9 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell) | |||
| 		for (auto it = cell->parameters.begin(); it != cell->parameters.end(); ++it) { | ||||
| 			if (it != cell->parameters.begin()) | ||||
| 				f << stringf(","); | ||||
| 			f << stringf("\n%s  .%s(", indent.c_str(), id(it->first).c_str()); | ||||
| 			if (it->second.size() > 0) | ||||
| 				dump_const(f, it->second); | ||||
| 			f << stringf("\n%s  .%s(", indent.c_str(), id((*it).first).c_str()); | ||||
| 			if ((*it).second.size() > 0) | ||||
| 				dump_const(f, (*it).second); | ||||
| 			f << stringf(")"); | ||||
| 		} | ||||
| 		f << stringf("\n%s" ")", indent.c_str()); | ||||
|  | @ -1915,36 +1915,36 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell) | |||
| 		char str[16]; | ||||
| 		snprintf(str, 16, "$%d", i); | ||||
| 		for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) { | ||||
| 			if (it->first != str) | ||||
| 			if ((*it).first != str) | ||||
| 				continue; | ||||
| 			if (!first_arg) | ||||
| 				f << stringf(","); | ||||
| 			first_arg = false; | ||||
| 			f << stringf("\n%s  ", indent.c_str()); | ||||
| 			dump_sigspec(f, it->second); | ||||
| 			numbered_ports.insert(it->first); | ||||
| 			dump_sigspec(f, (*it).second); | ||||
| 			numbered_ports.insert((*it).first); | ||||
| 			goto found_numbered_port; | ||||
| 		} | ||||
| 		break; | ||||
| 	found_numbered_port:; | ||||
| 	} | ||||
| 	for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) { | ||||
| 		if (numbered_ports.count(it->first)) | ||||
| 		if (numbered_ports.count((*it).first)) | ||||
| 			continue; | ||||
| 		if (!first_arg) | ||||
| 			f << stringf(","); | ||||
| 		first_arg = false; | ||||
| 		f << stringf("\n%s  .%s(", indent.c_str(), id(it->first).c_str()); | ||||
| 		if (it->second.size() > 0) | ||||
| 			dump_sigspec(f, it->second); | ||||
| 		f << stringf("\n%s  .%s(", indent.c_str(), id((*it).first).c_str()); | ||||
| 		if ((*it).second.size() > 0) | ||||
| 			dump_sigspec(f, (*it).second); | ||||
| 		f << stringf(")"); | ||||
| 	} | ||||
| 	f << stringf("\n%s" ");\n", indent.c_str()); | ||||
| 
 | ||||
| 	if (defparam && cell->parameters.size() > 0) { | ||||
| 		for (auto it = cell->parameters.begin(); it != cell->parameters.end(); ++it) { | ||||
| 			f << stringf("%sdefparam %s.%s = ", indent.c_str(), cell_name.c_str(), id(it->first).c_str()); | ||||
| 			dump_const(f, it->second); | ||||
| 			f << stringf("%sdefparam %s.%s = ", indent.c_str(), cell_name.c_str(), id((*it).first).c_str()); | ||||
| 			dump_const(f, (*it).second); | ||||
| 			f << stringf(";\n"); | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue