diff options
author | Aki Van Ness <aki@yosyshq.com> | 2021-12-03 13:44:09 -0500 |
---|---|---|
committer | N. Engelhardt <nakengelhardt@gmail.com> | 2022-04-08 08:05:15 +0200 |
commit | bdf14557ca3a25b10b6300a76d974d95988ebdf4 (patch) | |
tree | 655866e026a5d80e3f486e08efc5607a02c49c02 | |
parent | 1876ed21e704a8c4c384981560659da1fc248d1b (diff) | |
download | yosys-bdf14557ca3a25b10b6300a76d974d95988ebdf4.tar.gz yosys-bdf14557ca3a25b10b6300a76d974d95988ebdf4.tar.bz2 yosys-bdf14557ca3a25b10b6300a76d974d95988ebdf4.zip |
pass metadata: added the machinery to write param and attributes
-rw-r--r-- | backends/metadata/metadata.cc | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/backends/metadata/metadata.cc b/backends/metadata/metadata.cc index 8f73e474f..103db533f 100644 --- a/backends/metadata/metadata.cc +++ b/backends/metadata/metadata.cc @@ -172,6 +172,21 @@ struct MetadataWriter f << " ]\n"; f << " }"; } + + void write_param_val(const Const& v) + { + if ((v.flags & RTLIL::ConstFlags::CONST_FLAG_STRING) == RTLIL::ConstFlags::CONST_FLAG_STRING) { + const auto str = v.decode_string(); + + + f << get_string(str); + } else if ((v.flags & RTLIL::ConstFlags::CONST_FLAG_SIGNED) == RTLIL::ConstFlags::CONST_FLAG_SIGNED) { + f << stringf("\"%dsd %d\"", v.size(), v.as_int()); + } else if ((v.flags & RTLIL::ConstFlags::CONST_FLAG_REAL) == RTLIL::ConstFlags::CONST_FLAG_REAL) { + + } else { + f << get_string(v.as_string()); + } } void write_cell(Cell* cell) @@ -187,10 +202,12 @@ struct MetadataWriter if (!first_attr) f << stringf(",\n"); const auto attr_val = attr.second; - if (!attr_val.empty()) - f << stringf(" %s: \"%s\"\n", get_string(RTLIL::unescape_id(attr.first)).c_str(), attr_val.decode_string().c_str()); - else - f << stringf(" %s: true\n", get_string(RTLIL::unescape_id(attr.first)).c_str()); + if (!attr_val.empty()) { + f << stringf(" %s: ", get_string(RTLIL::unescape_id(attr.first)).c_str()); + write_param_val(attr_val); + } else { + f << stringf(" %s: true", get_string(RTLIL::unescape_id(attr.first)).c_str()); + } first_attr = false; } @@ -204,10 +221,12 @@ struct MetadataWriter if (!first_param) f << stringf(",\n"); const auto param_val = param.second; - if (!param_val.empty()) - f << stringf(" %s: \"%s\"\n", get_string(RTLIL::unescape_id(param.first)).c_str(), param_val.decode_string().c_str()); - else - f << stringf(" %s: true\n", get_string(RTLIL::unescape_id(param.first)).c_str()); + if (!param_val.empty()) { + f << stringf(" %s: ", get_string(RTLIL::unescape_id(param.first)).c_str()); + write_param_val(param_val); + } else { + f << stringf(" %s: true", get_string(RTLIL::unescape_id(param.first)).c_str()); + } first_param = false; } |