Quantcast
Channel: Altera Forums
Viewing all articles
Browse latest Browse all 19390

Parametrically sized localparam assignment

$
0
0
I would like to be able to assign an array of localparams with some kind of static function. For example I don't want to have to do this:

Code:

  localparam SIZE = 3;
  typedef logic [31:0] bar_t;
  localparam bar_t [SIZE-1:0] FOO = {32'd1, 32'd2, 32'd3};

Because, while this works, it isn't fully parametric. I'd like to be able to do something like:

Code:

  localparam SIZE = 3;
  typedef logic [31:0] bar_t;


  function makeFoo (input integer size);
    bar_t [size-1:0] bar;
    integer i;


    for (i = 0; i < size; i++) begin
      bar[i] = i;
    end


    return bar;
  endfunction


  localparam bar_t [SIZE-1:0] FOO = makeFoo(SIZE);

Unfortunately, size inside of makeFoo isn't static (or at least Modelsim says it isn't).

Anyway, I'm wondering if anyone has a way to do this. I use static functions all the time to define simple localparam types, but this is proving more difficult.

Thanks,
Todd

Viewing all articles
Browse latest Browse all 19390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>