3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-23 14:23:41 +00:00

Remove abc option ambiguity

This commit is contained in:
Alain Dargelas 2024-11-27 21:31:14 -08:00
parent b421ffa3c4
commit e5e596149b

View file

@ -34,9 +34,9 @@ struct LongLoopSelect : public ScriptPass {
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n"); log("\n");
log(" longloop_select [-depth <for-loop threshold depth>] [-abc <ABC script>]\n"); log(" longloop_select [-depth <for-loop threshold depth>] [-abc_opt <ABC options>] [-abc_script <ABC script>]\n");
log(" If no ABC script is provided, this pass simply selects cells in for-loops\n"); log(" If no ABC script/option is provided, this pass simply selects cells in for-loops\n");
log(" If an ABC script is provided, this pass selects cells in a per for-loop basis and runs ABC with the given script\n"); log(" If an ABC script/option is provided, this pass selects cells in a per for-loop basis and runs ABC with the given script\n");
log("\n"); log("\n");
} }
void script() override {} void script() override {}
@ -99,15 +99,19 @@ struct LongLoopSelect : public ScriptPass {
bool debug = false; bool debug = false;
size_t argidx; size_t argidx;
std::string abc_script; std::string abc_script;
std::string abc_options;
for (argidx = 1; argidx < args.size(); argidx++) { for (argidx = 1; argidx < args.size(); argidx++) {
if (args[argidx] == "-depth") { if (args[argidx] == "-depth") {
argidx++; argidx++;
threshold_depth = std::stoul(args[argidx], nullptr, 10); threshold_depth = std::stoul(args[argidx], nullptr, 10);
} else if (args[argidx] == "-debug") { } else if (args[argidx] == "-debug") {
debug = true; debug = true;
} else if (args[argidx] == "-abc") { } else if (args[argidx] == "-abc_script") {
argidx++; argidx++;
abc_script = args[argidx]; abc_script = args[argidx];
} else if (args[argidx] == "-abc_opt") {
argidx++;
abc_options = args[argidx];
} else { } else {
break; break;
} }
@ -134,6 +138,7 @@ struct LongLoopSelect : public ScriptPass {
log(" Creating sorting datastructures\n"); log(" Creating sorting datastructures\n");
log_flush(); log_flush();
} }
for (auto cell : module->cells()) { for (auto cell : module->cells()) {
std::string loopIndex = cell->get_string_attribute("\\in_for_loop"); std::string loopIndex = cell->get_string_attribute("\\in_for_loop");
if (!loopIndex.empty()) { if (!loopIndex.empty()) {
@ -147,6 +152,7 @@ struct LongLoopSelect : public ScriptPass {
} }
} }
} }
if (!loopIndexCellMap.empty()) { if (!loopIndexCellMap.empty()) {
log(" Found %ld for-loop clusters in module %s\n", loopIndexCellMap.size(), module->name.c_str()); log(" Found %ld for-loop clusters in module %s\n", loopIndexCellMap.size(), module->name.c_str());
log_flush(); log_flush();
@ -199,18 +205,16 @@ struct LongLoopSelect : public ScriptPass {
} }
} }
if (!abc_script.empty()) { if (!abc_script.empty()) {
if (abc_script.find("map") == std::string::npos) { std::string command = "abc -map_src " + src_info + " -script " + abc_script;
abc_script.erase(std::remove(abc_script.begin(), abc_script.end(), '"'), abc_script.end()); log(" Executing: %s\n", command.c_str());
std::string command = "abc -map_src " + src_info + " " + abc_script; log_flush();
log(" Executing: %s\n", command.c_str()); Pass::call(design, command);
log_flush(); } else if (!abc_options.empty()) {
Pass::call(design, command); abc_options.erase(std::remove(abc_options.begin(), abc_options.end(), '"'), abc_options.end());
} else { std::string command = "abc -map_src " + src_info + " " + abc_options;
std::string command = "abc -map_src " + src_info + " -script " + abc_script; log(" Executing: %s\n", command.c_str());
log(" Executing: %s\n", command.c_str()); log_flush();
log_flush(); Pass::call(design, command);
Pass::call(design, command);
}
} }
} }
} }