Sometimes we need to search for a specific string in our test. To do that, we can use regex—everyone loves regex, right?So, how do we do it in UVM?We use a special DPI function (note: this won’t work if UVM_NO_DPI or UVM_REGEX_NO_DPI is defined) called uvm_re_match.The uvm_re_match function takes two arguments:
If there’s a match, uvm_re_match returns 0. If there’s no match, it returns 1.We can also use another DPI function, uvm_glob_to_re, which converts a glob-style expression into a regex.Wondering how to use uvm_glob_to_re? Here’s an example:
As you can see, I used the escape character \ —this allows us to search within square brackets [ ].And that’s it! Now you know how to use regex in UVM.To wrap things up, here’s a small example on EDA Playground so you can test it and have some fun:https://www.edaplayground.com/x/QB3P