From 08c0fe164fefb28dc209d35e7bd757538311d2e6 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 19 Feb 2015 13:19:04 +0100 Subject: [PATCH] format fixes in "sat -dump_json" --- passes/sat/sat.cc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/passes/sat/sat.cc b/passes/sat/sat.cc index a7a510d7d..b9535f49d 100644 --- a/passes/sat/sat.cc +++ b/passes/sat/sat.cc @@ -758,13 +758,6 @@ struct SatHelper log("Dumping SAT model to WaveJSON file '%s'.\n", json_file_name.c_str()); - std::string module_fname = "unknown"; - auto apos = module->attributes.find("\\src"); - if(apos != module->attributes.end()) - module_fname = module->attributes["\\src"].decode_string(); - - fprintf(f, "// Generated by %s\n", yosys_version_str); - int mintime = 1, maxtime = 0, maxwidth = 0;; dict>> wavedata; @@ -784,13 +777,19 @@ struct SatHelper maxwidth = std::max(maxwidth, info.width); } - fprintf(f, "{ signal: [\n"); - for (auto &wd : wavedata) { + fprintf(f, "{ \"signal\": ["); + bool fist_wavedata = true; + for (auto &wd : wavedata) + { + fprintf(f, "%s", fist_wavedata ? "\n" : ",\n"); + fist_wavedata = false; + vector data; string name = wd.first.c_str(); while (name.substr(0, 1) == "\\") name = name.substr(1); - fprintf(f, " { name: '%s', wave: '", name.c_str()); + + fprintf(f, " { \"name\": \"%s\", \"wave\": \"", name.c_str()); for (int i = mintime; i <= maxtime; i++) { if (wd.second.second.count(i)) { string this_data = wd.second.second[i].as_string(); @@ -809,18 +808,18 @@ struct SatHelper } } if (wd.second.first != 1) { - fprintf(f, "', data: ["); + fprintf(f, "\", \"data\": ["); for (int i = 0; i < GetSize(data); i++) - fprintf(f, "%s'%s'", i ? ", " : "", data[i].c_str()); - fprintf(f, "] },\n"); + fprintf(f, "%s\"%s\"", i ? ", " : "", data[i].c_str()); + fprintf(f, "] }"); } else { - fprintf(f, "' },\n"); + fprintf(f, "\" }"); } } - fprintf(f, " ],\n"); - fprintf(f, " config: {\n"); - fprintf(f, " hscale: %.2f,\n", maxwidth / 4.0); - fprintf(f, " },\n"); + fprintf(f, "\n ],\n"); + fprintf(f, " \"config\": {\n"); + fprintf(f, " \"hscale\": %.2f\n", maxwidth / 4.0); + fprintf(f, " }\n"); fprintf(f, "}\n"); fclose(f); } -- 2.30.2