User guide

24-7
SystemVerilog Testbench Constructs
tolower()
Similar to the toupper method, this method returns a string with the
upper case characters converted to lower case.
compare() and icompare()
Compares strings and returns 0 if they match, and a value less than
0 or more than zero, depending on the order of the strings, if they
don’t match. The icompare method doesn’t see a difference between
upper case and lower case.
string string1 = "abc";
string string2 = "abc";
string string3 = "xyz";
string string4 = "ABC";
initial
begin
if (string1.compare(string2) == 0)
$display("string1 matches string2");
if (string1.compare(string3) != 0)
$display("string1 does not match string3");
if (string1.compare(string4) != 0)
if (string1.icompare(string4) == 0)
$display("string1 matches string4 except for case");
else
$display("string1 does not match string4");
end
The $display system tasks display the following:
string1 matches string2
string1 does not match string3
string1 matches string4 except for case