3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-11 01:35:49 +00:00

driver: allow --no-version still write things like Generated by Yosys

This commit is contained in:
Emil J. Tywoniak 2025-05-07 11:34:23 +02:00
parent d7affb8821
commit 90a2c92370
21 changed files with 36 additions and 40 deletions

View file

@ -662,8 +662,7 @@ struct AigerWriter
f << std::endl; f << std::endl;
} }
} }
if (yosys_write_versions) 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,8 +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());
if (yosys_write_versions) f << stringf("Generated by %s\n", yosys_maybe_version());
f << stringf("Generated by %s\n", yosys_version_str);
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,8 +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();
if (yosys_write_versions) *f << stringf("# Generated by %s\n", yosys_maybe_version());
*f << stringf("# Generated by %s\n", yosys_version_str);
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

@ -232,8 +232,7 @@ struct EdifBackend : public Backend {
*f << stringf(" (edifLevel 0)\n"); *f << stringf(" (edifLevel 0)\n");
*f << stringf(" (keywordMap (keywordLevel 0))\n"); *f << stringf(" (keywordMap (keywordLevel 0))\n");
if (yosys_write_versions) *f << stringf(" (comment \"Generated by %s\")\n", yosys_maybe_version());
*f << stringf(" (comment \"Generated by %s\")\n", yosys_version_str);
*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,8 +291,7 @@ struct JsonWriter
design->sort(); design->sort();
f << stringf("{\n"); f << stringf("{\n");
if (yosys_write_versions) f << stringf(" \"creator\": %s,\n", get_string(yosys_maybe_version()).c_str());
f << stringf(" \"creator\": %s,\n", get_string(yosys_version_str).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

@ -460,8 +460,7 @@ struct RTLILBackend : public Backend {
log("Output filename: %s\n", filename.c_str()); log("Output filename: %s\n", filename.c_str());
if (yosys_write_versions) *f << stringf("# Generated by %s\n", yosys_maybe_version());
*f << stringf("# Generated by %s\n", yosys_version_str);
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

@ -1289,7 +1289,6 @@ class MkVcd:
assert t >= self.t assert t >= self.t
if t != self.t: if t != self.t:
if self.t == -1: if self.t == -1:
# TODO if (yosys_write_versions) equivalent?
print("$version Generated by Yosys-SMTBMC $end", file=self.f) print("$version Generated by Yosys-SMTBMC $end", file=self.f)
print("$timescale 1ns $end", file=self.f) print("$timescale 1ns $end", file=self.f)
print("$var integer 32 t smt_step $end", file=self.f) print("$var integer 32 t smt_step $end", file=self.f)

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,8 +2596,7 @@ struct VerilogBackend : public Backend {
design->sort(); design->sort();
if (yosys_write_versions) *f << stringf("/* Generated by %s */\n", yosys_maybe_version());
*f << stringf("/* Generated by %s */\n", yosys_version_str);
for (auto module : design->modules()) { for (auto module : design->modules()) {
if (module->get_blackbox_attribute() != blackboxes) if (module->get_blackbox_attribute() != blackboxes)

View file

@ -252,7 +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 Yosys version in command outputs") ("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. " \
@ -693,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;
@ -733,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

@ -82,6 +82,13 @@ YOSYS_NAMESPACE_BEGIN
int autoidx = 1; int autoidx = 1;
int yosys_xtrace = 0; int yosys_xtrace = 0;
bool yosys_write_versions = true; 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;
@ -145,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

@ -99,8 +99,7 @@ struct InternalStatsPass : public Pass {
if (json_mode) { if (json_mode) {
log("{\n"); log("{\n");
if (yosys_write_versions) log(" \"creator\": %s,\n", json11::Json(yosys_maybe_version()).dump().c_str());
log(" \"creator\": %s,\n", json11::Json(yosys_version_str).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,8 +444,7 @@ struct StatPass : public Pass {
if (json_mode) { if (json_mode) {
log("{\n"); log("{\n");
if (yosys_write_versions) log(" \"creator\": %s,\n", json11::Json(yosys_maybe_version()).dump().c_str());
log(" \"creator\": %s,\n", json11::Json(yosys_version_str).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

@ -690,11 +690,9 @@ struct SatHelper
fprintf(f, "$date\n"); fprintf(f, "$date\n");
fprintf(f, " %s\n", stime); fprintf(f, " %s\n", stime);
fprintf(f, "$end\n"); fprintf(f, "$end\n");
if (yosys_write_versions) { fprintf(f, "$version\n");
fprintf(f, "$version\n"); fprintf(f, " Generated by %s\n", yosys_maybe_version());
fprintf(f, " Generated by %s\n", yosys_version_str); 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",
module->name.c_str(), module_fname.c_str()); module->name.c_str(), module_fname.c_str());

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