Avoid creating very long strings in test_autotb
authorClifford Wolf <clifford@clifford.at>
Mon, 19 Sep 2016 08:20:20 +0000 (10:20 +0200)
committerClifford Wolf <clifford@clifford.at>
Mon, 19 Sep 2016 08:20:20 +0000 (10:20 +0200)
passes/tests/test_autotb.cc

index 69e2e76d7ca2c2374a360a44c1b04710df64bf44..a0b47df8c0fffd5dd932eaa37fbd5f07bb487f38 100644 (file)
@@ -220,19 +220,21 @@ static void autotest(std::ostream &f, RTLIL::Design *design, int num_iter, int s
                        for (auto it = signal_in.begin(); it != signal_in.end(); it++) {
                                f << stringf("%s %s", it == signal_in.begin() ? "" : ",", it->first.c_str());
                                int len = it->second;
+                               header2 += ", \"";
                                if (len > 1)
                                        header2 += "/", len--;
                                while (len > 1)
                                        header2 += "-", len--;
                                if (len > 0)
                                        header2 += shorthand, len--;
+                               header2 += "\"";
                                header1.push_back("    " + it->first);
                                header1.back()[0] = shorthand;
                                shorthand = shorthand == 'Z' ? 'A' : shorthand+1;
                        }
                else {
                        f << stringf(" 1'bx");
-                       header2 += "#";
+                       header2 += ", \"#\"";
                }
                f << stringf(" }, {");
                header2 += " ";
@@ -240,19 +242,21 @@ static void autotest(std::ostream &f, RTLIL::Design *design, int num_iter, int s
                        for (auto it = signal_clk.begin(); it != signal_clk.end(); it++) {
                                f << stringf("%s %s", it == signal_clk.begin() ? "" : ",", it->first.c_str());
                                int len = it->second;
+                               header2 += ", \"";
                                if (len > 1)
                                        header2 += "/", len--;
                                while (len > 1)
                                        header2 += "-", len--;
                                if (len > 0)
                                        header2 += shorthand, len--;
+                               header2 += "\"";
                                header1.push_back("    " + it->first);
                                header1.back()[0] = shorthand;
                                shorthand = shorthand == 'Z' ? 'A' : shorthand+1;
                        }
                } else {
                        f << stringf(" 1'bx");
-                       header2 += "#";
+                       header2 += ", \"#\"";
                }
                f << stringf(" }, {");
                header2 += " ";
@@ -260,19 +264,21 @@ static void autotest(std::ostream &f, RTLIL::Design *design, int num_iter, int s
                        for (auto it = signal_out.begin(); it != signal_out.end(); it++) {
                                f << stringf("%s %s", it == signal_out.begin() ? "" : ",", it->first.c_str());
                                int len = it->second;
+                               header2 += ", \"";
                                if (len > 1)
                                        header2 += "/", len--;
                                while (len > 1)
                                        header2 += "-", len--;
                                if (len > 0)
                                        header2 += shorthand, len--;
+                               header2 += "\"";
                                header1.push_back("    " + it->first);
                                header1.back()[0] = shorthand;
                                shorthand = shorthand == 'Z' ? 'A' : shorthand+1;
                        }
                } else {
                        f << stringf(" 1'bx");
-                       header2 += "#";
+                       header2 += ", \"#\"";
                }
                f << stringf(" }, $time, i);\n");
                f << stringf("end\n");
@@ -284,7 +290,7 @@ static void autotest(std::ostream &f, RTLIL::Design *design, int num_iter, int s
                for (auto &hdr : header1)
                        f << stringf("\t$fdisplay(file, \"#OUT#   %s\");\n", hdr.c_str());
                f << stringf("\t$fdisplay(file, \"#OUT#\");\n");
-               f << stringf("\t$fdisplay(file, \"#OUT# %s\");\n", header2.c_str());
+               f << stringf("\t$fdisplay(file, {\"#OUT# \"%s});\n", header2.c_str());
                f << stringf("end\n");
                f << stringf("endtask\n\n");