mode1 is my string array. Is there anyother way I can define my string array? I want to declare the mode1 string array in a such a way so that I can pass it to my other function
You’re still mixing up the syntax - in SystemVerilog you don’t need the { } braces around the function call body, that’s what the compiler is complaining about.
The ’ in front of the RHS side of the array assignment is important, it says that what comes inside the braces is the content of the array.
If you want to pass an array to another function call you have to code the target function call like this:
function void print_array(string ip_info[3]);
foreach(ip_info[i]) begin
$display(ip_info[i]);
end
endfunction
Because your member ‘mode1’ is defined in a static function, not in class A. You still mixed the syntax between C and SV. If you want to use a string in class , you wont define it in a main function. That is wrong.
This code maybe fit for you:
class A;
string mode1[3]=xxxxx;
string mode2[2]=xxxxx;
endclass : A
class B;
…
endclass : B
class C;
A test_mode;
B printing;
test_mode = new();
printing = new();
printing.print_it(test_mode.mode1);
endclass:C
@gaurson
thanks.The issue is solved. Now there is no syntax error but when i run the testcase I get the following error:
Error-[NOA] Null object access
Please make sure that the object is newed before using it.
The object is being used before it was constructed.
It is complaining about the following line of code below:
test_mode.mode1=xxx
The complete code is:
class A;
function new(string name = “A”);
super.new(name);
endfunction:new
string mode1[3] = '{“chip”, “boundary”, “chain”};
string mode2[2] = '{“chip”, “chain”};
endclass : A
class B;
function new(string name = “B”);
super.new(name);
endfunction:new
function void print_it(string details);
A test_mode;
foreach(details[i]) begin
test_mode.mode1=xxx
$display(details[i]);
end
endfunction: print_it
endclass : B
class C;
function new(string name = “C”);
super.new(name);
endfunction:new
A test_mode;
B printing;
test_mode = new();
printing = new();
printing.print_it(test_mode.mode1);
endclass:C
I think your knowledge of OVM or SV is so pitty. I suggest you that read some book about it and do some research by yourself. So maybe you have a great development.
By the way, this problem is that you dont execute class A’s new() to instantiate a instance of A in class B. You just do so in class C.
Oh, my god. You must have a deep study on OVM or SV.