User guide

24-5
SystemVerilog Testbench Constructs
The string Data Type
The string data type is an LCA feature.
VCS has implemented the string SystemVerilog data type. The
following is the syntax for declaring this data type:
string variable_name [=initial_value];
String Manipulation Methods
SystemVerilog has the following methods for manipulating strings:
len()
Returns the number of characters in a string.
string string_name = "xyz";
int int1 = string_name.len;
getc()
Returns the numerically specified character in the string.
bit1=string_name.getc(0);
If variable string_name has a value of “xyz”, then this method returns
the ASCII code for the number 0 character to bit1, the x character.
putc()
Replaces a specified character with another value or character. This
method takes two arguments, the first is the number of the characters
in the string, the second is a value or another string variable. If the
second argument is a string value, the specified character is replaced
with the first character of the string argument.