How to verify if two bits of a 32 bit register are swapped?

In reply to jaswanth_b:

You could access the register bit by bit using the B2B meaning you write the bit and read it back. Check the access policy in case you would have a RO fields or WO fields or so


// this is for fields
foreach (fields[i]) begin
  if(fields[i].get_access() == "RO" | fields[i].get_access() == "R")
   is_read = 1;
  else 
   is_read = 0;
end

// or if you focus on BITS as fine-grain control
n_bits = register.get_n_bits();
for(int i = 0; i<n_bits; i++) begin
   register.write(1'b1<<i);
   register.read(rdata);
   // compare data with the shifted one
end

regards