Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

Issue #1052

Localparam array can't be passed into parameter-called function

Added by Andrew Bardsley almost 3 years ago. Updated almost 3 years ago.

Status:
Feature
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

pattern_const_index.v - Source (322 Bytes) Andrew Bardsley, 04/06/2016 03:50 PM

verilator_errors.txt View - Errors produced (417 Bytes) Andrew Bardsley, 04/06/2016 03:50 PM

History

#1 Updated by Wilson Snyder almost 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 almost 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

Also available in: Atom