push_get_record(name,scope,null);returnnull;endrsrc=get_highest_precedence(q);push_get_record(name,scope,rsrc);returnrsrc;endfunction// Function: lookup_type//// Lookup resources by type. Return a queue of resources that match// the ~type_handle~ and ~scope~. If no resources match then the returned// queue is empty.functionuvm_resource_types::rsrc_q_tlookup_type(stringscope="",uvm_resource_basetype_handle);
//// Sorts a list of resources of resources in a standard SV// queue instead of a uvm_queue.staticfunctionvoidsort_by_precedence_q(refuvm_resource_types::rsrc_sv_q_tq);uvm_resource_types::rsrc_sv_q_tall[int];uvm_resource_baser;intunsignedprec;for(inti=0;i<q.size();++i)beginr=q[i];prec=(r!=null)?r.precedence:0;all[prec].push_back(r);endq.delete();foreach(all[iter])beginq={q,all[iter]};endendfunction// sort_by_precedence_q
end// Sort the resource queuesort_by_precedence_q(svq);// Return the first scope matchforeach(svq[iter])beginrsrc=svq[iter];rsrcs=(rsrc!=null)?rsrc.get_scope():"";if(uvm_is_match(rsrcs,scope))break;elsersrc=null;endpush_get_record(name,scope,rsrc);returnrsrc;endfunction
stringmsg;rsrc_base=rp.get_by_name(scope,name,rsrc_t::get_type(),rpterr);if(rsrc_base==null)returnnull;if(!$cast(rsrc,rsrc_base))beginif(rpterr)begin$sformat(msg,"Resource with name %s in scope %s has incorrect type",name,scope);`uvm_warning("RSRCTYPE",msg)endreturnnull;endreturnrsrc;endfunction:get_by_name// Function: set_default