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

Hi,

In a 32 bit register if any of the two bits are swapped, Swapped in the sense if we read or write to say 1st bit the value is accessed from 2nd bit and vice versa.

How to verify this scenario?

In reply to jaswanth_b:

Do you mean if you write the value 32’h8000_0000, when you read it back you get 32=h4000_0000?

In reply to dave_59:

No dave, its like you get the same value but when you access 1st bit it will come from 2nd bit and vice versa.

In reply to jaswanth_b:

suppose there is a 32bit reg:
we write the value

'h0000_0001

but reg will get updated as

'h0000_0002

we read the value but it returns

'h0000_0001

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

In reply to jaswanth_b:

In reply to jaswanth_b:
suppose there is a 32bit reg:
we write the value

'h0000_0001

but reg will get updated as

'h0000_0002

we read the value but it returns

'h0000_0001

Any use case to verify this scenario in Register access tests?

In reply to dddvlsique:
I believe you do not want to verify this scenario. Instead you want to find out what is wrong, i.e. debugging this scenario.
There are different approaches.
You have to find out if this is a problem of your testbench (RAL model) or does it happen in the design. The reson might be you have a wrong access mode or bits have been swapped and there will be more.
To give you a good advice depends on mor information as you gave so far.

In reply to jaswanth_b:

To summarize what the others are saying: if you have data bits or address bits “reversed” in a register or memory, and the only operation you perform on these registers is read or write, then it does not matter if anything is swapped. However, is there is some other operation, like a shift register, you would need to perform that operation and see if you still got the correct results.

Thanks for your answers guys.

can a back door write followed by front door read to the register catch this issue?

In reply to svq:

The bug you want to identify does not depend on the read/write. It is a bug which can be only detected with appropriate data.