svlib Users Guide and Programmer Reference
String Processing
SystemVerilog language provides a number of string operations natively. However, experience has shown that the built-in set is not sufficient for many practical string processing tasks, and svlib provides a further set of operations to help meet these requirements.
String operations are, in most cases, available in two different forms, and a programmer is free to choose whichever form is more appropriate to their needs.
- The first form is straightforward functions on string values, often (but not always) returning a string result. These functions are defined in the svlib package and consistently have names that begin with the prefix
str_. - The second form is methods of an object of class Str (note the uppercase S). The Str class is a wrapper for a SystemVerilog string, allowing a string to be passed around by reference and making some sequences of operations more convenient.
The obvious drawback to using Str objects rather than simple functions is that an object must be constructed before any operation is performed. This drawback is often outweighed by the efficiency and convenience of being able to offer a string object, by reference, to many successive operations. As already noted, programmers are free to choose the representation that is most convenient for them.