Strange behaviour in register model - How did I manage to modify an attribute of a uvm_reg_field through a class called get_access()?

Hi!

I’m exploring the functionalities of the uvm_reg and uvm_reg_field classes and I ran into something strange when I was using the get_access() method of uvm_reg_field: With this following code snippet


uvm_reg  rg;
uvm_reg_map  maps[$];
rg.get_maps(maps);
string  access_str = "|";
uvm_reg_field  fields[$];
rg.get_fields(fields);
foreach(fields[j]) begin
  access_str = {access_str, {fields[j].get_access(), "|"}};
end

the fields appear to sometimes have their access property changed. I have so far only seen this happen with “WO” being changed into “WO|”. I should mention that at no point in the code do I use the set_access() method.

If I modify the code in the following way


uvm_reg  rg;
uvm_reg_map  maps[$];
rg.get_maps(maps);
string access_str = "|";
string get_access_ret;  // Added line
uvm_reg_field  fields[$];
rg.get_fields(fields);
foreach(fields[j]) begin
  get_access_ret = fields[j].get_access();  // Added line
  access_str = {access_str, {get_access_ret, "|"}};  // Modified line
end

the problem resolves itself. Does anyone understand what might be happening here?

Thanks in advance for any help!

-------------------------------------Footnote------------------------------------------------
If anyone is curious what I’m trying to do: I’m trying to concatenate the access type strings into one string and get something like this:
|RW|RW|RW|RW|RW| or |RO|RO|RW|RW|RW| etc. My intention was to have it display in the simulation log at UVM_MEDIUM levels of verbosity.

In reply to strykbringer:

Are you sure you were not just misinterpreting the
I
for an |? Otherwise I can’t see what is wrong with the code shown. Try using ‘-’.

In reply to dave_59:

Yes, just to be sure I already tried switching out the ‘|’ for ‘,’ which sure enough resulted in get_access() method returning ‘WO,’.

In reply to strykbringer:

Without seeing enough code to reproduce the problem, I can’t help you further. There is either something wrong with code you have not shown, or a tool issue. Try using get_access outside of the foreach loop.