Uvm_re_match

Hi,
I need to read a CSV file, i.e. each line is a list of values separated by commas, e.g. “11,22,33,44”.
I want to use the uvm_re_match to split each line to an array of values.
my code looks something like this:
string my_string = “aa,44”;
int return_value;

return_value = uvm_re_match(“\w+,\d+”,my_string); //This pattern does not match(return value is 1)
return_value = uvm_re_match(“\D+,\d+”,my_string); //This pattern does not match(return value is 1)
return_value = uvm_re_match(“,\d+”,my_string) ; //This pattern does not match(return value is 1)
return_value = uvm_re_match(“\w+”,my_string) ; //This pattern does not match(return value is 1)
My Questions are:

  1. Why don’t these patterns match?
  2. how can I access the matched sub-patterns(i.e. the sub-strings with “( )” around them? In PERL they are numbered by $1 $2 ,…
  3. in the UVM source code(uvm_regex.svh) there is a ifndef clause : ifndef UVM_REGEX_NO_DPI - how can I know whether it applies to me?
  4. Is there a better way to split a string into a list of sub-strings?
    Thanks,
    Shay

In reply to shaygueta:

uvm_re_match uses the POSIX function regexec() to perform a match, not PERL. See regcomp

Tools that have the UVM pre-compiled do not have UVM_REGEX_NO_DPI set, but you could easily write a simple test with your own `ifdef.

If your file contains only list of values, you can use $fscanf/$sscanf to read one value at a time.

In reply to shaygueta:

Hi,Shay
1.You can modify the code like this:
return_value = uvm_re_match(“/[1]+,[0-9]+$/”,my_string);

4.UVM have a split function to split a string to a queue:uvm_split_string()


  1. a-z ↩︎