projects
/
yosys.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
xaiger: update help text
[yosys.git]
/
kernel
/
yosys.cc
diff --git
a/kernel/yosys.cc
b/kernel/yosys.cc
index 7694fc9b62eeadf34a5e7ffbb817e19ffc68c293..2ec3dca0cffeda704d13141a25c81250b0b07e94 100644
(file)
--- a/
kernel/yosys.cc
+++ b/
kernel/yosys.cc
@@
-45,8
+45,10
@@
# include <unistd.h>
# include <dirent.h>
# include <sys/types.h>
# include <unistd.h>
# include <dirent.h>
# include <sys/types.h>
-# include <sys/wait.h>
# include <sys/stat.h>
# include <sys/stat.h>
+# if !defined(YOSYS_DISABLE_SPAWN)
+# include <sys/wait.h>
+# endif
#endif
#if !defined(_WIN32) && defined(YOSYS_ENABLE_GLOB)
#endif
#if !defined(_WIN32) && defined(YOSYS_ENABLE_GLOB)
@@
-129,7
+131,7
@@
void yosys_banner()
log(" | |\n");
log(" | yosys -- Yosys Open SYnthesis Suite |\n");
log(" | |\n");
log(" | |\n");
log(" | yosys -- Yosys Open SYnthesis Suite |\n");
log(" | |\n");
- log(" | Copyright (C) 2012 - 20
19 Clifford Wolf <clifford@clifford.at>
|\n");
+ log(" | Copyright (C) 2012 - 20
20 Claire Wolf <claire@symbioticeda.com>
|\n");
log(" | |\n");
log(" | Permission to use, copy, modify, and/or distribute this software for any |\n");
log(" | purpose with or without fee is hereby granted, provided that the above |\n");
log(" | |\n");
log(" | Permission to use, copy, modify, and/or distribute this software for any |\n");
log(" | purpose with or without fee is hereby granted, provided that the above |\n");
@@
-336,16
+338,13
@@
bool patmatch(const char *pattern, const char *string)
return false;
}
return false;
}
+#if !defined(YOSYS_DISABLE_SPAWN)
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
{
if (!process_line)
return system(command.c_str());
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
{
if (!process_line)
return system(command.c_str());
-#ifdef EMSCRIPTEN
- FILE *f = nullptr;
-#else
FILE *f = popen(command.c_str(), "r");
FILE *f = popen(command.c_str(), "r");
-#endif
if (f == nullptr)
return -1;
if (f == nullptr)
return -1;
@@
-368,10
+367,16
@@
int run_command(const std::string &command, std::function<void(const std::string
return WEXITSTATUS(ret);
#endif
}
return WEXITSTATUS(ret);
#endif
}
+#endif
std::string make_temp_file(std::string template_str)
{
std::string make_temp_file(std::string template_str)
{
-#ifdef _WIN32
+#if defined(__wasm)
+ size_t pos = template_str.rfind("XXXXXX");
+ log_assert(pos != std::string::npos);
+ static size_t index = 0;
+ template_str.replace(pos, 6, stringf("%06zu", index++));
+#elif defined(_WIN32)
if (template_str.rfind("/tmp/", 0) == 0) {
# ifdef __MINGW32__
char longpath[MAX_PATH + 1];
if (template_str.rfind("/tmp/", 0) == 0) {
# ifdef __MINGW32__
char longpath[MAX_PATH + 1];
@@
-420,10
+425,14
@@
std::string make_temp_file(std::string template_str)
std::string make_temp_dir(std::string template_str)
{
std::string make_temp_dir(std::string template_str)
{
-#if
def _WIN32
+#if
defined(_WIN32)
template_str = make_temp_file(template_str);
mkdir(template_str.c_str());
return template_str;
template_str = make_temp_file(template_str);
mkdir(template_str.c_str());
return template_str;
+#elif defined(__wasm)
+ template_str = make_temp_file(template_str);
+ mkdir(template_str.c_str(), 0777);
+ return template_str;
#else
# ifndef NDEBUG
size_t pos = template_str.rfind("XXXXXX");
#else
# ifndef NDEBUG
size_t pos = template_str.rfind("XXXXXX");
@@
-515,12
+524,9
@@
void yosys_setup()
return;
already_setup = true;
return;
already_setup = true;
- RTLIL::ID::A = "\\A";
- RTLIL::ID::B = "\\B";
- RTLIL::ID::Y = "\\Y";
- RTLIL::ID::keep = "\\keep";
- RTLIL::ID::whitebox = "\\whitebox";
- RTLIL::ID::blackbox = "\\blackbox";
+#define X(_id) RTLIL::ID::_id = "\\" # _id;
+#include "kernel/constids.inc"
+#undef X
#ifdef WITH_PYTHON
PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
#ifdef WITH_PYTHON
PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
@@
-809,7
+815,7
@@
std::string proc_self_dirname()
path += char(shortpath[i]);
return path;
}
path += char(shortpath[i]);
return path;
}
-#elif defined(EMSCRIPTEN)
+#elif defined(EMSCRIPTEN)
|| defined(__wasm)
std::string proc_self_dirname()
{
return "/";
std::string proc_self_dirname()
{
return "/";
@@
-818,7
+824,7
@@
std::string proc_self_dirname()
#error "Don't know how to determine process executable base path!"
#endif
#error "Don't know how to determine process executable base path!"
#endif
-#if
def EMSCRIPTEN
+#if
defined(EMSCRIPTEN) || defined(__wasm)
std::string proc_share_dirname()
{
return "/share/";
std::string proc_share_dirname()
{
return "/share/";
@@
-838,7
+844,7
@@
std::string proc_share_dirname()
std::string proc_share_path = proc_self_path + "share/";
if (check_file_exists(proc_share_path, true))
return proc_share_path;
std::string proc_share_path = proc_self_path + "share/";
if (check_file_exists(proc_share_path, true))
return proc_share_path;
- proc_share_path = proc_self_path + "../share/yosys/";
+ proc_share_path = proc_self_path + "../share/
" + proc_program_prefix()+ "
yosys/";
if (check_file_exists(proc_share_path, true))
return proc_share_path;
# ifdef YOSYS_DATDIR
if (check_file_exists(proc_share_path, true))
return proc_share_path;
# ifdef YOSYS_DATDIR
@@
-851,6
+857,15
@@
std::string proc_share_dirname()
}
#endif
}
#endif
+std::string proc_program_prefix()
+{
+ std::string program_prefix;
+#ifdef YOSYS_PROGRAM_PREFIX
+ program_prefix = YOSYS_PROGRAM_PREFIX;
+#endif
+ return program_prefix;
+}
+
bool fgetline(FILE *f, std::string &buffer)
{
buffer = "";
bool fgetline(FILE *f, std::string &buffer)
{
buffer = "";
@@
-1037,6
+1052,8
@@
void run_backend(std::string filename, std::string command, RTLIL::Design *desig
command = "verilog";
else if (filename.size() > 3 && filename.compare(filename.size()-3, std::string::npos, ".il") == 0)
command = "ilang";
command = "verilog";
else if (filename.size() > 3 && filename.compare(filename.size()-3, std::string::npos, ".il") == 0)
command = "ilang";
+ else if (filename.size() > 3 && filename.compare(filename.size()-3, std::string::npos, ".cc") == 0)
+ command = "cxxrtl";
else if (filename.size() > 4 && filename.compare(filename.size()-4, std::string::npos, ".aig") == 0)
command = "aiger";
else if (filename.size() > 5 && filename.compare(filename.size()-5, std::string::npos, ".blif") == 0)
else if (filename.size() > 4 && filename.compare(filename.size()-4, std::string::npos, ".aig") == 0)
command = "aiger";
else if (filename.size() > 5 && filename.compare(filename.size()-5, std::string::npos, ".blif") == 0)
@@
-1098,30
+1115,29
@@
static char *readline_obj_generator(const char *text, int state)
if (design->selected_active_module.empty())
{
if (design->selected_active_module.empty())
{
- for (auto
&it : design->modules_
)
- if (RTLIL::unescape_id(
it.first
).compare(0, len, text) == 0)
- obj_names.push_back(strdup(
RTLIL::id2cstr(it.first
)));
+ for (auto
mod : design->modules()
)
+ if (RTLIL::unescape_id(
mod->name
).compare(0, len, text) == 0)
+ obj_names.push_back(strdup(
log_id(mod->name
)));
}
}
- else
- if (design->modules_.count(design->selected_active_module) > 0)
+ else if (design->module(design->selected_active_module) != nullptr)
{
{
- RTLIL::Module *module = design->module
s_.at
(design->selected_active_module);
+ RTLIL::Module *module = design->module(design->selected_active_module);
- for (auto
&it : module->wires_
)
- if (RTLIL::unescape_id(
it.first
).compare(0, len, text) == 0)
- obj_names.push_back(strdup(
RTLIL::id2cstr(it.first
)));
+ for (auto
w : module->wires()
)
+ if (RTLIL::unescape_id(
w->name
).compare(0, len, text) == 0)
+ obj_names.push_back(strdup(
log_id(w->name
)));
for (auto &it : module->memories)
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
for (auto &it : module->memories)
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
- obj_names.push_back(strdup(
RTLIL::id2cstr
(it.first)));
+ obj_names.push_back(strdup(
log_id
(it.first)));
- for (auto
&it : module->cells_
)
- if (RTLIL::unescape_id(
it.first
).compare(0, len, text) == 0)
- obj_names.push_back(strdup(
RTLIL::id2cstr(it.first
)));
+ for (auto
cell : module->cells()
)
+ if (RTLIL::unescape_id(
cell->name
).compare(0, len, text) == 0)
+ obj_names.push_back(strdup(
log_id(cell->name
)));
for (auto &it : module->processes)
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
for (auto &it : module->processes)
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
- obj_names.push_back(strdup(
RTLIL::id2cstr
(it.first)));
+ obj_names.push_back(strdup(
log_id
(it.first)));
}
std::sort(obj_names.begin(), obj_names.end());
}
std::sort(obj_names.begin(), obj_names.end());