json: Change compat mode to directly emit ints <= 32 bits
authorR. Ou <rqou@robertou.com>
Sun, 9 Feb 2020 09:01:18 +0000 (01:01 -0800)
committerR. Ou <rqou@robertou.com>
Sun, 9 Feb 2020 09:01:18 +0000 (01:01 -0800)
This increases compatibility with certain older parsers in some cases
that worked before commit 15fae357 but do not work with the current
compat-int mode

backends/json/json.cc

index 5c67cb857e34aae90a49222398a3f345df459d84..6c924ff99798690d7cdb90a546a5c611cd260dcf 100644 (file)
@@ -104,7 +104,7 @@ struct JsonWriter
                        if (state < 2)
                                str += " ";
                        f << get_string(str);
-               } else if (compat_int_mode && GetSize(value) == 32 && value.is_fully_def()) {
+               } else if (compat_int_mode && GetSize(value) <= 32 && value.is_fully_def()) {
                        if ((value.flags & RTLIL::ConstFlags::CONST_FLAG_SIGNED) != 0)
                                f << stringf("%d", value.as_int());
                        else
@@ -296,7 +296,7 @@ struct JsonBackend : public Backend {
                log("        include AIG models for the different gate types\n");
                log("\n");
                log("    -compat-int\n");
-               log("        emit 32-bit fully-defined parameter values directly\n");
+               log("        emit 32-bit or smaller fully-defined parameter values directly\n");
                log("        as JSON numbers (for compatibility with old parsers)\n");
                log("\n");
                log("\n");
@@ -540,7 +540,7 @@ struct JsonPass : public Pass {
                log("        also include AIG models for the different gate types\n");
                log("\n");
                log("    -compat-int\n");
-               log("        emit 32-bit fully-defined parameter values directly\n");
+               log("        emit 32-bit or smaller fully-defined parameter values directly\n");
                log("        as JSON numbers (for compatibility with old parsers)\n");
                log("\n");
                log("See 'help write_json' for a description of the JSON format used.\n");