////----------------------------------------------------------------------classuvm_resource_pool;staticlocaluvm_resource_poolrp=get();uvm_resource_types::rsrc_q_trtab[string];uvm_resource_types::rsrc_q_tttab[uvm_resource_base];get_tget_record[$];// history of getslocalfunctionnew();endfunction// Function: get//// Returns the singleton handle to the resource poolstaticfunctionuvm_resource_poolget();if(rp==null)rp=new();returnrp;endfunction// Function: spell_check
// <set_override>, <set_name_override>, or <set_type_override>// functions.//functionvoidset(uvm_resource_basersrc,uvm_resource_types::override_toverride=0);uvm_resource_types::rsrc_q_trq;stringname;uvm_resource_basetype_handle;// If resource handle is ~null~ then there is nothing to do.if(rsrc==null)return;// insert into the name map. Resources with empty names are// anonymous resources and are not entered into the name mapname=rsrc.get_name();if(name!="")beginif(rtab.exists(name))
// The resource provided as an argument will be entered into the pool// and will override both by name and type.functionvoidset_override(uvm_resource_basersrc);set(rsrc,(uvm_resource_types::NAME_OVERRIDE|uvm_resource_types::TYPE_OVERRIDE));endfunction// Function: set_name_override//// The resource provided as an argument will entered into the pool// using normal precedence in the type map and will override the name.functionvoidset_name_override(uvm_resource_basersrc);set(rsrc,uvm_resource_types::NAME_OVERRIDE);endfunction// Function: set_type_override//// The resource provided as an argument will be entered into the pool// using normal precedence in the name map and will override the type.functionvoidset_type_override(uvm_resource_basersrc);set(rsrc,uvm_resource_types::TYPE_OVERRIDE);endfunction// function - push_get_record//// Insert a new record into the get history list.functionvoidpush_get_record(stringname,stringscope,uvm_resource_basersrc);get_timpt;// if auditing is turned off then there is no reason// to save a get recordif(!uvm_resource_options::is_auditing())
// is used to initiate the printing. If the ~audit~ bit is set then// the audit trail is dumped for each resource.functionvoiddump(bitaudit=0);uvm_resource_types::rsrc_q_trq;stringname;`uvm_info("UVM/RESOURCE/DUMP","\n=== resource pool ===",UVM_NONE)foreach(rtab[name])beginrq=rtab[name];print_resources(rq,audit);end`uvm_info("UVM/RESOURCE/DUMP","=== end of resource pool ===",UVM_NONE)endfunction
get_tget_record[$];// history of gets// @uvm-ieee 1800.2-2020 auto C.2.4.2.1functionnew();endfunction// Function -- NODOCS -- get//// Returns the singleton handle to the resource pool// @uvm-ieee 1800.2-2020 auto C.2.4.2.2staticfunctionuvm_resource_poolget();uvm_resource_poolt_rp;uvm_coreservice_tcs=uvm_coreservice_t::get();t_rp=cs.get_resource_pool();returnt_rp;endfunction
////@uvm-compat provided for compatibility with 1.2functionvoidset(uvm_resource_basersrc,uvm_resource_types::override_toverride=0);// If resource handle is ~null~ then there is nothing to do.if(rsrc==null)return;if(override)set_override(rsrc,rsrc.get_scope());elseset_scope(rsrc,rsrc.get_scope());endfunction// @uvm-ieee 1800.2-2020 auto C.2.4.3.1functionvoidset_scope(uvm_resource_basersrc,stringscope);table_q_trq;stringname;uvm_resource_basetype_handle;uvm_resource_baser;intunsignedi;// If resource handle is ~null~ then there is nothing to do.if(rsrc==null)beginuvm_report_warning("NULLRASRC","attempting to set scope of a null resource");return;end// Insert into the name map. Resources with empty names are// anonymous resources and are not entered into the name map
// is added to make the routine backward compatible// @uvm-ieee 1800.2-2020 auto C.2.4.3.2functionvoidset_override(uvm_resource_basersrc,stringscope="<not provided>");strings;if(rsrc==null)beginuvm_report_warning("NULLRASRC","attempting to change the search priority of a null resource");return;endif(scope=="<not provided>")s=rsrc.get_scope();elses=scope;set_scope(rsrc,s);set_priority(rsrc,uvm_resource_types::PRI_HIGH);endfunction// Function -- NODOCS -- set_name_override//// The resource provided as an argument will entered into the pool
// is added to make the routine backward compatible// @uvm-ieee 1800.2-2020 auto C.2.4.3.3functionvoidset_name_override(uvm_resource_basersrc,stringscope="<not provided>");strings;if(rsrc==null)beginuvm_report_warning("NULLRASRC","attempting to change the search priority of a null resource");return;endif(scope=="<not provided>")s=rsrc.get_scope();elses=scope;set_scope(rsrc,s);set_priority_name(rsrc,uvm_resource_types::PRI_HIGH);endfunction// Function -- NODOCS -- set_type_override//// The resource provided as an argument will be entered into the pool
// is added to make the routine backward compatible// @uvm-ieee 1800.2-2020 auto C.2.4.3.4functionvoidset_type_override(uvm_resource_basersrc,stringscope="<not provided>");strings;if(rsrc==null)beginuvm_report_warning("NULLRASRC","attempting to change the search priority of a null resource");return;endif(scope=="<not provided>")s=rsrc.get_scope();elses=scope;set_scope(rsrc,s);set_priority_type(rsrc,uvm_resource_types::PRI_HIGH);endfunction// @uvm-ieee 1800.2-2020 auto C.2.4.3.5virtualfunctionbitget_scope(uvm_resource_basersrc,outputstringscope);table_q_trq;stringname;uvm_resource_baser,type_handle;intunsignedi;// If resource handle is ~null~ then there is nothing to do.if(rsrc==null)return0;// Search the resouce in the name map. Resources with empty names are// anonymous resources and are not entered into the name mapname=rsrc.get_name();if((name!="")&&rtab.exists(name))begin
// @uvm-ieee 1800.2-2020 auto C.2.4.3.6virtualfunctionvoiddelete(uvm_resource_basersrc);stringname;table_q_trq;uvm_resource_basetype_handle;intiter;if(rsrc!=null)beginname=rsrc.get_name();if(name!="")beginif(rtab.exists(name))beginrq=rtab[name];iter=0;while(iter<`M__TABLE_Q(rq).size())beginif(`M__TABLE_GET(rq,iter)==rsrc)begin
// precedence will be the one that is returned.// @uvm-ieee 1800.2-2020 auto C.2.4.4.2staticfunctionuvm_resource_baseget_highest_precedence(refuvm_resource_types::rsrc_q_tq);uvm_resource_basersrc;uvm_resource_baser;intunsignedi;intunsignedprec;intunsignedc_prec;if(q.size()==0)returnnull;// get the first resources in the queuersrc=q.get(0);prec=(rsrc!=null)?rsrc.precedence:0;// start searching from the second resource
//// 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
endrq=ttab[type_handle];set_priority_queue(rsrc,rq,pri);endfunction// Function -- NODOCS -- set_priority_name//// Change the priority of the ~rsrc~ based on the value of ~pri~, the// priority enum argument. This function changes the priority only in// the name map, leaving the type map untouched.// @uvm-ieee 1800.2-2020 auto C.2.4.5.2functionvoidset_priority_name(uvm_resource_basersrc,uvm_resource_types::priority_epri);stringname;stringmsg;
// @uvm-ieee 1800.2-2020 auto C.2.4.5.4staticfunctionvoidset_default_precedence(intunsignedprecedence);uvm_coreservice_tcs=uvm_coreservice_t::get();cs.set_resource_pool_default_precedence(precedence);endfunctionstaticfunctionintunsignedget_default_precedence();uvm_coreservice_tcs=uvm_coreservice_t::get();returncs.get_resource_pool_default_precedence();endfunction// @uvm-ieee 1800.2-2020 auto C.2.4.5.6virtualfunctionvoidset_precedence(uvm_resource_baser,intunsignedp=uvm_resource_pool::get_default_precedence());
// is used to initiate the printing. If the ~audit~ bit is set then// the audit trail is dumped for each resource.functionvoiddump(bitaudit=0,uvm_printerprinter=null);stringname;staticuvm_tree_printerm_printer;if(m_printer==null)beginm_printer=new();m_printer.set_type_name_enabled(1);endif(printer==null)printer=m_printer;printer.flush();printer.push_element("uvm_resource_pool",