Issue #1052
Localparam array can't be passed into parameter-called function
Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
Unsupported
% Done:
0%
Description
A localparam of unpacked array type isn't considered const in this example and also fails to be handled in the SimulateVisitor:
module top; function integer get_element; input integer index; input integer array_arg[7:0]; get_element = array_arg[index]; endfunction localparam integer array[7:0] = '{12, 12, 12, 12, 12, 12, 12, 12}; // line 8 localparam element = get_element(0, array); // line 9 endmodule
Produces:
%Error: a.v:9: Expecting expression to be constant, but variable isn't const: array %Error: a.v:9: Expecting expression to be constant, but can't determine constant for FUNCREF 'get_element' %Error: a.v:8: ... Location of non-constant INITARRAY: Unknown node type, perhaps missing visitor in SimulateVisitor
With Verilator (verilator --version) on Ubuntu 14.04:
Verilator 3.882 2016-03-01 rev verilator_3_882-1-gacff683
History
#1 Updated by Wilson Snyder over 3 years ago
- Subject changed from Assignment patterned localparam array can't be const indexed by function to Localparam array can't be passed into parameter-called function
- Status changed from New to Feature
Note this works ok already
localparam element = array[index];
Looked at the function example (thanks), the code that computes functions etc doesn't have the concept of passing any data type other than numbers, so passing an array isn't a simple fix that I can work on immediately. If you'd like to do the work yourself I can suggest how to go about it.
#2 Updated by Andrew Bardsley over 3 years ago
Right. Thought this one might need more work than was trivially possible. I'll pass on doing the change myself (for the moment).
Thanks
#3 Updated by Wilson Snyder 6 months ago
- Status changed from Feature to Duplicate
bug1315 is the same issue, so tracking there.
Also available in: Atom