diff options
author | Aki Van Ness <aki@yosyshq.com> | 2022-08-02 06:58:41 -0400 |
---|---|---|
committer | Aki Van Ness <aki@yosyshq.com> | 2022-08-02 06:58:41 -0400 |
commit | 4f0ee383c9b48174c916540d7aa1eb624a4a9a25 (patch) | |
tree | c73a9b79203c5a384b3eb5a35a04c39d297c057e /backends/jny | |
parent | 7d4f87d69f06d2cf6259fb445275a5f479bf74ee (diff) | |
download | yosys-4f0ee383c9b48174c916540d7aa1eb624a4a9a25.tar.gz yosys-4f0ee383c9b48174c916540d7aa1eb624a4a9a25.tar.bz2 yosys-4f0ee383c9b48174c916540d7aa1eb624a4a9a25.zip |
backend: jny: updated the `JnyWriter` to emite a new "invocation" entry as well as a "$schema" entry to point to the location the schema will be at
Diffstat (limited to 'backends/jny')
-rw-r--r-- | backends/jny/jny.cc | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/backends/jny/jny.cc b/backends/jny/jny.cc index d801b144c..2b8d51b76 100644 --- a/backends/jny/jny.cc +++ b/backends/jny/jny.cc @@ -27,6 +27,8 @@ #include <algorithm> #include <unordered_map> #include <vector> +#include <sstream> +#include <iterator> USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN @@ -116,17 +118,17 @@ struct JnyWriter _include_connections(connections), _include_attributes(attributes), _include_properties(properties) { } - void write_metadata(Design *design, uint16_t indent_level = 0) + void write_metadata(Design *design, uint16_t indent_level = 0, std::string invk = "") { log_assert(design != nullptr); design->sort(); f << "{\n"; + f << " \"$schema\": \"https://raw.githubusercontent.com/YosysHQ/yosys/master/misc/jny.schema.json\",\n"; f << stringf(" \"generator\": \"%s\",\n", escape_string(yosys_version_str).c_str()); - // XXX(aki): Replace this with a proper version info eventually:tm: - f << " \"version\": \"0.0.0\",\n"; - + f << " \"version\": \"0.0.1\",\n"; + f << " \"invocation\": \"" << escape_string(invk) << "\",\n"; f << " \"features\": ["; size_t fnum{0}; @@ -409,11 +411,12 @@ struct JnyWriter struct JnyBackend : public Backend { JnyBackend() : Backend("jny", "generate design metadata") { } void help() override { - // XXX(aki): TODO: explicitly document the JSON schema // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); log(" jny [options] [selection]\n"); log("\n"); + log("Write JSON netlist metadata for the current design\n"); + log("\n"); log(" -no-connections\n"); log(" Don't include connection information in the netlist output.\n"); log("\n"); @@ -423,8 +426,8 @@ struct JnyBackend : public Backend { log(" -no-properties\n"); log(" Don't include property information in the netlist output.\n"); log("\n"); - log("Write a JSON metadata for the current design\n"); - log("\n"); + log("The JSON schema for JNY output files is located in the \"jny.schema.json\" file\n"); + log("which is located at \"https://raw.githubusercontent.com/YosysHQ/yosys/master/misc/jny.schema.json\"\n"); log("\n"); } @@ -453,12 +456,22 @@ struct JnyBackend : public Backend { break; } + + // Compose invocation line + std::ostringstream invk; + if (!args.empty()) { + std::copy(args.begin(), args.end(), + std::ostream_iterator<std::string>(invk, " ") + ); + } + invk << filename; + extra_args(f, filename, args, argidx); log_header(design, "Executing jny backend.\n"); JnyWriter jny_writer(*f, false, connections, attributes, properties); - jny_writer.write_metadata(design); + jny_writer.write_metadata(design, 0, invk.str()); } } JnyBackend; @@ -472,7 +485,7 @@ struct JnyPass : public Pass { log("\n"); log(" jny [options] [selection]\n"); log("\n"); - log("Write a JSON netlist metadata for the current design\n"); + log("Write JSON netlist metadata for the current design\n"); log("\n"); log(" -o <filename>\n"); log(" write to the specified file.\n"); @@ -520,6 +533,15 @@ struct JnyPass : public Pass { break; } + + // Compose invocation line + std::ostringstream invk; + if (!args.empty()) { + std::copy(args.begin(), args.end(), + std::ostream_iterator<std::string>(invk, " ") + ); + } + extra_args(args, argidx, design); std::ostream *f; @@ -534,13 +556,14 @@ struct JnyPass : public Pass { log_error("Can't open file `%s' for writing: %s\n", filename.c_str(), strerror(errno)); } f = ff; + invk << filename; } else { f = &buf; } JnyWriter jny_writer(*f, false, connections, attributes, properties); - jny_writer.write_metadata(design); + jny_writer.write_metadata(design, 0, invk.str()); if (!filename.empty()) { delete f; |