Fixed AST handling of variables declared inside a functions main block
authorClifford Wolf <clifford@clifford.at>
Tue, 5 Aug 2014 06:35:51 +0000 (08:35 +0200)
committerClifford Wolf <clifford@clifford.at>
Tue, 5 Aug 2014 06:35:51 +0000 (08:35 +0200)
frontends/ast/simplify.cc
tests/simple/task_func.v

index 694f1d4d84d41526f68c0537a31616c61a0e5bfc..20edc1739bcae5499e37451820b7621d6b2ffdb9 100644 (file)
@@ -1460,7 +1460,6 @@ skip_dynamic_range_lvalue_expansion:;
                }
 
                for (auto child : decl->children)
-               {
                        if (child->type == AST_WIRE)
                        {
                                AstNode *wire = child->clone();
@@ -1488,7 +1487,9 @@ skip_dynamic_range_lvalue_expansion:;
                                        }
                                }
                        }
-                       else
+
+               for (auto child : decl->children)
+                       if (child->type != AST_WIRE)
                        {
                                AstNode *stmt = child->clone();
                                stmt->replace_ids(replace_rules);
@@ -1500,7 +1501,6 @@ skip_dynamic_range_lvalue_expansion:;
                                        break;
                                }
                        }
-               }
 
        replace_fcall_with_id:
                if (type == AST_FCALL) {
index 8dbc90c5662215a992eb1f0b97a3a9ebc4df0726..51e31015fcce7d52ce28d0e7c75f9ceb2c0d8e05 100644 (file)
@@ -33,3 +33,16 @@ end
 
 endmodule
 
+
+module task_func_test02( input [7:0] din_a, input [7:0] din_b, output [7:0] dout_a);
+       assign dout_a = test(din_a,din_b);
+       function [7:0] test;
+               input [7:0] a;
+               input [7:0] b;
+               begin : TEST
+                       integer i;
+                       for (i = 0; i <= 7; i = i + 1)
+                               test[i] = a[i] & b[i];
+               end
+       endfunction
+endmodule