Support $fflush without arguments, #1638.

This commit is contained in:
Wilson Snyder 2020-04-05 10:11:28 -04:00
parent 6eadb8e771
commit e55338f927
5 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
** Add simplistic class support with many restrictions, see manual, #377.
**** Support $fflush without arguments, #1638.
* Verilator 4.032 2020-04-04

View File

@ -1181,6 +1181,10 @@ void VL_FCLOSE_I(IData fdi) VL_MT_SAFE {
VerilatedImp::fdDelete(fdi);
}
void VL_FFLUSH_ALL() VL_MT_SAFE {
fflush(stdout);
}
void VL_SFORMAT_X(int obits, CData& destr, const char* formatp, ...) VL_MT_SAFE {
static VL_THREAD_LOCAL std::string output; // static only for speed
output = "";

View File

@ -557,7 +557,7 @@ public:
}
virtual void visit(AstFFlush* nodep) VL_OVERRIDE {
if (!nodep->filep()) {
puts("fflush(stdout);\n");
puts("Verilated::flushCall();\n");
} else {
puts("if (");
iterateAndNextNull(nodep->filep());

View File

@ -3232,7 +3232,7 @@ system_t_call<nodep>: // IEEE: system_tf_call (as task)
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemT($1, $3); }
//
| yD_FCLOSE '(' idClassSel ')' { $$ = new AstFClose($1, $3); }
| yD_FFLUSH parenE { $$ = NULL; BBUNSUP($1, "Unsupported: $fflush of all handles does not map to C++."); }
| yD_FFLUSH parenE { $$ = new AstFFlush($1, NULL); }
| yD_FFLUSH '(' expr ')' { $$ = new AstFFlush($1, $3); }
| yD_FINISH parenE { $$ = new AstFinish($1); }
| yD_FINISH '(' expr ')' { $$ = new AstFinish($1); DEL($3); }

View File

@ -61,6 +61,8 @@ module t;
$fwriteb(file, "b: "); $fwriteb(file, i); $fwriteb(file, " "); $fdisplayb(file, i);
$fflush(file);
$fflush();
$fflush;
$fclose(file);
`ifdef verilator