mirror of https://github.com/YosysHQ/yosys.git
write_json: also write module attributes.
This commit is contained in:
parent
c71785d65e
commit
546233f0e1
|
@ -83,12 +83,12 @@ struct JsonWriter
|
||||||
return str + " ]";
|
return str + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_parameters(const dict<IdString, Const> ¶meters)
|
void write_parameters(const dict<IdString, Const> ¶meters, bool for_module=false)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto ¶m : parameters) {
|
for (auto ¶m : parameters) {
|
||||||
f << stringf("%s\n", first ? "" : ",");
|
f << stringf("%s\n", first ? "" : ",");
|
||||||
f << stringf(" %s: ", get_name(param.first).c_str());
|
f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first).c_str());
|
||||||
if ((param.second.flags & RTLIL::ConstFlags::CONST_FLAG_STRING) != 0)
|
if ((param.second.flags & RTLIL::ConstFlags::CONST_FLAG_STRING) != 0)
|
||||||
f << get_string(param.second.decode_string());
|
f << get_string(param.second.decode_string());
|
||||||
else if (GetSize(param.second.bits) > 32)
|
else if (GetSize(param.second.bits) > 32)
|
||||||
|
@ -111,6 +111,10 @@ struct JsonWriter
|
||||||
|
|
||||||
f << stringf(" %s: {\n", get_name(module->name).c_str());
|
f << stringf(" %s: {\n", get_name(module->name).c_str());
|
||||||
|
|
||||||
|
f << stringf(" \"attributes\": {");
|
||||||
|
write_parameters(module->attributes, /*for_module=*/true);
|
||||||
|
f << stringf("\n },\n");
|
||||||
|
|
||||||
f << stringf(" \"ports\": {");
|
f << stringf(" \"ports\": {");
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto n : module->ports) {
|
for (auto n : module->ports) {
|
||||||
|
|
Loading…
Reference in New Issue