Altera_Forum
Honored Contributor
12 years agoParametrically sized localparam assignment
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:
localparam SIZE = 3;
typedef logic bar_t;
localparam bar_t 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:
localparam SIZE = 3;
typedef logic bar_t;
function makeFoo (input integer size);
bar_t bar;
integer i;
for (i = 0; i < size; i++) begin
bar = i;
end
return bar;
endfunction
localparam bar_t 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