Avoid creating very long strings in test_autotb

This commit is contained in:
Clifford Wolf 2016-09-19 10:20:20 +02:00
parent aaa99c35bd
commit 5e155aa121
1 changed files with 10 additions and 4 deletions

View 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");