write_json: dump default parameter values
authorMarcelina Kościelnicka <mwk@0x04.net>
Thu, 16 Apr 2020 13:57:03 +0000 (15:57 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Tue, 21 Apr 2020 17:09:00 +0000 (19:09 +0200)
Fixes #1823.

This will allow nextpnr to reuse the default value information already
present in yosys cells_sim.v and avoid duplicating (and probably
desyncing) this information.

backends/json/json.cc

index 1da23bb7d035c50538e4f170a48250419a2584e1..1a8b757ef1f1fdb95b53f6fe16a0aee5d65d5909 100644 (file)
@@ -141,6 +141,12 @@ struct JsonWriter
                write_parameters(module->attributes, /*for_module=*/true);
                f << stringf("\n      },\n");
 
+               if (module->parameter_default_values.size()) {
+                       f << stringf("      \"parameter_default_values\": {");
+                       write_parameters(module->parameter_default_values, /*for_module=*/true);
+                       f << stringf("\n      },\n");
+               }
+
                f << stringf("      \"ports\": {");
                bool first = true;
                for (auto n : module->ports) {
@@ -310,6 +316,10 @@ struct JsonBackend : public Backend {
                log("            <attribute_name>: <attribute_value>,\n");
                log("            ...\n");
                log("          },\n");
+               log("          \"parameter_default_values\": {\n");
+               log("            <parameter_name>: <parameter_value>,\n");
+               log("            ...\n");
+               log("          },\n");
                log("          \"ports\": {\n");
                log("            <port_name>: <port_details>,\n");
                log("            ...\n");