How to Implement the "W1C" Access type using Callbacks [With Addition Changes]?

Hello Folks,

Have a requirement where in I wanted to implement the “W1C” field access process with write protected process.

a. When the write protection is not set, then the W1C functionality has to happen for the respective field.
b. When the write protection is set, then W1C cannot happen.

Was able to implement the callback process, but was confused how to get the functionality of “W1C” process ? Can anyone give a quick suggestion for this process ??

I see the defined code for W1C in the uvm_reg_filed source code as

"W1C":   return cur_val & (~wr_val);

but then how do I get the value of wr_val to the post_predict process which can be used in post_predict() process ?

Thanks,
Desperado !!

Hello Folks,

Think we have both the previous value and the current value which needs to be written. So I tried it as

value = previous & (~value);

.

Correct me if my understanding is wrong. Appreciate your help.

Regards,
Desperado

In reply to desperadorocks:

In the ‘post_predict(…)’ callback, ‘value’ contains the value that the register module already predicted, based on the current access and the field’s access policy. ‘previous’ contains the value that the field contained before this prediction happened. If you want to suppress the effect of ‘W1C’ while you’re write-protected, you’ll need to set ‘value’ to ‘previous’:


virtual function void post_predict(...);
  if (kind == UVM_PREDICT_WRITE && write_protected)
    value = previous;
endfunction