log("design as an XAIGER file with write_xaiger and then load that into ABC externally\n");
log("if you want to use ABC to convert your design into another format.\n");
log("\n");
- // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
- log("Delay targets can also be specified on a per clock basis by attaching a\n");
- log("'(* abc9_period = <int> *)' attribute onto clock wires (specifically, onto wires\n");
- log("that appear inside any special '$abc9_clock' wires inserted by abc9_map.v). This\n");
- log("can be achieved by modifying the source directly, or through a `setattr`\n");
- log("invocation. Since such attributes cannot yet be propagated through a\n");
- log("hierarchical design (whether or not it has been uniquified) it is recommended\n");
- log("that the design be flattened when using this feature.\n");
- log("\n");
log("[1] http://www.eecs.berkeley.edu/~alanmi/abc/\n");
log("\n");
+ help_script();
+ log("\n");
}
- void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
- {
- log_header(design, "Executing ABC9 pass (technology mapping using ABC9).\n");
- log_push();
-#ifdef ABCEXTERNAL
- std::string exe_file = ABCEXTERNAL;
-#else
- std::string exe_file = proc_self_dirname() + "yosys-abc";
-#endif
- std::string script_file, clk_str, box_file, lut_file;
- std::string delay_target, lutin_shared = "-S 1", wire_delay;
- bool fast_mode = false, cleanup = true;
- bool show_tempdir = false;
- bool nomfs = false;
- vector<int> lut_costs;
- markgroups = false;
+ std::stringstream map_cmd;
+ bool cleanup;
-#if 0
- cleanup = false;
- show_tempdir = true;
-#endif
+ void clear_flags() YS_OVERRIDE
+ {
+ map_cmd.str("");
+ map_cmd << "abc9_map";
+ cleanup = true;
+ }
-#ifdef _WIN32
-#ifndef ABCEXTERNAL
- if (!check_file_exists(exe_file + ".exe") && check_file_exists(proc_self_dirname() + "..\\yosys-abc.exe"))
- exe_file = proc_self_dirname() + "..\\yosys-abc";
-#endif
-#endif
+ void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
+ {
+ std::string run_from, run_to;
+ clear_flags();
size_t argidx;
- char pwd [PATH_MAX];
- if (!getcwd(pwd, sizeof(pwd))) {
- log_cmd_error("getcwd failed: %s\n", strerror(errno));
- log_abort();
- }
for (argidx = 1; argidx < args.size(); argidx++) {
std::string arg = args[argidx];
- if (arg == "-exe" && argidx+1 < args.size()) {
- exe_file = args[++argidx];
- continue;
- }
- if (arg == "-script" && argidx+1 < args.size()) {
- script_file = args[++argidx];
- rewrite_filename(script_file);
- if (!script_file.empty() && !is_absolute_path(script_file) && script_file[0] != '+')
- script_file = std::string(pwd) + "/" + script_file;
+ if ((arg == "-exe" || arg == "-script" || arg == "-D" ||
+ /* arg == "-S" || */ arg == "-lut" || arg == "-luts" ||
+ arg == "-clk" || arg == "-box" || arg == "-W") &&
+ argidx+1 < args.size()) {
+ map_cmd << " " << arg << " " << args[++argidx];
continue;
}
- if (arg == "-D" && argidx+1 < args.size()) {
- delay_target = "-D " + args[++argidx];
- continue;
- }
- //if (arg == "-S" && argidx+1 < args.size()) {
- // lutin_shared = "-S " + args[++argidx];
- // continue;
- //}
- if (arg == "-lut" && argidx+1 < args.size()) {
- string arg = args[++argidx];
- if (arg.find_first_not_of("0123456789:") == std::string::npos) {
- size_t pos = arg.find_first_of(':');
- int lut_mode = 0, lut_mode2 = 0;
- if (pos != string::npos) {
- lut_mode = atoi(arg.substr(0, pos).c_str());
- lut_mode2 = atoi(arg.substr(pos+1).c_str());
- } else {
- lut_mode = atoi(arg.c_str());
- lut_mode2 = lut_mode;
- }
- lut_costs.clear();
- for (int i = 0; i < lut_mode; i++)
- lut_costs.push_back(1);
- for (int i = lut_mode; i < lut_mode2; i++)
- lut_costs.push_back(2 << (i - lut_mode));
- }
- else {
- lut_file = arg;
- rewrite_filename(lut_file);
- if (!lut_file.empty() && !is_absolute_path(lut_file) && lut_file[0] != '+')
- lut_file = std::string(pwd) + "/" + lut_file;
- }
- continue;
- }
- if (arg == "-luts" && argidx+1 < args.size()) {
- lut_costs.clear();
- for (auto &tok : split_tokens(args[++argidx], ",")) {
- auto parts = split_tokens(tok, ":");
- if (GetSize(parts) == 0 && !lut_costs.empty())
- lut_costs.push_back(lut_costs.back());
- else if (GetSize(parts) == 1)
- lut_costs.push_back(atoi(parts.at(0).c_str()));
- else if (GetSize(parts) == 2)
- while (GetSize(lut_costs) < atoi(parts.at(0).c_str()))
- lut_costs.push_back(atoi(parts.at(1).c_str()));
- else
- log_cmd_error("Invalid -luts syntax.\n");
- }
- continue;
- }
- if (arg == "-fast") {
- fast_mode = true;
+ if (arg == "-fast"
+ /*|| arg == "-nocleanup"*/ || arg == "-showtmp" || arg == "-markgroups"
+ || arg == "-nomfs") {
+ map_cmd << " " << arg;
continue;
}
if (arg == "-nocleanup") {