mirror of https://github.com/YosysHQ/yosys.git
Update from upstream
This commit is contained in:
commit
aeed1ddb74
2
Makefile
2
Makefile
|
|
@ -176,7 +176,7 @@ ifeq ($(OS), Haiku)
|
|||
CXXFLAGS += -D_DEFAULT_SOURCE
|
||||
endif
|
||||
|
||||
YOSYS_VER := 0.53+3
|
||||
YOSYS_VER := 0.53+15
|
||||
YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1)
|
||||
YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2)
|
||||
YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'.' -f3)
|
||||
|
|
|
|||
|
|
@ -662,8 +662,7 @@ struct AigerWriter
|
|||
f << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
f << stringf("c\nGenerated by %s\n", yosys_version_str);
|
||||
f << stringf("c\nGenerated by %s\n", yosys_maybe_version());
|
||||
}
|
||||
|
||||
void write_map(std::ostream &f, bool verbose_map, bool no_startoffset)
|
||||
|
|
@ -746,7 +745,7 @@ struct AigerWriter
|
|||
{
|
||||
json.begin_object();
|
||||
json.entry("version", "Yosys Witness Aiger map");
|
||||
json.entry("gennerator", yosys_version_str);
|
||||
json.entry("gennerator", yosys_maybe_version());
|
||||
|
||||
json.entry("latch_count", aig_l);
|
||||
json.entry("input_count", aig_i);
|
||||
|
|
|
|||
|
|
@ -671,7 +671,7 @@ struct XAigerWriter
|
|||
//f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
|
||||
//f.write(buffer_str.data(), buffer_str.size());
|
||||
|
||||
f << stringf("Generated by %s\n", yosys_version_str);
|
||||
f << stringf("Generated by %s\n", yosys_maybe_version());
|
||||
|
||||
design->scratchpad_set_int("write_xaiger.num_ands", and_map.size());
|
||||
design->scratchpad_set_int("write_xaiger.num_wires", aig_map.size());
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ struct BlifBackend : public Backend {
|
|||
if (module->get_bool_attribute(ID::top))
|
||||
top_module_name = module->name.str();
|
||||
|
||||
*f << stringf("# Generated by %s\n", yosys_version_str);
|
||||
*f << stringf("# Generated by %s\n", yosys_maybe_version());
|
||||
|
||||
std::vector<RTLIL::Module*> mod_list;
|
||||
|
||||
|
|
|
|||
|
|
@ -1499,7 +1499,7 @@ struct BtorWorker
|
|||
{
|
||||
ywmap_json.begin_object();
|
||||
ywmap_json.entry("version", "Yosys Witness BTOR map");
|
||||
ywmap_json.entry("generator", yosys_version_str);
|
||||
ywmap_json.entry("generator", yosys_maybe_version());
|
||||
|
||||
ywmap_json.name("clocks");
|
||||
ywmap_json.begin_array();
|
||||
|
|
@ -1613,7 +1613,7 @@ struct BtorBackend : public Backend {
|
|||
log_cmd_error("No top module found.\n");
|
||||
|
||||
*f << stringf("; BTOR description generated by %s for module %s.\n",
|
||||
yosys_version_str, log_id(topmod));
|
||||
yosys_maybe_version(), log_id(topmod));
|
||||
|
||||
BtorWorker(*f, topmod, verbose, single_bad, cover_mode, print_internal_names, info_filename, ywmap_filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,8 @@ struct EdifBackend : public Backend {
|
|||
*f << stringf(" (edifVersion 2 0 0)\n");
|
||||
*f << stringf(" (edifLevel 0)\n");
|
||||
*f << stringf(" (keywordMap (keywordLevel 0))\n");
|
||||
*f << stringf(" (comment \"Generated by %s\")\n", yosys_version_str);
|
||||
|
||||
*f << stringf(" (comment \"Generated by %s\")\n", yosys_maybe_version());
|
||||
|
||||
*f << stringf(" (external LIB\n");
|
||||
*f << stringf(" (edifLevel 0)\n");
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ struct JnyWriter
|
|||
|
||||
f << "{\n";
|
||||
f << " \"$schema\": \"https://raw.githubusercontent.com/YosysHQ/yosys/main/misc/jny.schema.json\",\n";
|
||||
f << stringf(" \"generator\": \"%s\",\n", escape_string(yosys_version_str).c_str());
|
||||
f << stringf(" \"generator\": \"%s\",\n", escape_string(yosys_maybe_version()).c_str());
|
||||
f << " \"version\": \"0.0.1\",\n";
|
||||
f << " \"invocation\": \"" << escape_string(invk) << "\",\n";
|
||||
f << " \"features\": [";
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ struct JsonWriter
|
|||
design->sort();
|
||||
|
||||
f << stringf("{\n");
|
||||
f << stringf(" \"creator\": %s,\n", get_string(yosys_version_str).c_str());
|
||||
f << stringf(" \"creator\": %s,\n", get_string(yosys_maybe_version()).c_str());
|
||||
f << stringf(" \"modules\": {\n");
|
||||
vector<Module*> modules = use_selection ? design->selected_modules() : design->modules();
|
||||
bool first_module = true;
|
||||
|
|
|
|||
|
|
@ -459,7 +459,8 @@ struct RTLILBackend : public Backend {
|
|||
design->sort();
|
||||
|
||||
log("Output filename: %s\n", filename.c_str());
|
||||
*f << stringf("# Generated by %s\n", yosys_version_str);
|
||||
|
||||
*f << stringf("# Generated by %s\n", yosys_maybe_version());
|
||||
RTLIL_BACKEND::dump_design(*f, design, selected, true, false);
|
||||
}
|
||||
} RTLILBackend;
|
||||
|
|
|
|||
|
|
@ -1831,7 +1831,7 @@ struct Smt2Backend : public Backend {
|
|||
}
|
||||
}
|
||||
|
||||
*f << stringf("; SMT-LIBv2 description generated by %s\n", yosys_version_str);
|
||||
*f << stringf("; SMT-LIBv2 description generated by %s\n", yosys_maybe_version());
|
||||
|
||||
if (!bvmode)
|
||||
*f << stringf("; yosys-smt2-nobv\n");
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ struct SmvBackend : public Backend {
|
|||
if (module == nullptr)
|
||||
log_error("Module '%s' not found.\n", stmt[1].c_str());
|
||||
|
||||
*f << stringf("-- SMV description generated by %s\n", yosys_version_str);
|
||||
*f << stringf("-- SMV description generated by %s\n", yosys_maybe_version());
|
||||
|
||||
log("Creating SMV representation of module %s.\n", log_id(module));
|
||||
SmvWorker worker(module, verbose, *f);
|
||||
|
|
@ -816,7 +816,7 @@ struct SmvBackend : public Backend {
|
|||
|
||||
if (!modules.empty())
|
||||
{
|
||||
*f << stringf("-- SMV description generated by %s\n", yosys_version_str);
|
||||
*f << stringf("-- SMV description generated by %s\n", yosys_maybe_version());
|
||||
|
||||
for (auto module : modules) {
|
||||
log("Creating SMV representation of module %s.\n", log_id(module));
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ struct SpiceBackend : public Backend {
|
|||
if (module->get_bool_attribute(ID::top))
|
||||
top_module_name = module->name.str();
|
||||
|
||||
*f << stringf("* SPICE netlist generated by %s\n", yosys_version_str);
|
||||
*f << stringf("* SPICE netlist generated by %s\n", yosys_maybe_version());
|
||||
*f << stringf("\n");
|
||||
|
||||
for (auto module : design->modules())
|
||||
|
|
|
|||
|
|
@ -2621,7 +2621,8 @@ struct VerilogBackend : public Backend {
|
|||
|
||||
design->sort();
|
||||
|
||||
*f << stringf("/* Generated by %s */\n", yosys_version_str);
|
||||
*f << stringf("/* Generated by %s */\n", yosys_maybe_version());
|
||||
|
||||
for (auto module : design->modules()) {
|
||||
if (module->get_blackbox_attribute() != blackboxes)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -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\": {");
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
|
|
|||
15
kernel/io.cc
15
kernel/io.cc
|
|
@ -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
|
||||
|
|
|
|||
17
kernel/io.h
17
kernel/io.h
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ struct InternalStatsPass : public Pass {
|
|||
|
||||
if (json_mode) {
|
||||
log("{\n");
|
||||
log(" \"creator\": %s,\n", json11::Json(yosys_version_str).dump().c_str());
|
||||
log(" \"creator\": %s,\n", json11::Json(yosys_maybe_version()).dump().c_str());
|
||||
std::stringstream invocation;
|
||||
std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " "));
|
||||
log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str());
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ struct StatPass : public Pass {
|
|||
|
||||
if (json_mode) {
|
||||
log("{\n");
|
||||
log(" \"creator\": %s,\n", json11::Json(yosys_version_str).dump().c_str());
|
||||
log(" \"creator\": %s,\n", json11::Json(yosys_maybe_version()).dump().c_str());
|
||||
std::stringstream invocation;
|
||||
std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " "));
|
||||
log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str());
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ struct SatHelper
|
|||
fprintf(f, " %s\n", stime);
|
||||
fprintf(f, "$end\n");
|
||||
fprintf(f, "$version\n");
|
||||
fprintf(f, " Generated by %s\n", yosys_version_str);
|
||||
fprintf(f, " Generated by %s\n", yosys_maybe_version());
|
||||
fprintf(f, "$end\n");
|
||||
fprintf(f, "$comment\n");
|
||||
fprintf(f, " Generated from SAT problem in module %s (declared at %s)\n",
|
||||
|
|
|
|||
|
|
@ -2067,7 +2067,7 @@ struct SimWorker : SimShared
|
|||
|
||||
json.begin_object();
|
||||
json.entry("version", "Yosys sim summary");
|
||||
json.entry("generator", yosys_version_str);
|
||||
json.entry("generator", yosys_maybe_version());
|
||||
json.entry("steps", step);
|
||||
json.entry("top", log_id(top->module->name));
|
||||
json.name("assertions");
|
||||
|
|
@ -2346,7 +2346,7 @@ struct VCDWriter : public OutputWriter
|
|||
void write(std::map<int, bool> &use_signal) override
|
||||
{
|
||||
if (!vcdfile.is_open()) return;
|
||||
vcdfile << stringf("$version %s $end\n", worker->date ? yosys_version_str : "Yosys");
|
||||
vcdfile << stringf("$version %s $end\n", worker->date ? yosys_maybe_version() : "Yosys");
|
||||
|
||||
if (worker->date) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
|
|
@ -2637,7 +2637,7 @@ struct FSTWriter : public OutputWriter
|
|||
{
|
||||
if (!fstfile) return;
|
||||
std::time_t t = std::time(nullptr);
|
||||
fstWriterSetVersion(fstfile, worker->date ? yosys_version_str : "Yosys");
|
||||
fstWriterSetVersion(fstfile, worker->date ? yosys_maybe_version() : "Yosys");
|
||||
if (worker->date)
|
||||
fstWriterSetDate(fstfile, asctime(std::localtime(&t)));
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue