Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't determine constant for FUNCREF when define parameter #952

Closed
veripoolbot opened this issue Aug 5, 2015 · 3 comments
Closed

can't determine constant for FUNCREF when define parameter #952

veripoolbot opened this issue Aug 5, 2015 · 3 comments

Comments

@veripoolbot
Copy link
Contributor

@veripoolbot veripoolbot commented Aug 5, 2015


Author Name: Jie Xu (@jiexu)
Original Redmine Issue: 952 from https://www.veripool.org
Original Date: 2015-08-05
Original Assignee: Jie Xu (@jiexu)


The following code failed to compile in Verilator.

module test#(
     parameter size = 4,
     parameter p = sum({32'h1,32'h2,32'h3,32'h4}, size))

     (input clk,
      input logic sel,
      output [p:0] res);

     logic [p:0] cc = 'h45;

     assign res = sel ? cc : {(p+1){1'b1}};

     function integer sum;
         input [3:0][31:0] values;
         input int size;

         sum = 0;

         begin
             for (int i = 0; i < size; i ++)
                 sum += values[i];
         end
     endfunction

endmodule


Verilator reports errors:

%Error: t/t_param_func.v:11: Expecting expression to be constant, but can't determine constant for FUNCREF 'sum'

%Error: t/t_param_func.v:29: ... Location of non-constant VARREF 'values': Array references/not basic

The issue is similar with #�, #�. But here the issue is caused by the multi-dimensional function input @values@.

Test case attached.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Aug 7, 2015


Original Redmine Comment
Author Name: Jie Xu (@jiexu)
Original Date: 2015-08-07T12:21:48Z


The issue can be fixed by patching the following lines. Verilator is able to handle packed array without problem, I think.

-       if (!nodep->varp()->dtypeSkipRefp()->castBasicDType()) clearOptimizable(nodep,"Array references/not basic");
+       if (!nodep->varp()->dtypeSkipRefp()->castBasicDType()
+            && !nodep->varp()->dtypeSkipRefp()->castPackArrayDType())
+            clearOptimizable(nodep,"Array references/not basic");


The patch with test is attached here.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Aug 12, 2015


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-08-12T23:29:29Z


Great patch, thanks! Fixed in git towards 3.875.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Aug 13, 2015


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-08-13T01:45:09Z


In 3.876.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.