diff options
author | Aki Van Ness <aki@yosyshq.com> | 2021-11-16 15:25:14 -0500 |
---|---|---|
committer | N. Engelhardt <nakengelhardt@gmail.com> | 2022-04-08 08:05:15 +0200 |
commit | 7a275567df5231673cb8832bb6e97e0aaa2b82d8 (patch) | |
tree | 7a0eac3c0225ded6317b8400721e5d9b6c426a28 | |
parent | d8b85e124783b55f414ccfd0513211daa8a94cdb (diff) | |
download | yosys-7a275567df5231673cb8832bb6e97e0aaa2b82d8.tar.gz yosys-7a275567df5231673cb8832bb6e97e0aaa2b82d8.tar.bz2 yosys-7a275567df5231673cb8832bb6e97e0aaa2b82d8.zip |
pass metadata: added the output of parameters,
it's kinda dumb at the moment and needs parsing based on type but it's a start
-rw-r--r-- | backends/metadata/metadata.cc | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/backends/metadata/metadata.cc b/backends/metadata/metadata.cc index eea8e8338..d5726d4d3 100644 --- a/backends/metadata/metadata.cc +++ b/backends/metadata/metadata.cc @@ -177,13 +177,41 @@ struct MetadataWriter { log_assert(cell != nullptr); - f << stringf(" {\n"); - f << stringf(" \"name\": %s,\n", get_string(RTLIL::unescape_id(cell->name)).c_str()); - f << stringf(" \"attributes\": {\n"); - f << stringf(" },\n"); - f << stringf(" \"parameters\": {\n"); - f << stringf(" },\n"); - f << stringf(" }"); + f << stringf(" {\n"); + f << stringf(" \"name\": %s,\n", get_string(RTLIL::unescape_id(cell->name)).c_str()); + f << stringf(" \"attributes\": {\n"); + + bool first_attr{true}; + for (auto& attr : cell->attributes) { + if (!first_attr) + f << stringf(",\n"); + const auto attr_val = attr.second.decode_string(); + if (attr_val.size() > 0) + f << stringf(" %s: \"%s\"\n", get_string(RTLIL::unescape_id(attr.first)).c_str(), attr_val.c_str()); + else + f << stringf(" %s: true\n", get_string(RTLIL::unescape_id(attr.first)).c_str()); + + first_attr = false; + } + + f << stringf(" },\n"); + f << stringf(" \"parameters\": {\n"); + + bool first_param{true}; + for (auto& param : cell->parameters) { + if (!first_param) + f << stringf(",\n"); + const auto param_val = param.second.decode_string(); + if (param_val.size() > 0) + f << stringf(" %s: \"%s\"\n", get_string(RTLIL::unescape_id(param.first)).c_str(), param_val.c_str()); + else + f << stringf(" %s: true\n", get_string(RTLIL::unescape_id(param.first)).c_str()); + + first_param = false; + } + + f << stringf(" },\n"); + f << stringf(" }"); } }; |