mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-22 07:05:51 +00:00
Merge remote-tracking branch 'upstream/main' into silimate
This commit is contained in:
commit
e58125b605
834 changed files with 25281 additions and 8780 deletions
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "kernel/yosys.h"
|
||||
#include "kernel/celltypes.h"
|
||||
#include "kernel/log.h"
|
||||
#include "kernel/newcelltypes.h"
|
||||
|
||||
#include "libs/backward-cpp/backward.hpp"
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ namespace py = pybind11;
|
|||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# if !defined(YOSYS_DISABLE_SPAWN)
|
||||
# if defined(YOSYS_ENABLE_SPAWN)
|
||||
# include <sys/wait.h>
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -94,7 +94,7 @@ const char* yosys_maybe_version() {
|
|||
}
|
||||
|
||||
RTLIL::Design *yosys_design = NULL;
|
||||
CellTypes yosys_celltypes;
|
||||
NewCellTypes yosys_celltypes;
|
||||
|
||||
#ifdef YOSYS_ENABLE_TCL
|
||||
Tcl_Interp *yosys_tcl_interp = NULL;
|
||||
|
|
@ -181,7 +181,7 @@ void yosys_banner()
|
|||
log(" %s\n", yosys_maybe_version());
|
||||
}
|
||||
|
||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
||||
#if defined(YOSYS_ENABLE_SPAWN)
|
||||
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
||||
{
|
||||
if (!process_line)
|
||||
|
|
@ -230,6 +230,7 @@ PYBIND11_MODULE(pyosys, m) {
|
|||
// This should not affect using wheels as the dylib has to actually be called
|
||||
// libyosys_dummy.so for this function to be interacted with at all.
|
||||
PYBIND11_MODULE(libyosys_dummy, _) {
|
||||
(void)_;
|
||||
throw py::import_error("Change your import from 'import libyosys' to 'from pyosys import libyosys'.");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -265,7 +266,7 @@ void yosys_setup()
|
|||
|
||||
Pass::init_register();
|
||||
yosys_design = new RTLIL::Design;
|
||||
yosys_celltypes.setup();
|
||||
yosys_celltypes.static_cell_types = StaticCellTypes::categories.is_known;
|
||||
log_push();
|
||||
}
|
||||
|
||||
|
|
@ -294,8 +295,6 @@ void yosys_shutdown()
|
|||
log_errfile = NULL;
|
||||
log_files.clear();
|
||||
|
||||
yosys_celltypes.clear();
|
||||
|
||||
#ifdef YOSYS_ENABLE_TCL
|
||||
if (yosys_tcl_interp != NULL) {
|
||||
if (!Tcl_InterpDeleted(yosys_tcl_interp)) {
|
||||
|
|
@ -476,17 +475,30 @@ struct TclPass : public Pass {
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__CYGWIN__)
|
||||
#if defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
|
||||
std::string proc_self_dirname()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
ssize_t buflen = readlink("/proc/self/exe", path, sizeof(path));
|
||||
std::string path(4096, '\0');
|
||||
ssize_t buflen = -1;
|
||||
// Double until sucess, while avoiding endless loop. Give up
|
||||
// when symlink is longer than 4096*(2^30) = 4398046511104
|
||||
// bytes.
|
||||
for (int tries = 30; 0 < tries; tries--) {
|
||||
buflen = readlink("/proc/self/exe", path.data(), path.size());
|
||||
if (buflen < (ssize_t)path.size())
|
||||
break;
|
||||
else
|
||||
path.resize(path.size() * 2);
|
||||
}
|
||||
if (buflen < 0) {
|
||||
log_error("readlink(\"/proc/self/exe\") failed: %s\n", strerror(errno));
|
||||
path.resize(0);
|
||||
} else {
|
||||
while (buflen > 0 && path[buflen-1] != '/')
|
||||
buflen--;
|
||||
path.resize(buflen);
|
||||
}
|
||||
while (buflen > 0 && path[buflen-1] != '/')
|
||||
buflen--;
|
||||
return std::string(path, buflen);
|
||||
return path;
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
std::string proc_self_dirname()
|
||||
|
|
@ -529,25 +541,17 @@ std::string proc_self_dirname()
|
|||
std::string proc_self_dirname()
|
||||
{
|
||||
int i = 0;
|
||||
# ifdef __MINGW32__
|
||||
char longpath[MAX_PATH + 1];
|
||||
char shortpath[MAX_PATH + 1];
|
||||
# else
|
||||
WCHAR longpath[MAX_PATH + 1];
|
||||
TCHAR shortpath[MAX_PATH + 1];
|
||||
# endif
|
||||
if (!GetModuleFileName(0, longpath, MAX_PATH+1))
|
||||
if (!GetModuleFileNameA(0, longpath, MAX_PATH+1))
|
||||
log_error("GetModuleFileName() failed.\n");
|
||||
if (!GetShortPathName(longpath, shortpath, MAX_PATH+1))
|
||||
if (!GetShortPathNameA(longpath, shortpath, MAX_PATH+1))
|
||||
log_error("GetShortPathName() failed.\n");
|
||||
while (shortpath[i] != 0)
|
||||
i++;
|
||||
while (i > 0 && shortpath[i-1] != '/' && shortpath[i-1] != '\\')
|
||||
shortpath[--i] = 0;
|
||||
std::string path;
|
||||
for (i = 0; shortpath[i]; i++)
|
||||
path += char(shortpath[i]);
|
||||
return path;
|
||||
return shortpath;
|
||||
}
|
||||
#elif defined(EMSCRIPTEN) || defined(__wasm)
|
||||
std::string proc_self_dirname()
|
||||
|
|
@ -628,13 +632,11 @@ void init_share_dirname()
|
|||
yosys_share_dirname = proc_share_path;
|
||||
return;
|
||||
}
|
||||
# ifdef YOSYS_DATDIR
|
||||
proc_share_path = YOSYS_DATDIR "/";
|
||||
if (check_directory_exists(proc_share_path, true)) {
|
||||
yosys_share_dirname = proc_share_path;
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -676,11 +678,7 @@ std::string proc_share_dirname()
|
|||
|
||||
std::string proc_program_prefix()
|
||||
{
|
||||
std::string program_prefix;
|
||||
#ifdef YOSYS_PROGRAM_PREFIX
|
||||
program_prefix = YOSYS_PROGRAM_PREFIX;
|
||||
#endif
|
||||
return program_prefix;
|
||||
return YOSYS_PROGRAM_PREFIX;
|
||||
}
|
||||
|
||||
bool fgetline(FILE *f, std::string &buffer)
|
||||
|
|
@ -940,28 +938,28 @@ static char *readline_obj_generator(const char *text, int state)
|
|||
if (design->selected_active_module.empty())
|
||||
{
|
||||
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)));
|
||||
if (mod->name.unescape().compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(mod->name.unescape().c_str()));
|
||||
}
|
||||
else if (design->module(design->selected_active_module) != nullptr)
|
||||
{
|
||||
RTLIL::Module *module = design->module(design->selected_active_module);
|
||||
|
||||
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)));
|
||||
if (w->name.unescape().compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(w->name.unescape().c_str()));
|
||||
|
||||
for (auto &it : module->memories)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(log_id(it.first)));
|
||||
if (it.first.unescape().compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(it.first.unescape().c_str()));
|
||||
|
||||
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)));
|
||||
if (cell->name.unescape().compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(cell->name.unescape().c_str()));
|
||||
|
||||
for (auto &it : module->processes)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(log_id(it.first)));
|
||||
if (it.first.unescape().compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(it.first.unescape().c_str()));
|
||||
}
|
||||
|
||||
std::sort(obj_names.begin(), obj_names.end());
|
||||
|
|
@ -1166,7 +1164,7 @@ struct ScriptCmdPass : public Pass {
|
|||
if (!mod->selected(w))
|
||||
continue;
|
||||
if (!c.second.is_fully_const())
|
||||
log_error("RHS of selected wire %s.%s is not constant.\n", log_id(mod), log_id(w));
|
||||
log_error("RHS of selected wire %s.%s is not constant.\n", mod, w);
|
||||
auto v = c.second.as_const();
|
||||
Pass::call_on_module(design, mod, v.decode_string());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue