3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-09 16:55:49 +00:00

Merge pull request #5086 from YosysHQ/emil/driver-no-version

driver: add --no-version to suppress writing Yosys version
This commit is contained in:
Emil J 2025-05-08 16:28:25 +02:00 committed by GitHub
commit bfbbb8cf98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 40 additions and 26 deletions

View file

@ -662,8 +662,7 @@ struct AigerWriter
f << std::endl; f << std::endl;
} }
} }
f << stringf("c\nGenerated by %s\n", yosys_maybe_version());
f << stringf("c\nGenerated by %s\n", yosys_version_str);
} }
void write_map(std::ostream &f, bool verbose_map, bool no_startoffset) void write_map(std::ostream &f, bool verbose_map, bool no_startoffset)
@ -746,7 +745,7 @@ struct AigerWriter
{ {
json.begin_object(); json.begin_object();
json.entry("version", "Yosys Witness Aiger map"); 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("latch_count", aig_l);
json.entry("input_count", aig_i); json.entry("input_count", aig_i);

View file

@ -671,7 +671,7 @@ struct XAigerWriter
//f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be)); //f.write(reinterpret_cast<const char*>(&buffer_size_be), sizeof(buffer_size_be));
//f.write(buffer_str.data(), buffer_str.size()); //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_ands", and_map.size());
design->scratchpad_set_int("write_xaiger.num_wires", aig_map.size()); design->scratchpad_set_int("write_xaiger.num_wires", aig_map.size());

View file

@ -649,7 +649,7 @@ struct BlifBackend : public Backend {
if (module->get_bool_attribute(ID::top)) if (module->get_bool_attribute(ID::top))
top_module_name = module->name.str(); 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; std::vector<RTLIL::Module*> mod_list;

View file

@ -1499,7 +1499,7 @@ struct BtorWorker
{ {
ywmap_json.begin_object(); ywmap_json.begin_object();
ywmap_json.entry("version", "Yosys Witness BTOR map"); 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.name("clocks");
ywmap_json.begin_array(); ywmap_json.begin_array();
@ -1613,7 +1613,7 @@ struct BtorBackend : public Backend {
log_cmd_error("No top module found.\n"); log_cmd_error("No top module found.\n");
*f << stringf("; BTOR description generated by %s for module %s.\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); BtorWorker(*f, topmod, verbose, single_bad, cover_mode, print_internal_names, info_filename, ywmap_filename);

View file

@ -231,7 +231,8 @@ struct EdifBackend : public Backend {
*f << stringf(" (edifVersion 2 0 0)\n"); *f << stringf(" (edifVersion 2 0 0)\n");
*f << stringf(" (edifLevel 0)\n"); *f << stringf(" (edifLevel 0)\n");
*f << stringf(" (keywordMap (keywordLevel 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(" (external LIB\n");
*f << stringf(" (edifLevel 0)\n"); *f << stringf(" (edifLevel 0)\n");

View file

@ -125,7 +125,7 @@ struct JnyWriter
f << "{\n"; f << "{\n";
f << " \"$schema\": \"https://raw.githubusercontent.com/YosysHQ/yosys/main/misc/jny.schema.json\",\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 << " \"version\": \"0.0.1\",\n";
f << " \"invocation\": \"" << escape_string(invk) << "\",\n"; f << " \"invocation\": \"" << escape_string(invk) << "\",\n";
f << " \"features\": ["; f << " \"features\": [";

View file

@ -291,7 +291,7 @@ struct JsonWriter
design->sort(); design->sort();
f << stringf("{\n"); 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"); f << stringf(" \"modules\": {\n");
vector<Module*> modules = use_selection ? design->selected_modules() : design->modules(); vector<Module*> modules = use_selection ? design->selected_modules() : design->modules();
bool first_module = true; bool first_module = true;

View file

@ -459,7 +459,8 @@ struct RTLILBackend : public Backend {
design->sort(); design->sort();
log("Output filename: %s\n", filename.c_str()); 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); RTLIL_BACKEND::dump_design(*f, design, selected, true, false);
} }
} RTLILBackend; } RTLILBackend;

View file

@ -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) if (!bvmode)
*f << stringf("; yosys-smt2-nobv\n"); *f << stringf("; yosys-smt2-nobv\n");

View file

@ -797,7 +797,7 @@ struct SmvBackend : public Backend {
if (module == nullptr) if (module == nullptr)
log_error("Module '%s' not found.\n", stmt[1].c_str()); 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)); log("Creating SMV representation of module %s.\n", log_id(module));
SmvWorker worker(module, verbose, *f); SmvWorker worker(module, verbose, *f);
@ -816,7 +816,7 @@ struct SmvBackend : public Backend {
if (!modules.empty()) 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) { for (auto module : modules) {
log("Creating SMV representation of module %s.\n", log_id(module)); log("Creating SMV representation of module %s.\n", log_id(module));

View file

@ -215,7 +215,7 @@ struct SpiceBackend : public Backend {
if (module->get_bool_attribute(ID::top)) if (module->get_bool_attribute(ID::top))
top_module_name = module->name.str(); 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"); *f << stringf("\n");
for (auto module : design->modules()) for (auto module : design->modules())

View file

@ -2596,7 +2596,8 @@ struct VerilogBackend : public Backend {
design->sort(); 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()) { for (auto module : design->modules()) {
if (module->get_blackbox_attribute() != blackboxes) if (module->get_blackbox_attribute() != blackboxes)
continue; continue;

View file

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

View file

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

View file

@ -81,6 +81,14 @@ YOSYS_NAMESPACE_BEGIN
int autoidx = 1; int autoidx = 1;
int yosys_xtrace = 0; int yosys_xtrace = 0;
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; RTLIL::Design *yosys_design = NULL;
CellTypes yosys_celltypes; CellTypes yosys_celltypes;
@ -144,7 +152,7 @@ void yosys_banner()
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <claire@yosyshq.com> |\n"); 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(" | Distributed under an ISC-like license, type \"license\" to see terms |\n");
log(" \\----------------------------------------------------------------------------/\n"); log(" \\----------------------------------------------------------------------------/\n");
log(" %s\n", yosys_version_str); log(" %s\n", yosys_maybe_version());
} }
#if !defined(YOSYS_DISABLE_SPAWN) #if !defined(YOSYS_DISABLE_SPAWN)

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) // from kernel/version_*.o (cc source generated from Makefile)
extern const char *yosys_version_str; extern const char *yosys_version_str;
const char* yosys_maybe_version();
// from passes/cmds/design.cc // from passes/cmds/design.cc
extern std::map<std::string, RTLIL::Design*> saved_designs; extern std::map<std::string, RTLIL::Design*> saved_designs;

View file

@ -274,6 +274,7 @@ inline int GetSize(RTLIL::Wire *wire);
extern int autoidx; extern int autoidx;
extern int yosys_xtrace; extern int yosys_xtrace;
extern bool yosys_write_versions;
RTLIL::IdString new_id(std::string file, int line, std::string func); 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); RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix);

View file

@ -99,7 +99,7 @@ struct InternalStatsPass : public Pass {
if (json_mode) { if (json_mode) {
log("{\n"); 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::stringstream invocation;
std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " ")); std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " "));
log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str()); log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str());

View file

@ -444,7 +444,7 @@ struct StatPass : public Pass {
if (json_mode) { if (json_mode) {
log("{\n"); 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::stringstream invocation;
std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " ")); std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " "));
log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str()); log(" \"invocation\": %s,\n", json11::Json(invocation.str()).dump().c_str());

View file

@ -691,7 +691,7 @@ struct SatHelper
fprintf(f, " %s\n", stime); fprintf(f, " %s\n", stime);
fprintf(f, "$end\n"); fprintf(f, "$end\n");
fprintf(f, "$version\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, "$end\n");
fprintf(f, "$comment\n"); fprintf(f, "$comment\n");
fprintf(f, " Generated from SAT problem in module %s (declared at %s)\n", fprintf(f, " Generated from SAT problem in module %s (declared at %s)\n",

View file

@ -2065,7 +2065,7 @@ struct SimWorker : SimShared
json.begin_object(); json.begin_object();
json.entry("version", "Yosys sim summary"); json.entry("version", "Yosys sim summary");
json.entry("generator", yosys_version_str); json.entry("generator", yosys_maybe_version());
json.entry("steps", step); json.entry("steps", step);
json.entry("top", log_id(top->module->name)); json.entry("top", log_id(top->module->name));
json.name("assertions"); json.name("assertions");
@ -2344,7 +2344,7 @@ struct VCDWriter : public OutputWriter
void write(std::map<int, bool> &use_signal) override void write(std::map<int, bool> &use_signal) override
{ {
if (!vcdfile.is_open()) return; 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) { if (worker->date) {
std::time_t t = std::time(nullptr); std::time_t t = std::time(nullptr);
@ -2412,7 +2412,7 @@ struct FSTWriter : public OutputWriter
{ {
if (!fstfile) return; if (!fstfile) return;
std::time_t t = std::time(nullptr); 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) if (worker->date)
fstWriterSetDate(fstfile, asctime(std::localtime(&t))); fstWriterSetDate(fstfile, asctime(std::localtime(&t)));
else else