protectedbitmodified;protectedbitread_only;uvm_resource_types::access_taccess[string];// variable: precedence//// This variable is used to associate a precedence that a resource// has with respect to other resources which match the same scope// and name. Resources are set to the <default_precedence> initially,// and may be set to a higher or lower precedence as desired.intunsignedprecedence;// variable: default_precedence//// The default precedence for an resource that has been created.// When two resources have the same precedence, the first resource// found has precedence.
// function: record_read_accessfunctionvoidrecord_read_access(uvm_objectaccessor=null);stringstr;uvm_resource_types::access_taccess_record;// If an accessor object is supplied then get the accessor record.// Otherwise create a new access record. In either case populate// the access record with information about this access. Check// first to make sure that auditing is turned on.if(!uvm_resource_options::is_auditing())return;// If an accessor is supplied, then use its name// as the database entry for the accessor record.// Otherwise, use "<empty>" as the database entry.
//// Dump the access records for this resource//virtualfunctionvoidprint_accessors();stringstr;uvm_componentcomp;uvm_resource_types::access_taccess_record;stringqs[$];if(access.num()==0)return;foreach(access[i])beginstr=i;access_record=access[str];qs.push_back($sformatf("%s reads: %0d @ %0t writes: %0d @ %0t\n",str,access_record.read_count,access_record.read_time,
// object is supplied then also update the accessor record for this// resource.functionTread(uvm_objectaccessor=null);record_read_access(accessor);returnval;endfunction// Function: write// Modify the object stored in this resource container. If the// resource is read-only then issue an error message and return// without modifying the object in the container. If the resource is// not read-only and an ~accessor~ object has been supplied then also// update the accessor record. Lastly, replace the object value in// the container with the value supplied as the argument, ~t~, and// release any processes blocked on// <uvm_resource_base::wait_modified>. If the value to be written is// the same as the value already present in the resource then the// write is not done. That also means that the accessor record is not// updated and the modified bit is not set.functionvoidwrite(Tt,uvm_objectaccessor=null);if(is_read_only())beginuvm_report_error("resource",$sformatf("resource %s is read only -- cannot modify",get_name()));return;end// Set the modified bit and record the transaction only if the value// has actually changed.if(val==t)return;record_write_access(accessor);// set the value and set the dirty bitval=t;
// in the parameterized uvm_resource class.//// @uvm-accellera The details of this API are specific to the Accellera implementation and are not being considered for contribution to 1800.2classuvm_resource_debugextendsuvm_object;uvm_resource_types::access_taccess[string];`uvm_object_utils(uvm_resource_debug)functionnew(stringname="");super.new(name);endfunction// Function: record_read_access//// Record the read access information for this resource for debug purposes.// This information is used by <print_accessors> function.//// @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
protectedbitread_only;// instance of delegate class for supporting resource debuguvm_resource_debugdbg;protectedstringscope;//@uvm-compat provided for compatibility with 1.2intunsignedprecedence;//@uvm-compat provided for compatibility with 1.2staticintunsigneddefault_precedence=1000;// @uvm-ieee 1800.2-2020 auto C.2.3.2.1functionnew(stringname="",strings="<not provided>");//string argument added for compatibilitysuper.new(name);modified=0;read_only=0;// begin lines provided for compatibility with 1.2if(s=="<not provided>")scope=s;//don't call glob_to_re unless legacy usage
//// @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2functionvoidrecord_read_access(uvm_objectaccessor=null);if(dbg==null)dbg=uvm_resource_debug::type_id::create("dbg");dbg.record_read_access(accessor);endfunction// Function: record_write_access//// Delegates to the <uvm_resource_debug::record_write_access function to // record write access information for this resource for debug purposes,// information used by <print_accessors> function.//// @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2functionvoidrecord_write_access(uvm_objectaccessor=null);if(dbg==null)dbg=uvm_resource_debug::type_id::create("dbg");dbg.record_write_access(accessor);endfunction// Function: print_accessors//// Delegates to the <uvm_resource_debug::print_access function to // print the read/write access history of the resource, using the accessor // argument <accessor> which is passed to the <uvm_resource#(T)::read> // and <uvm_resource#(T)::write> //// @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2virtualfunctionvoidprint_accessors();// if dbg is null, we never called record_xxx_access and so there is nothing to printif(dbg!=null)dbg.print_accessors();endfunctionfunctionvoidinit_access_record(inoutuvm_resource_types::access_taccess_record);if(dbg==null)dbg=uvm_resource_debug::type_id::create("dbg");dbg.init_access_record(access_record);endfunction//@uvm-compat provided for compatibility with 1.2functionvoidset_scope(strings);scope=uvm_glob_to_re(s);endfunctionfunctionvoidm_set_scope(strings);
// Accellera implementation and is not being considered for contribution to 1800.2//@uvm-contrib For potential contribution to 1800.2virtualfunctionTdo_read(uvm_objectaccessor);if(uvm_resource_options::is_auditing())beginrecord_read_access(accessor);endreturnval;endfunction:do_read// Function: write////| function void write(T t, uvm_object accessor = null);//// This function is the implementation of the uvm_resource#(T)::write // method detailed in IEEE1800.2-2020 section C.2.5.4.2//// The Accellera implementation passes ~t~ and ~accessor~ to <do_write>.
// Accellera implementation and is not being considered for contribution to 1800.2//@uvm-contrib For potential contribution to 1800.2virtualfunctionvoiddo_write(Tt,uvm_objectaccessor);if(is_read_only())beginuvm_report_error("resource",$sformatf("resource %s is read only -- cannot modify",get_name()));return;end// Set the modified bit and record the transaction only if the value// has actually changed.if(val==t)return;if(uvm_resource_options::is_auditing())beginrecord_write_access(accessor);end// set the value and set the dirty bit