From: Clifford Wolf Date: Mon, 2 Mar 2015 22:47:45 +0000 (+0100) Subject: Added write_blif -attr X-Git-Tag: yosys-0.6~382 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=795a6e1d04c666dbdef9a91ea55595fb168087d6;p=yosys.git Added write_blif -attr --- diff --git a/backends/blif/blif.cc b/backends/blif/blif.cc index 6422d9f01..f6aac0b41 100644 --- a/backends/blif/blif.cc +++ b/backends/blif/blif.cc @@ -38,13 +38,14 @@ struct BlifDumperConfig bool impltf_mode; bool gates_mode; bool param_mode; + bool attr_mode; bool blackbox_mode; std::string buf_type, buf_in, buf_out; std::map> unbuf_types; 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), param_mode(false), blackbox_mode(false) { } + BlifDumperConfig() : icells_mode(false), conn_mode(false), impltf_mode(false), gates_mode(false), param_mode(false), attr_mode(false), blackbox_mode(false) { } }; struct BlifDumper @@ -103,6 +104,26 @@ struct BlifDumper return "subckt"; } + void dump_params(const char *command, dict ¶ms) + { + for (auto ¶m : params) { + f << stringf("%s %s ", command, RTLIL::id2cstr(param.first)); + if (param.second.flags & RTLIL::CONST_FLAG_STRING) { + std::string str = param.second.decode_string(); + f << stringf("\""); + for (char ch : str) + if (ch == '"' || ch == '\\') + f << stringf("\\%c", ch); + else if (ch < 32 || ch >= 127) + f << stringf("\\%03o", ch); + else + f << stringf("%c", ch); + f << stringf("\"\n"); + } else + f << stringf("%s\n", param.second.as_string().c_str()); + } + } + void dump() { f << stringf("\n"); @@ -249,23 +270,10 @@ struct BlifDumper } f << stringf("\n"); + if (config->attr_mode) + dump_params(".attr", cell->attributes); if (config->param_mode) - for (auto ¶m : cell->parameters) { - f << stringf(".param %s ", RTLIL::id2cstr(param.first)); - if (param.second.flags & RTLIL::CONST_FLAG_STRING) { - std::string str = param.second.decode_string(); - f << stringf("\""); - for (char ch : str) - if (ch == '"' || ch == '\\') - f << stringf("\\%c", ch); - else if (ch < 32 || ch >= 127) - f << stringf("\\%03o", ch); - else - f << stringf("%c", ch); - f << stringf("\"\n"); - } else - f << stringf("%s\n", param.second.as_string().c_str()); - } + dump_params(".param", cell->parameters); } for (auto &conn : module->connections()) @@ -333,8 +341,11 @@ struct BlifBackend : public Backend { log(" do not generate buffers for connected wires. instead use the\n"); log(" non-standard .conn statement.\n"); log("\n"); + log(" -attr\n"); + log(" use the non-standard .attr statement to write cell attributes\n"); + log("\n"); log(" -param\n"); - log(" use the non-standard .param statement to write module parameters\n"); + log(" use the non-standard .param statement to write cell parameters\n"); log("\n"); log(" -blackbox\n"); log(" write blackbox cells with .blackbox statement.\n"); @@ -404,6 +415,10 @@ struct BlifBackend : public Backend { config.param_mode = true; continue; } + if (args[argidx] == "-attr") { + config.attr_mode = true; + continue; + } if (args[argidx] == "-blackbox") { config.blackbox_mode = true; continue;