mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-12 12:08:19 +00:00
WIP
This commit is contained in:
parent
0c689091e2
commit
1646bcd474
4
Makefile
4
Makefile
|
@ -631,7 +631,7 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
|
kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
|
||||||
kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"' -DYOSYS_PROGRAM_PREFIX='"$(PROGRAM_PREFIX)"'
|
kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"' -DYOSYS_LIBDIR='"$(LIBDIR)"' -DYOSYS_PROGRAM_PREFIX='"$(PROGRAM_PREFIX)"'
|
||||||
ifeq ($(ENABLE_ABC),1)
|
ifeq ($(ENABLE_ABC),1)
|
||||||
ifneq ($(ABCEXTERNAL),)
|
ifneq ($(ABCEXTERNAL),)
|
||||||
kernel/yosys.o: CXXFLAGS += -DABCEXTERNAL='"$(ABCEXTERNAL)"'
|
kernel/yosys.o: CXXFLAGS += -DABCEXTERNAL='"$(ABCEXTERNAL)"'
|
||||||
|
@ -771,7 +771,7 @@ endif
|
||||||
$(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in $(YOSYS_SRC)/Makefile
|
$(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in $(YOSYS_SRC)/Makefile
|
||||||
$(P) $(SED) -e 's#@CXXFLAGS@#$(subst -Ilibs/dlfcn-win32,,$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(strip $(CXXFLAGS_NOVERIFIC))))#;' \
|
$(P) $(SED) -e 's#@CXXFLAGS@#$(subst -Ilibs/dlfcn-win32,,$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(strip $(CXXFLAGS_NOVERIFIC))))#;' \
|
||||||
-e 's#@CXX@#$(strip $(CXX))#;' -e 's#@LINKFLAGS@#$(strip $(LINKFLAGS) $(PLUGIN_LINKFLAGS))#;' -e 's#@LIBS@#$(strip $(LIBS_NOVERIFIC) $(PLUGIN_LIBS))#;' \
|
-e 's#@CXX@#$(strip $(CXX))#;' -e 's#@LINKFLAGS@#$(strip $(LINKFLAGS) $(PLUGIN_LINKFLAGS))#;' -e 's#@LIBS@#$(strip $(LIBS_NOVERIFIC) $(PLUGIN_LIBS))#;' \
|
||||||
-e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config
|
-e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' -e 's#@LIBDIR@#$(strip $(LIBDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config
|
||||||
$(Q) chmod +x $(PROGRAM_PREFIX)yosys-config
|
$(Q) chmod +x $(PROGRAM_PREFIX)yosys-config
|
||||||
|
|
||||||
.PHONY: check-git-abc
|
.PHONY: check-git-abc
|
||||||
|
|
|
@ -96,9 +96,10 @@ std::vector<void*> memhasher_store;
|
||||||
uint32_t Hasher::fudge = 0;
|
uint32_t Hasher::fudge = 0;
|
||||||
|
|
||||||
std::string yosys_share_dirname;
|
std::string yosys_share_dirname;
|
||||||
|
std::string yosys_lib_dirname;
|
||||||
std::string yosys_abc_executable;
|
std::string yosys_abc_executable;
|
||||||
|
|
||||||
void init_share_dirname();
|
void init_dirnames();
|
||||||
void init_abc_executable_name();
|
void init_abc_executable_name();
|
||||||
|
|
||||||
void memhasher_on()
|
void memhasher_on()
|
||||||
|
@ -565,7 +566,7 @@ void yosys_setup()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_share_dirname();
|
init_dirnames();
|
||||||
init_abc_executable_name();
|
init_abc_executable_name();
|
||||||
|
|
||||||
#define X(_id) RTLIL::ID::_id = "\\" # _id;
|
#define X(_id) RTLIL::ID::_id = "\\" # _id;
|
||||||
|
@ -895,12 +896,13 @@ std::string proc_self_dirname(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EMSCRIPTEN) || defined(__wasm)
|
#if defined(EMSCRIPTEN) || defined(__wasm)
|
||||||
void init_share_dirname()
|
void init_dirnames()
|
||||||
{
|
{
|
||||||
yosys_share_dirname = "/share/";
|
yosys_share_dirname = "/share/";
|
||||||
|
yosys_lib_dirname = "/lib/";
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void init_share_dirname()
|
void init_dirname(const char* d) // TODO const char* d
|
||||||
{
|
{
|
||||||
# ifdef WITH_PYTHON
|
# ifdef WITH_PYTHON
|
||||||
PyObject *sys_obj = PyImport_ImportModule("sys");
|
PyObject *sys_obj = PyImport_ImportModule("sys");
|
||||||
|
@ -926,6 +928,7 @@ void init_share_dirname()
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
std::string proc_share_path = proc_self_path + "share/";
|
std::string proc_share_path = proc_self_path + "share/";
|
||||||
|
std::string proc_lib_path = proc_self_path + "lib/";
|
||||||
if (check_file_exists(proc_share_path, true)) {
|
if (check_file_exists(proc_share_path, true)) {
|
||||||
yosys_share_dirname = proc_share_path;
|
yosys_share_dirname = proc_share_path;
|
||||||
return;
|
return;
|
||||||
|
@ -944,6 +947,20 @@ void init_share_dirname()
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
void init_lib_dirname() {
|
||||||
|
# ifdef YOSYS_LIBDIR
|
||||||
|
proc_lib_path = YOSYS_LIBDIR "/";
|
||||||
|
log("proc_lib_path %s\n", proc_lib_path.c_str());
|
||||||
|
if (check_file_exists(proc_lib_path, true)) {
|
||||||
|
yosys_lib_dirname = proc_lib_path;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
void init_dirnames() {
|
||||||
|
init_share_dirname();
|
||||||
|
init_lib_dirname();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void init_abc_executable_name()
|
void init_abc_executable_name()
|
||||||
|
@ -977,10 +994,15 @@ void init_abc_executable_name()
|
||||||
std::string proc_share_dirname()
|
std::string proc_share_dirname()
|
||||||
{
|
{
|
||||||
if (yosys_share_dirname.empty())
|
if (yosys_share_dirname.empty())
|
||||||
log_error("init_share_dirname: unable to determine share/ directory!\n");
|
log_error("init_dirnames: unable to determine share/ directory!\n");
|
||||||
return yosys_share_dirname;
|
return yosys_share_dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string proc_lib_dirname()
|
||||||
|
{
|
||||||
|
return yosys_lib_dirname;
|
||||||
|
}
|
||||||
|
|
||||||
std::string proc_program_prefix()
|
std::string proc_program_prefix()
|
||||||
{
|
{
|
||||||
std::string program_prefix;
|
std::string program_prefix;
|
||||||
|
|
|
@ -66,6 +66,7 @@ extern RTLIL::Design *yosys_design;
|
||||||
RTLIL::Design *yosys_get_design();
|
RTLIL::Design *yosys_get_design();
|
||||||
std::string proc_self_dirname();
|
std::string proc_self_dirname();
|
||||||
std::string proc_share_dirname();
|
std::string proc_share_dirname();
|
||||||
|
std::string proc_lib_dirname();
|
||||||
std::string proc_program_prefix();
|
std::string proc_program_prefix();
|
||||||
const char *create_prompt(RTLIL::Design *design, int recursion_counter);
|
const char *create_prompt(RTLIL::Design *design, int recursion_counter);
|
||||||
std::vector<std::string> glob_filename(const std::string &filename_pattern);
|
std::vector<std::string> glob_filename(const std::string &filename_pattern);
|
||||||
|
@ -95,6 +96,7 @@ extern std::map<std::string, std::string> loaded_plugin_aliases;
|
||||||
void load_plugin(std::string filename, std::vector<std::string> aliases);
|
void load_plugin(std::string filename, std::vector<std::string> aliases);
|
||||||
|
|
||||||
extern std::string yosys_share_dirname;
|
extern std::string yosys_share_dirname;
|
||||||
|
extern std::string yosys_lib_dirname;
|
||||||
extern std::string yosys_abc_executable;
|
extern std::string yosys_abc_executable;
|
||||||
|
|
||||||
YOSYS_NAMESPACE_END
|
YOSYS_NAMESPACE_END
|
||||||
|
|
|
@ -15,6 +15,7 @@ help() {
|
||||||
echo " --ldlibs (alias of --libs)"
|
echo " --ldlibs (alias of --libs)"
|
||||||
echo " --bindir @BINDIR@"
|
echo " --bindir @BINDIR@"
|
||||||
echo " --datdir @DATDIR@"
|
echo " --datdir @DATDIR@"
|
||||||
|
echo " --libdir @LIBDIR@"
|
||||||
echo ""
|
echo ""
|
||||||
echo "All other args are passed through as they are."
|
echo "All other args are passed through as they are."
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -31,8 +32,8 @@ help() {
|
||||||
echo ""
|
echo ""
|
||||||
echo " $0 --prefix @ bindir: @bindir"
|
echo " $0 --prefix @ bindir: @bindir"
|
||||||
echo ""
|
echo ""
|
||||||
echo "The args --bindir and --datdir can be directly followed by a slash and"
|
echo "The args --bindir, --datdir and --libdir can be directly followed by a slash"
|
||||||
echo "additional text. Example:"
|
echo "and additional text. Example:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $0 --datdir/simlib.v"
|
echo " $0 --datdir/simlib.v"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -77,10 +78,14 @@ for opt; do
|
||||||
tokens=( "${tokens[@]}" '@BINDIR@' ) ;;
|
tokens=( "${tokens[@]}" '@BINDIR@' ) ;;
|
||||||
"$prefix"datdir)
|
"$prefix"datdir)
|
||||||
tokens=( "${tokens[@]}" '@DATDIR@' ) ;;
|
tokens=( "${tokens[@]}" '@DATDIR@' ) ;;
|
||||||
|
"$prefix"libdir)
|
||||||
|
tokens=( "${tokens[@]}" '@LIBDIR@' ) ;;
|
||||||
"$prefix"bindir/*)
|
"$prefix"bindir/*)
|
||||||
tokens=( "${tokens[@]}" '@BINDIR@'"${opt#${prefix}bindir}" ) ;;
|
tokens=( "${tokens[@]}" '@BINDIR@'"${opt#${prefix}bindir}" ) ;;
|
||||||
"$prefix"datdir/*)
|
"$prefix"datdir/*)
|
||||||
tokens=( "${tokens[@]}" '@DATDIR@'"${opt#${prefix}datdir}" ) ;;
|
tokens=( "${tokens[@]}" '@DATDIR@'"${opt#${prefix}datdir}" ) ;;
|
||||||
|
"$prefix"libdir/*)
|
||||||
|
tokens=( "${tokens[@]}" '@LIBDIR@'"${opt#${prefix}libdir}" ) ;;
|
||||||
--help|-\?|-h)
|
--help|-\?|-h)
|
||||||
if [ ${#tokens[@]} -eq 0 ]; then
|
if [ ${#tokens[@]} -eq 0 ]; then
|
||||||
help
|
help
|
||||||
|
|
|
@ -85,21 +85,27 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)
|
||||||
|
|
||||||
void *hdl = dlopen(filename.c_str(), RTLD_LAZY|RTLD_LOCAL);
|
void *hdl = dlopen(filename.c_str(), RTLD_LAZY|RTLD_LOCAL);
|
||||||
|
|
||||||
// We were unable to open the file, try to do so from the plugin directory
|
// We were unable to open the file, try to do so from the plugin directories
|
||||||
if (hdl == NULL && orig_filename.find('/') == std::string::npos) {
|
std::vector<std::string> errors;
|
||||||
hdl = dlopen([orig_filename]() {
|
log("orig_filename %s\n", orig_filename.c_str());
|
||||||
std::string new_path = proc_share_dirname() + "plugins/" + orig_filename;
|
for (auto dir : {proc_lib_dirname() + "plugins/", proc_share_dirname() + "plugins/"})
|
||||||
|
if (hdl == NULL && orig_filename.find('/') == std::string::npos) {
|
||||||
// Check if we need to append .so
|
hdl = dlopen([dir, orig_filename]() {
|
||||||
if (new_path.find(".so") == std::string::npos)
|
std::string new_path = dir + orig_filename;
|
||||||
|
|
||||||
|
// Check if we need to append .so
|
||||||
|
if (new_path.find(".so") == std::string::npos)
|
||||||
new_path.append(".so");
|
new_path.append(".so");
|
||||||
|
|
||||||
return new_path;
|
log("new_path %s\n", new_path.c_str());
|
||||||
}().c_str(), RTLD_LAZY|RTLD_LOCAL);
|
return new_path;
|
||||||
}
|
}().c_str(), RTLD_LAZY|RTLD_LOCAL);
|
||||||
|
errors.push_back(dlerror());
|
||||||
|
}
|
||||||
|
|
||||||
if (hdl == NULL)
|
if (hdl == NULL)
|
||||||
log_cmd_error("Can't load module `%s': %s\n", filename.c_str(), dlerror());
|
for (auto error : errors)
|
||||||
|
log_cmd_error("Can't load module `%s': %s\n", filename.c_str(), error.c_str());
|
||||||
|
|
||||||
loaded_plugins[orig_filename] = hdl;
|
loaded_plugins[orig_filename] = hdl;
|
||||||
Pass::init_register();
|
Pass::init_register();
|
||||||
|
|
Loading…
Reference in a new issue