Convert string question

I use convert2string in my code and the string I got is like below. (the format is [field]=[value])

send=1 addr=1234 data=5678 id=1 …
send=1 addr=2345 data=6789 id=2 …

and now I want to convert it to below format.


send   addr   data   id 
1      1234   5678   1
1      2345   6789   2

Is there any good solution here ?

In reply to zz8318:

It is not really clear what your situation is. If you are using the UVM convert2string, it is virtual and you could override it. Or it might be easier to create another method that formats the string exactly the way you want it. As a last resort, you can use $sscanf to parse the string returned by convert2string and reformat it the way you want it.

In reply to dave_59:

But how can I fetch the field name to collect and list all of them in one line ?

In reply to zz8318:

You never explained your situation, but I’m going to assume you are using the UVM and looking the the method of last resort.

You can use uvm_split_string to create an array of name-value pairs, and then call uvm_split_string again to split the name from the value.

string c2s, pairs[$], pair[$], names[$];
int values[$]
c2s = my_transactio.convert2string();
uvm_split_string(c2s," ",pairs);
names={};values={};
foreach(pairs[p]) begin
   uvm_split_string(pairs[p], "=", pair);
   names.push_back(pair[0]);
   values.push_back(pair[1].atoi());
end

In reply to dave_59:

really appreciate to your help for this. I learned from you a lot in this forum.