Member reference resolution error

Hello,
I’m facing an error in the following driver class. It says:
Error-[MRRE] Member reference resolution error
student_src/ocp_driver.sv, 33
Member operator “.” cannot be used on object of type logic.
Expression: SCmdAccept
Source info: rx.SCmdAccept.randomize

Error-[MRRE] Member reference resolution error
student_src/ocp_driver.sv, 34
Member operator “.” cannot be used on object of type logic.
Expression: SResp
Source info: rx.SResp.randomize
These two lines are highlighted in my ocp driver code below.
Please help me in debugging this error

Thank You

class ocp_driver extends uvm_driver #(ocp_transaction);

`uvm_component_utils(ocp_driver)

virtual ocp_if ocp_vi;

function new(string name = "ocp_driver", uvm_component parent = null );
	super.new(name,parent);
endfunction: new

function void connect_phase(uvm_phase phase);
	if( !uvm_config_db #( virtual ocp_if )::get(null, "", "ocp_vi", ocp_vi) ) begin
		`uvm_error("connect", "ocp_if not found")
	end
	`uvm_info("OCP_DRIVER", "connect_phase running",UVM_LOW) 	
    endfunction: connect_phase

task run_phase(uvm_phase phase);
	int assoc[*];
	forever begin
		ocp_transaction rx;
		rx = ocp_transaction::type_id::create("rx");
		`uvm_info("CPU2REG_DRIVER","run_phase:cpu2reg_transaction started", UVM_LOW)
            	seq_item_port.get_next_item(rx);
		@(posedge ocp_vi.Clk) begin
			if (ocp_vi.MCmd == 3'b001) begin
				assoc[ocp_vi.MAddr] = ocp_vi.MData;
			end else if (ocp_vi.MCmd == 3'b010) begin
				rx.SData = assoc[ocp_vi.MAddr];
			end 
		end 
	
		**rx.SCmdAccept.randomize() with {rx.delay > 0 && rx.delay < 5;};
		rx.SResp.randomize();**
		seq_item_port.item_done();
		`uvm_info("OCP_DRIVER","run_phase:ocp_transaction completed",UVM_LOW)
        	end

endtask: run_phase

endclass: ocp_driver

In reply to Ramakrishna Melgiri:

Because I do not know the ocp_transaction I can only guess.
My guessing is SCmdAccept is of type logic and also SResp.
randomize is defined on a class type. You are trying to randomize only one data memeber of this class.
Another question is what is your intention randomizing in the driver class?

In reply to chr_sue:

I want to generate responses(SCmdAccept, SResp) to the CPU2OCP Bridge after a read/write transactions on the OCP slave.

In reply to Ramakrishna Melgiri:

Response means you are taking values from the pin-level interface, putting this into a data field of the sequ_item and putting this back using a put() or item_done() command.

In reply to Ramakrishna Melgiri:

Hi Ramakrishna,

If you want to randomize only particular class members but not the entire class object then,

Following will be better approach-
[Randomizing declared local variables and assigning them to appropriate fields of rx object]

task run_phase(uvm_phase phase);
bit sCmdAccept,sResp,isRandomized;
int delay;



isRandomized = std::randomize(sCmdAccept,sResp,delay) with {delay > 0 && delay < 5;};
rx.SCmdAccept = sCmdAccept;
rx.SResp = sResp;
rx.delay = delay;
endtask: run_phase