605 if (command ==
"auto") {
606 if (filename.size() > 2 && filename.substr(filename.size()-2) ==
".v")
608 else if (filename.size() > 2 && filename.substr(filename.size()-3) ==
".sv")
609 command =
"verilog -sv";
610 else if (filename.size() > 3 && filename.substr(filename.size()-3) ==
".il")
612 else if (filename.size() > 3 && filename.substr(filename.size()-3) ==
".ys")
614 else if (filename ==
"-")
617 log_error(
"Can't guess frontend for input file `%s' (missing -f option)!\n", filename.c_str());
620 if (command ==
"script")
622 std::string run_from, run_to;
623 bool from_to_active =
true;
625 if (from_to_label !=
NULL) {
626 size_t pos = from_to_label->find(
':');
627 if (pos == std::string::npos) {
628 run_from = *from_to_label;
629 run_to = *from_to_label;
631 run_from = from_to_label->substr(0, pos);
632 run_to = from_to_label->substr(pos+1);
634 from_to_active = run_from.empty();
637 log(
"\n-- Executing script file `%s' --\n", filename.c_str());
642 f = fopen(filename.c_str(),
"r");
645 log_error(
"Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
653 while (!command.empty() && command[command.size()-1] ==
'\\') {
654 std::string next_line;
657 command.resize(command.size()-1);
658 command += next_line;
660 handle_label(command, from_to_active, run_from, run_to);
665 if (!command.empty()) {
666 handle_label(command, from_to_active, run_from, run_to);
681 if (backend_command !=
NULL && *backend_command ==
"auto")
682 *backend_command =
"";
687 if (filename ==
"-") {
688 log(
"\n-- Parsing stdin using frontend `%s' --\n", command.c_str());
690 log(
"\n-- Parsing `%s' using frontend `%s' --\n", filename.c_str(), command.c_str());
static void handle_label(std::string &command, bool &from_to_active, const std::string &run_from, const std::string &run_to)
static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::string command)
void log_error(const char *format,...)
static FILE * current_script_file
void log(const char *format,...)
static void call(RTLIL::Design *design, std::string command)
bool fgetline(FILE *f, std::string &buffer)