aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/yosys.cc
diff options
context:
space:
mode:
authorClaire Xen <claire@clairexen.net>2021-12-10 11:23:53 +0100
committerGitHub <noreply@github.com>2021-12-10 11:23:53 +0100
commitce82afe44f4c396c253a293a5f0d56212fe27010 (patch)
treece3d60c7aa65c8f67a583f1d8da1913ade20fd9e /kernel/yosys.cc
parentcdb57118758f855518ad416d12728d72bff58c10 (diff)
parentd6e4d3f1ba9191f0f3bbed2d47a9ef80b8614e77 (diff)
downloadyosys-ce82afe44f4c396c253a293a5f0d56212fe27010.tar.gz
yosys-ce82afe44f4c396c253a293a5f0d56212fe27010.tar.bz2
yosys-ce82afe44f4c396c253a293a5f0d56212fe27010.zip
Merge pull request #3099 from YosysHQ/claire/readargs
Use "read" command to parse HDL files from Yosys command-line
Diffstat (limited to 'kernel/yosys.cc')
-rw-r--r--kernel/yosys.cc33
1 files changed, 17 insertions, 16 deletions
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 39d6a1ec1..102f9e737 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -956,7 +956,7 @@ static void handle_label(std::string &command, bool &from_to_active, const std::
}
}
-void run_frontend(std::string filename, std::string command, std::string *backend_command, std::string *from_to_label, RTLIL::Design *design)
+bool run_frontend(std::string filename, std::string command, RTLIL::Design *design, std::string *from_to_label)
{
if (design == nullptr)
design = yosys_design;
@@ -966,11 +966,11 @@ void run_frontend(std::string filename, std::string command, std::string *backen
if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".gz") == 0)
filename_trim.erase(filename_trim.size()-3);
if (filename_trim.size() > 2 && filename_trim.compare(filename_trim.size()-2, std::string::npos, ".v") == 0)
- command = "verilog";
+ command = " -vlog2k";
else if (filename_trim.size() > 2 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".sv") == 0)
- command = "verilog -sv";
+ command = " -sv";
else if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vhd") == 0)
- command = "vhdl";
+ command = " -vhdl";
else if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-5, std::string::npos, ".blif") == 0)
command = "blif";
else if (filename_trim.size() > 5 && filename_trim.compare(filename_trim.size()-6, std::string::npos, ".eblif") == 0)
@@ -1056,10 +1056,12 @@ void run_frontend(std::string filename, std::string command, std::string *backen
if (filename != "-")
fclose(f);
- if (backend_command != NULL && *backend_command == "auto")
- *backend_command = "";
+ return true;
+ }
- return;
+ if (command == "tcl") {
+ Pass::call(design, vector<string>({command, filename}));
+ return true;
}
if (filename == "-") {
@@ -1068,16 +1070,15 @@ void run_frontend(std::string filename, std::string command, std::string *backen
log("\n-- Parsing `%s' using frontend `%s' --\n", filename.c_str(), command.c_str());
}
- if (command == "tcl")
- Pass::call(design, vector<string>({command, filename}));
- else
+ if (command[0] == ' ') {
+ auto argv = split_tokens("read" + command);
+ argv.push_back(filename);
+ Pass::call(design, argv);
+ } else
Frontend::frontend_call(design, NULL, filename, command);
- design->check();
-}
-void run_frontend(std::string filename, std::string command, RTLIL::Design *design)
-{
- run_frontend(filename, command, nullptr, nullptr, design);
+ design->check();
+ return false;
}
void run_pass(std::string command, RTLIL::Design *design)
@@ -1391,7 +1392,7 @@ struct ScriptCmdPass : public Pass {
else if (args.size() == 2)
run_frontend(args[1], "script", design);
else if (args.size() == 3)
- run_frontend(args[1], "script", NULL, &args[2], design);
+ run_frontend(args[1], "script", design, &args[2]);
else
extra_args(args, 2, design, false);
}