//// Simply put this resource into the global resource poolfunctionvoidset();uvm_resource_poolrp=uvm_resource_pool::get();rp.set(this);endfunction// Function: set_override//// Put a resource into the global resource pool as an override. This// means it gets put at the head of the list and is searched before// other existing resources that occupy the same position in the name// map or the type map. The default is to override both the name and// type maps. However, using the ~override~ argument you can specify// that either the name map or type map is overridden.functionvoidset_override(uvm_resource_types::override_toverride=2'b11);uvm_resource_poolrp=uvm_resource_pool::get();rp.set(this,override);endfunction// Function: get_by_name//// looks up a resource by ~name~ in the name map. The first resource// with the specified name, whose type is the current type, and is// visible in the specified ~scope~ is returned, if one exists. The// ~rpterr~ flag indicates whether or not an error should be reported// if the search fails. If ~rpterr~ is set to one then a failure// message is issued, including suggested spelling alternatives, based// on resource names that exist in the database, gathered by the spell// checker.staticfunctionthis_typeget_by_name(stringscope,stringname,bitrpterr=1);uvm_resource_poolrp=uvm_resource_pool::get();uvm_resource_basersrc_base;this_typersrc;stringmsg;rsrc_base=rp.get_by_name(scope,name,my_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);
// returned, if one exists. If there is no resource matching the specifications,// ~null~ is returned.staticfunctionthis_typeget_by_type(stringscope="",uvm_resource_basetype_handle);uvm_resource_poolrp=uvm_resource_pool::get();uvm_resource_basersrc_base;this_typersrc;stringmsg;if(type_handle==null)returnnull;rsrc_base=rp.get_by_type(scope,type_handle);if(rsrc_base==null)returnnull;if(!$cast(rsrc,rsrc_base))begin
//----------------------------------------------------------------------// @uvm-ieee 1800.2-2020 auto C.2.5.1classuvm_resource#(typeT=int)extendsuvm_resource_base;typedefuvm_resource#(T)this_type;// singleton handle that represents the type of this resourcestaticthis_typemy_type=get_type();// Can't be rand since things like rand strings are not legal.protectedTval;// Because of uvm_resource#(T)::get_type, we can't use// the macros. We need to do it all manually.typedefuvm_object_registry#(this_type)type_id;virtualfunctionuvm_object_wrapperget_object_type();returntype_id::get();endfunction:get_object_type
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
// ~scope~.// @uvm-ieee 1800.2-2020 auto C.3.2.3.5staticfunctionrsrc_tget_by_type(stringscope);uvm_resource_db_implementation_t#(T)imp;imp=uvm_resource_db_implementation_t#(T)::get_imp();returnimp.get_by_type(scope);endfunction// function -- NODOCS -- get_by_name//// Imports a resource by ~name~. The first argument is the current // ~scope~ of the resource to be retrieved and the second argument is// the ~name~. The ~rpterr~ flag indicates whether or not to generate// a warning if no matching resource is found.// @uvm-ieee 1800.2-2020 auto C.3.2.3.4staticfunctionrsrc_tget_by_name(stringscope,stringname,