0

I try to instantiate array of parameters, e.g.

module top();
    parameter array_size = 10;
    parameter par_array [array_size] = '{array_size{12}};

    initial begin
        $display("%d",par_array[array_size-1]);
    end
endmodule

But when I try to compile this module in questasim, I get this kind of error

-- Compiling module top ** Error: (vlog-13069) parameters_array.sv(3): near "[": syntax error, unexpected '[', expecting ';' or ','.

Search on this subject led me to the following topic and answerer says that systemverilog does allow this kind of construction.
I really don't want use long parameter vector, cause it's lead to new difficulties and this construction is compiling in Vivado (but for the sake of verification I need to use Questa).

3 Answers 3

1

parameter arrays are only supported in system verilog. So, make sure that you compile in the system verilog mode (file extension .sv or whatever qualifiers you need).

Also you'd better do int in your case:

parameter int par_array [array_size] = '{array_size{12}};`
----------^^^
Sign up to request clarification or add additional context in comments.

3 Comments

Yeah, I pretty sure, I'm using systemverilog (file extension is sv), and I've tried to use int.
well, it might not be implemented in questa. Talk to their support.
strange thing — I tried it again and it did work. Sorry for misinformation.
1

An unpacked array parameter requires a data type.

parameter int par_array [array_size] = '{array_size{12}};

Only simple integral parameter can be specified without a data type and just a range.

Do yourself a favor and never rely on implicit data types anywhere.

Comments

0

Try to define an dynamic array type some where:

typedef int int_arr_t[];

Then use the new define type in your module

module #(parameter array_size =12,
                  parameter int_arr_t par_array = '{array_size{12}})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.