write_json: also write module attributes.
authorwhitequark <whitequark@whitequark.org>
Tue, 12 Jul 2016 06:32:04 +0000 (06:32 +0000)
committerwhitequark <whitequark@whitequark.org>
Tue, 12 Jul 2016 06:32:04 +0000 (06:32 +0000)
backends/json/json.cc

index 05530ee69cfbd612e30e43dd5eed0bb55f52f373..4baffa33e8d14a03de083e29a9e67a002ae5d4b7 100644 (file)
@@ -83,12 +83,12 @@ struct JsonWriter
                return str + " ]";
        }
 
-       void write_parameters(const dict<IdString, Const> &parameters)
+       void write_parameters(const dict<IdString, Const> &parameters, bool for_module=false)
        {
                bool first = true;
                for (auto &param : parameters) {
                        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)
                                f << get_string(param.second.decode_string());
                        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("      \"attributes\": {");
+               write_parameters(module->attributes, /*for_module=*/true);
+               f << stringf("\n      },\n");
+
                f << stringf("      \"ports\": {");
                bool first = true;
                for (auto n : module->ports) {