Encoding/Decoding with RAL

I am looking for a solution using RAL to encode and decode data going into the dut without affecting the values in the register model itself. I want the register model to show uncoded register values. I cannot do this at the adapter level because i also need it to work with backdoor access. I’ve tried callbacks but they modify the values of the model itself. This leads to issues with coding being applied multiple times when performing a set()/update() operation. Is there a way to code/decode outgoing RAL traffic without affecting the mirror itself? the callbacks have encode/decode routines which appeared promising but they seem reserved for another purpose (they are only used in uvm_reg_backdoor.svh). Appreciate any pointers.

I would think you can implement this in the uvm_reg_adapter if you also set up a uvm_reg_backdoor object that implements the same encoding/decoding as the uvm_reg_adapter. Is there a reason this would not work?

Thanks, this is indeed the only thing i could think of as well… I am quite unfamiliar with the uvm_reg_backdoor class, never used it. I don’t see much info out there about it. How do i integrate this to a standard ral model.

Confession: I have not used it either. After searching around, it does not appear to be commonly used.

If it works with your flow, it may be easier to override the backdoor_read and backdoor_write methods of uvm_reg, to go along with the uvm_reg_adapter approach on the front end. I hope to learn from your experience if you try it!

I have made a quick attempt at using the uvm_reg_backdoor class. It does seem to work (not much testing yet). The documentation around the class does not make much sense to me, it actually behaves the way one would intuit it does. Here are some code snipets.

class custom_backdoor extends uvm_reg_backdoor;
	`uvm_object_utils( custom_backdoor )

	function new( string name = "custom_backdoor" );
		super.new( name );
	endfunction: new

	uvm_reg r;
    uvm_reg_item copy;

	task  write(uvm_reg_item rw);
		$cast(r, rw.element);
		$cast(copy, rw.clone());
	    // encode copy.value[0]
		r.backdoor_write(copy);
	endtask

	virtual task read(uvm_reg_item rw);
		$cast(r, rw.element);
		r.backdoor_read(rw);
		// decode and update rw.value[0]
	endtask

endclass

this is just added to all the regiters using

custom_backdoor cbkdr;
...
cbkdr = custom_backdoor::type_id::create("cbkdr", this);
reg_model.set_backdoor(cbkdr);

now when i execute a backdoor write or read, i get the custom behavior.

1 Like