In reply to dave_59:
Thanks Dave!
For Q1, No I’m not getting confused between the static cast and static variable lifetime.
For Q2, I was going over my goal again and I actually found my solution.
The goal I was trying to achieve there is as below.
// lets say that my_arr is of depth 5
// I can do declare and initialize like below in single line.
static cmd_arr my_arr[5] = '{0:test::initArr(wr), 1:test::initArr(rd), default: test::initArr()};
// But I was looking for something like below (declaring and initializing in different lines within the class and without using any static class methods or inline initialization)
class test;
static cmd_arr my_arr[5];
test::my_arr[0] = test::initArr(wr); // written directly inside class like this
test::my_arr[1] = test::initArr(rd);
test::my_arr[2] = test::initArr(unset);
test::my_arr[3] = test::initArr(rd);
test::my_arr[4] = test::initArr(wr);
endclass
// instead I should have done the array initialization in module block like below
class test;
static cmd_arr my_arr[5];
endlcass
module main;
initial begin
test::my_arr[0] = test::initArr(wr);
test::my_arr[1] = test::initArr(rd);
test::my_arr[2] = test::initArr(unset);
test::my_arr[3] = test::initArr(rd);
test::my_arr[4] = test::initArr(wr);
end
endmodule
//