task `SVT_USB_TEST_SUITE_HOST_XHCI_DRVR_TYPE::write_xhci_reg(string taskname, st
ring regfilename, string regname, uvm_reg_data_t wdata,
input uvm_verbosity verbosity); uvm_status_e status; uvm_reg xhci_reg; xhci_reg = get_reg(this.xhci_reg_model.MMIO_Space, regfilename, regname); `uvm_info({taskname,"::write_xhci_reg"}, $sformatf("Writing %0s (Address: 'h%0 h) = 'h%0h ...", xhci_reg.get_full_name(), xhci_reg.get_address(), wdata), verbo sity); xhci_reg.write(status, wdata, UVM_FRONTDOOR); if (status != UVM_IS_OK) begin `uvm_error({taskname,"::write_xhci_reg"}, $sformatf("Writing %0s ... Failed! ", xhci_reg.get_full_name())); end endtask task `SVT_USB_TEST_SUITE_HOST_XHCI_DRVR_TYPE::write_xhci_reg_field(string taskna me, string regfilename, string regname, string fieldname, uvm_reg_data_t wdata, input uvm_ver bosity verbosity); uvm_status_e status; uvm_reg xhci_reg; uvm_reg_field field; uvm_reg_field field_tmp[$]; uvm_reg_data_t reg_data; string access; xhci_reg = get_reg(this.xhci_reg_model.MMIO_Space, regfilename, regname); field = xhci_reg.get_field_by_name(fieldname); if (field == null) `uvm_fatal({taskname,"::write_xhci_reg_field"}, $sformatf(" No field named %0s found in register %0s", fieldname, xhci_reg.get_full_name())) ; // First read the entire register, to make sure the fields are up to date. xhci_reg.read(status, reg_data, UVM_FRONTDOOR); if (status != UVM_IS_OK) begin `uvm_error({taskname,"::write_xhci_reg_field"}, $sformatf("Reading %0s ... F ailed!", xhci_reg.get_full_name())); end `uvm_info({taskname,"::write_xhci_reg_field"}, $sformatf("Reading %0s returned reg_data = 'h%0h ...", xhci_reg.get_full_name(), reg_data), verbosity); xhci_reg.get_fields(field_tmp); for (int i = 0; i < field_tmp.size(); i++) begin if (field_tmp[i].get_name() == fieldname) begin field_tmp[i].value = wdata; end else begin access = field_tmp[i].get_access();
`uvm_info({taskname,"::write_xhci_reg_field"}, $sformatf("regname = %0s, f
ield = %0s, access = %0s", regname, field_tmp[i].get_name(), access), UVM_LOW); // For fields with special access rights make sure we don't 'accidentally' act on it the wrong way via read-modify-write case (access) "W1C", "W1S", "W1T" : field_tmp[i].value = 'd0; // Write-1-to-Clear/Set/ Toggle should be written to 0 to *not* affect them. "W0C", "W0S", "W0T" : field_tmp[i].value = 'd1; // Write-0-to-Clear/Set/ Toggle should be written to 0 to *not* affect them. endcase end for (int j = 0; j < field_tmp[i].get_n_bits(); j++) begin reg_data[j + field_tmp[i].get_lsb_pos()] = field_tmp[i].value[j]; end `uvm_info({taskname,"::write_xhci_reg_field"}, $sformatf("Setting %0s = 'h%0 h resulted in new reg_data = 'h%0h (accounting for special access fields) ...", field_tmp[i].get_fu ll_name(), wdata, reg_data), verbosity); end // Now write the entire register, including the updated field value. `uvm_info({taskname,"::write_xhci_reg_field"}, $sformatf("Writing %0s (Address : 'h%0h) = 'h%0h ...", xhci_reg.get_full_nam e(), xhci_reg.get_address(), reg_data), verbosity); xhci_reg.write(status, reg_data, UVM_FRONTDOOR); if (status != UVM_IS_OK) begin `uvm_error({taskname,"::write_xhci_reg_field"}, $sformatf("Writing %0s ... F ailed!", xhci_reg.get_full_name())); end endtask