From 453a29c9f6704e49297f507d98bcccafe6f2fa59 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 26 Apr 2013 13:13:58 +0200 Subject: Only use sha1 checksums for names of parametric modules when the verbose form is to long --- frontends/ast/ast.cc | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'frontends') diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index cb0311b6..0bd1ba2e 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -787,6 +787,7 @@ RTLIL::IdString AstModule::derive(RTLIL::Design *design, std::map hash_data; hash_data.insert(hash_data.end(), name.begin(), name.end()); hash_data.push_back(0); @@ -803,6 +804,7 @@ RTLIL::IdString AstModule::derive(RTLIL::Design *design, std::mapstr) > 0) { log("Parameter %s = %s\n", child->str.c_str(), log_signal(RTLIL::SigSpec(parameters[child->str]))); rewrite_parameter: + para_info += stringf("%s=%s", child->str.c_str(), log_signal(RTLIL::SigSpec(parameters[child->str]))); child->delete_children(); child->children.push_back(AstNode::mkconst_bits(parameters[para_id].bits, false)); hash_data.insert(hash_data.end(), child->str.begin(), child->str.end()); @@ -823,17 +825,26 @@ RTLIL::IdString AstModule::derive(RTLIL::Design *design, std::map 0) log_error("Requested parameter `%s' does not exist in module `%s'!\n", parameters.begin()->first.c_str(), name.c_str()); - unsigned char hash[20]; - unsigned char *hash_data2 = new unsigned char[hash_data.size()]; - for (size_t i = 0; i < hash_data.size(); i++) - hash_data2[i] = hash_data[i]; - sha1::calc(hash_data2, hash_data.size(), hash); - delete[] hash_data2; + std::string modname; - char hexstring[41]; - sha1::toHexString(hash, hexstring); + if (para_info.size() > 60) + { + unsigned char hash[20]; + unsigned char *hash_data2 = new unsigned char[hash_data.size()]; + for (size_t i = 0; i < hash_data.size(); i++) + hash_data2[i] = hash_data[i]; + sha1::calc(hash_data2, hash_data.size(), hash); + delete[] hash_data2; + + char hexstring[41]; + sha1::toHexString(hash, hexstring); - std::string modname = "$paramod$" + std::string(hexstring) + "$" + name; + modname = "$paramod$" + std::string(hexstring) + name; + } + else + { + modname = "$paramod" + name + para_info; + } if (design->modules.count(modname) == 0) { new_ast->str = modname; -- cgit v1.2.3