More bugfixes in handling of parameters in tasks and functions
authorClifford Wolf <clifford@clifford.at>
Thu, 12 Nov 2015 12:02:36 +0000 (13:02 +0100)
committerClifford Wolf <clifford@clifford.at>
Thu, 12 Nov 2015 12:02:36 +0000 (13:02 +0100)
frontends/ast/simplify.cc
tests/simple/task_func.v

index 24e96f074ebc28682a0d95fb873f1348ad20b651..b7ccf7e0ba3ca3b5fef1ecc8aa6f51a078c2a7cc 100644 (file)
@@ -1773,6 +1773,7 @@ skip_dynamic_range_lvalue_expansion:;
 
                size_t arg_count = 0;
                std::map<std::string, std::string> replace_rules;
+               vector<AstNode*> added_mod_children;
 
                if (current_block == NULL)
                {
@@ -1873,9 +1874,13 @@ skip_dynamic_range_lvalue_expansion:;
                                wire->is_input = false;
                                wire->is_output = false;
                                current_ast_mod->children.push_back(wire);
-                               while (wire->simplify(true, false, false, 1, -1, false, false)) { }
+                               added_mod_children.push_back(wire);
+
+                               if (child->type == AST_WIRE)
+                                       while (wire->simplify(true, false, false, 1, -1, false, false)) { }
 
                                replace_rules[child->str] = wire->str;
+                               current_scope[wire->str] = wire;
 
                                if ((child->is_input || child->is_output) && arg_count < children.size())
                                {
@@ -1895,6 +1900,11 @@ skip_dynamic_range_lvalue_expansion:;
                                }
                        }
 
+               for (auto child : added_mod_children) {
+                       child->replace_ids(prefix, replace_rules);
+                       while (child->simplify(true, false, false, 1, -1, false, false)) { }
+               }
+
                for (auto child : decl->children)
                        if (child->type != AST_WIRE && child->type != AST_PARAMETER && child->type != AST_LOCALPARAM)
                        {
index 36ac768eacd40087c933fac7aa8002c02b26b57b..fa50c1d5cadad665e29d635277939a1718d856f7 100644 (file)
@@ -83,8 +83,9 @@ endmodule
 
 // -------------------------------------------------------------------
 
-module task_func_test04(input [7:0] in, output [7:0] out1, out2, out3);
+module task_func_test04(input [7:0] in, output [7:0] out1, out2, out3, out4);
        parameter p = 23;
+       parameter px = 42;
        function [7:0] test1;
                input [7:0] i;
                parameter p = 42;
@@ -105,7 +106,17 @@ module task_func_test04(input [7:0] in, output [7:0] out1, out2, out3);
                        test3 = i + p;
                end
        endfunction
+       function [7:0] test4;
+               input [7:0] i;
+               parameter px = p + 13;
+               parameter p3 = px - 37;
+               parameter p4 = p3 ^ px;
+               begin
+                       test4 = i + p4;
+               end
+       endfunction
        assign out1 = test1(in);
        assign out2 = test2(in);
        assign out3 = test3(in);
+       assign out4 = test4(in);
 endmodule