3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-18 13:15:46 +00:00

Update from upstream

This commit is contained in:
Akash Levy 2025-05-11 15:16:52 -07:00
commit aeed1ddb74
26 changed files with 78 additions and 52 deletions

View file

@ -252,6 +252,7 @@ int main(int argc, char **argv)
options.add_options("logging")
("Q", "suppress printing of banner (copyright, disclaimer, version)")
("T", "suppress printing of footer (log hash, version, timing statistics)")
("no-version", "suppress writing out Yosys version anywhere excluding -V, --version")
("q,quiet", "quiet operation. Only write warnings and error messages to console. " \
"Use this option twice to also quiet warning messages")
("v,verbose", "print log headers up to <level> to the console. " \
@ -318,6 +319,7 @@ int main(int argc, char **argv)
if (result.count("A")) call_abort = true;
if (result.count("Q")) print_banner = false;
if (result.count("T")) print_stats = false;
if (result.count("no-version")) yosys_write_versions = false;
if (result.count("V")) {
std::cout << yosys_version_str << std::endl;
exit(0);
@ -691,7 +693,7 @@ int main(int argc, char **argv)
stats_divider.c_str(), ru_buffer.ru_utime.tv_sec + 1e-6 * ru_buffer.ru_utime.tv_usec,
ru_buffer.ru_stime.tv_sec + 1e-6 * ru_buffer.ru_stime.tv_usec, meminfo.c_str());
#endif
log("%s\n", yosys_version_str);
log("%s\n", yosys_maybe_version());
int64_t total_ns = 0;
std::set<tuple<int64_t, int, std::string>> timedat;
@ -731,7 +733,7 @@ int main(int argc, char **argv)
log_error("Can't open performance log file for writing: %s\n", strerror(errno));
fprintf(f, "{\n");
fprintf(f, " \"generator\": \"%s\",\n", yosys_version_str);
fprintf(f, " \"generator\": \"%s\",\n", yosys_maybe_version());
fprintf(f, " \"total_ns\": %" PRIu64 ",\n", total_ns);
fprintf(f, " \"passes\": {");

View file

@ -102,6 +102,8 @@ gzip_istream::ibuf::~ibuf() {
// returns the original ifstream, rewound to the start.
// Never returns nullptr or failed state istream*
std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode) {
if (!check_file_exists(filename))
log_cmd_error("File `%s' not found or is a directory\n", filename.c_str());
std::ifstream* f = new std::ifstream();
f->open(filename, mode);
if (f->fail())

View file

@ -15,6 +15,7 @@
#include <stdexcept>
#include <algorithm>
#include <set>
#include <optional>
#include <string>
#include <variant>
#include <vector>

View file

@ -247,7 +247,7 @@ std::string make_temp_dir(std::string template_str)
#endif
}
bool check_directory_exists(const std::string& dirname)
bool check_is_directory(const std::string& dirname)
{
#if defined(_WIN32)
struct _stat info;
@ -267,17 +267,26 @@ bool check_directory_exists(const std::string& dirname)
}
#ifdef _WIN32
bool check_file_exists(std::string filename, bool)
bool check_accessible(const std::string& filename, bool)
{
return _access(filename.c_str(), 0) == 0;
}
#else
bool check_file_exists(std::string filename, bool is_exec)
bool check_accessible(const std::string& filename, bool is_exec)
{
return access(filename.c_str(), is_exec ? X_OK : F_OK) == 0;
}
#endif
bool check_file_exists(const std::string& filename, bool is_exec)
{
return check_accessible(filename, is_exec) && !check_is_directory(filename);
}
bool check_directory_exists(const std::string& filename, bool is_exec)
{
return check_accessible(filename, is_exec) && check_is_directory(filename);
}
bool is_absolute_path(std::string filename)
{
#ifdef _WIN32

View file

@ -64,6 +64,23 @@ inline std::string stringf(const char *fmt, ...)
return string;
}
int readsome(std::istream &f, char *s, int n);
std::string next_token(std::string &text, const char *sep = " \t\r\n", bool long_strings = false);
std::vector<std::string> split_tokens(const std::string &text, const char *sep = " \t\r\n");
bool patmatch(const char *pattern, const char *string);
#if !defined(YOSYS_DISABLE_SPAWN)
int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
#endif
std::string get_base_tmpdir();
std::string make_temp_file(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
std::string make_temp_dir(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
bool check_file_exists(const std::string& filename, bool is_exec = false);
bool check_directory_exists(const std::string& dirname, bool is_exec = false);
bool is_absolute_path(std::string filename);
void remove_directory(std::string dirname);
bool create_directory(const std::string& dirname);
std::string escape_filename_spaces(const std::string& filename);
YOSYS_NAMESPACE_END
#endif // YOSYS_IO_H

View file

@ -860,7 +860,7 @@ struct HelpPass : public Pass {
// init json
json.begin_object();
json.entry("version", "Yosys internal cells");
json.entry("generator", yosys_version_str);
json.entry("generator", yosys_maybe_version());
dict<string, vector<string>> groups;
dict<string, pair<SimHelper, CellType>> cells;

View file

@ -84,6 +84,14 @@ YOSYS_NAMESPACE_BEGIN
int autoidx = 1;
int yosys_xtrace = 0;
std::set<string> seen_ids;
bool yosys_write_versions = true;
const char* yosys_maybe_version() {
if (yosys_write_versions)
return yosys_version_str;
else
return "Yosys";
}
RTLIL::Design *yosys_design = NULL;
CellTypes yosys_celltypes;
@ -147,7 +155,7 @@ void yosys_banner()
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | Distributed under an ISC-like license, type \"license\" to see terms |\n");
log(" \\----------------------------------------------------------------------------/\n");
log(" %s\n", yosys_version_str);
log(" %s\n", yosys_maybe_version());
}
#if !defined(YOSYS_DISABLE_SPAWN)
@ -551,29 +559,29 @@ void init_share_dirname()
std::string proc_self_path = proc_self_dirname();
# if defined(_WIN32) && !defined(YOSYS_WIN32_UNIX_DIR)
std::string proc_share_path = proc_self_path + "share\\";
if (check_file_exists(proc_share_path, true)) {
if (check_directory_exists(proc_share_path, true)) {
yosys_share_dirname = proc_share_path;
return;
}
proc_share_path = proc_self_path + "..\\share\\";
if (check_file_exists(proc_share_path, true)) {
if (check_directory_exists(proc_share_path, true)) {
yosys_share_dirname = proc_share_path;
return;
}
# else
std::string proc_share_path = proc_self_path + "share/";
if (check_file_exists(proc_share_path, true)) {
if (check_directory_exists(proc_share_path, true)) {
yosys_share_dirname = proc_share_path;
return;
}
proc_share_path = proc_self_path + "../share/" + proc_program_prefix()+ "yosys/";
if (check_file_exists(proc_share_path, true)) {
if (check_directory_exists(proc_share_path, true)) {
yosys_share_dirname = proc_share_path;
return;
}
# ifdef YOSYS_DATDIR
proc_share_path = YOSYS_DATDIR "/";
if (check_file_exists(proc_share_path, true)) {
if (check_directory_exists(proc_share_path, true)) {
yosys_share_dirname = proc_share_path;
return;
}

View file

@ -81,6 +81,7 @@ extern std::set<std::string> yosys_input_files, yosys_output_files;
// from kernel/version_*.o (cc source generated from Makefile)
extern const char *yosys_version_str;
const char* yosys_maybe_version();
// from passes/cmds/design.cc
extern std::map<std::string, RTLIL::Design*> saved_designs;

View file

@ -252,29 +252,13 @@ inline void memhasher() { if (memhasher_active) memhasher_do(); }
void yosys_banner();
int ceil_log2(int x) YS_ATTRIBUTE(const);
int readsome(std::istream &f, char *s, int n);
std::string next_token(std::string &text, const char *sep = " \t\r\n", bool long_strings = false);
std::vector<std::string> split_tokens(const std::string &text, const char *sep = " \t\r\n");
bool patmatch(const char *pattern, const char *string);
#if !defined(YOSYS_DISABLE_SPAWN)
int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
#endif
std::string get_base_tmpdir();
std::string make_temp_file(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
std::string make_temp_dir(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
bool check_file_exists(std::string filename, bool is_exec = false);
bool check_directory_exists(const std::string& dirname);
bool is_absolute_path(std::string filename);
void remove_directory(std::string dirname);
bool create_directory(const std::string& dirname);
std::string escape_filename_spaces(const std::string& filename);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
inline int GetSize(RTLIL::Wire *wire);
extern int autoidx;
extern int yosys_xtrace;
extern std::set<string> seen_ids;
extern bool yosys_write_versions;
RTLIL::IdString new_id(std::string file, int line, std::string func);
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix);