Rsp.* not getting assigned in uvm_driver

Hi,
the driver code is :

task run_phase(uvm_phase phase);
      @(negedge s2p_if_0.reset);
     get_and_drive();
   endtask : run_phase

   virtual task get_and_drive();
      forever begin : b1
         @(posedge s2p_if_0.clk);
         seq_item_port.get_next_item(req);
         $cast(rsp, req.clone());
         rsp.set_id_info(req);
         send_to_dut(req);
         get_from_dut(rsp);
         seq_item_port.put_response(rsp);
         seq_item_port.item_done();
      end : b1
   endtask: get_and_drive

   task send_to_dut (s2p_xactn cur_xactn);
      uvm_report_info("DRIVER","Got a new s2p xactn");
      @(posedge s2p_if_0.clk);
      s2p_if_0.ser_data = cur_xactn.ser_data;
      s2p_if_0.valid_in = cur_xactn.valid_in;
      
      uvm_report_info("DRIVER","Sent s2p xactn");
   endtask : send_to_dut

   task get_data_from_dut(output bit [7:0] data);
      @(posedge s2p_if_0.clk);
      data = s2p_if_0.par_data;
       rsp.valid_out =   s2p_if_0.valid_out;
       rsp.par_data = s2p_if_0.par_data;
      if (s2p_if_0.valid_out == 1 ) begin
          $display("VAlid_out is 1");
         `uvm_info(get_type_name(),$sformatf("READ Response from DUT = %x", 
			  s2p_if_0.par_data," "), UVM_MEDIUM)
      end
      else rsp.par_data[7:0] = 0;

   endtask

   task get_from_dut (s2p_xactn rsp);
      var bit [7:0] data;
      get_data_from_dut(data);
      rsp.par_data = data;
      rsp.valid_out = s2p_if_0.valid_out;
      @(posedge s2p_if_0.clk);[b]
      `uvm_info(get_type_name(),$sformatf("READ Response from DUT Data= %x", 
			  data," "), UVM_MEDIUM)      
         `uvm_info(get_type_name(),$sformatf("READ Response from DUT RSP_PORT= %x", 
			  rsp.par_data," "), UVM_MEDIUM)      

   endtask : get_from_dut


The sequence body code is : 

   virtual task body();
      for (int i=0; i<=20; i++) begin
         uvm_report_info("SEQUENCE","Starting sequence new loop");
         `uvm_do(req)
         get_response(rsp);
         `uvm_info(get_type_name(),$sformatf("%s Response from DUT = %x", 
			   get_sequence_path(),rsp.par_data), UVM_MEDIUM);
      end
      global_stop_request();
   endtask : body

I see that in the task get_from_dut(), when i print data and rsp.par_data one clock after the assignment rsp.par_data = data, the value of data is not being assigned to rsp.data.

I see the value of data as expected, but the value of rsp.par_data is either 1 or 0.(i cant understand where is that coming from). This is the only driver in the code.

Manish
Please let me know what is missing.

It’s difficult to tell without more code:

Possible reasons:

  1. The type of rsp.par_data and data is not the same.
  2. As you show the code the handle, rsp, is global to the driver and is passed to the sequence. “Something” else other than the code you show is changing the content of rsp.
  3. There is some subtle timing issue such that rsp is re-cloned from req, so resetting the value of rsp.par_data, although I can’t see it in the supplied code.

Hi Manish,

in your ‘get_and_drive’ task you are calling first ‘seq_item_port.put_response(rsp)’
and then ‘seq_item_port.item_done()’.
Maybe the ‘item_done()’ call is overriding your response item of the ‘put_response(rsp)’ call.

You could give a try to call first ‘item_done()’ and then ‘put_response(rsp)’

virtual task get_and_drive();
      forever begin : b1
         @(posedge s2p_if_0.clk);
         seq_item_port.get_next_item(req);
         $cast(rsp, req.clone());
         rsp.set_id_info(req);
         send_to_dut(req);
         get_from_dut(rsp);
         seq_item_port.item_done();
         seq_item_port.put_response(rsp);
      end : b1
   endtask: get_and_drive

or you simply call only ‘item_done(rsp)’ and providing your response item as argument.

virtual task get_and_drive();
      forever begin : b1
         @(posedge s2p_if_0.clk);
         seq_item_port.get_next_item(req);
         $cast(rsp, req.clone());
         rsp.set_id_info(req);
         send_to_dut(req);
         get_from_dut(rsp);
         seq_item_port.item_done(rsp);
      end : b1
   endtask: get_and_drive

Kind regards,