From: Clifford Wolf Date: Wed, 23 Sep 2015 05:16:03 +0000 (+0200) Subject: Warning for $display/$write outside initial block X-Git-Tag: yosys-0.6~142 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=559929e341a9416ab68ce1d0ef94068cd57512f9;p=yosys.git Warning for $display/$write outside initial block --- diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 77d4447f5..2abb48a58 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -182,20 +182,21 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, str = std::string(); } + if ((type == AST_TCALL) && (str == "$display" || str == "$write") && (!current_always || current_always->type != AST_INITIAL)) { + log_warning("System task `%s' outside initial block is unsupported at %s:%d.\n", str.c_str(), filename.c_str(), linenum); + delete_children(); + str = std::string(); + } + // print messages if this a call to $display() or $write() // This code implements only a small subset of Verilog-2005 $display() format specifiers, // but should be good enough for most uses if ((type == AST_TCALL) && ((str == "$display") || (str == "$write"))) { - if (!current_always || current_always->type != AST_INITIAL) - log_error("System task `$display' outside initial block is unsupported at %s:%d.\n", filename.c_str(), linenum); - size_t nargs = GetSize(children); if(nargs < 1) - { - log_error("System task `$display' got %d arguments, expected >= 1 at %s:%d.\n", - int(children.size()), filename.c_str(), linenum); - } + log_error("System task `%s' got %d arguments, expected >= 1 at %s:%d.\n", + str.c_str(), int(children.size()), filename.c_str(), linenum); // First argument is the format string AstNode *node_string = children[0]->clone();