uvm_globals.svh 存放全局的变量和方法。当UVM平台启动时,便在uvm_globals查找相应的方法,uvm_globals 的方法实现也比较简单,就是调用uvm_root对应的方法。其简略源代码如下:
// Title: Globals //------------------------------------------------------------------------------ // // Group: Simulation Control // //------------------------------------------------------------------------------ // Task: run_test // // Convenience function for uvm_top.run_test(). See <uvm_root> for more // information. task run_test (string test_name=""); uvm_root top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); top = cs.get_root(); top.run_test(test_name); endtask `ifndef UVM_NO_DEPRECATED // Variable- uvm_test_done - DEPRECATED // // An instance of the <uvm_test_done_objection> class, this object is // used by components to coordinate when to end the currently running // task-based phase. When all participating components have dropped their // raised objections, an implicit call to <global_stop_request> is issued // to end the run phase (or any other task-based phase). const uvm_test_done_objection uvm_test_done = uvm_test_done_objection::get(); // Method- global_stop_request - DEPRECATED // // Convenience function for uvm_test_done.stop_request(). See // <uvm_test_done_objection::stop_request> for more information. function void global_stop_request(); uvm_test_done_objection tdo; tdo = uvm_test_done_objection::get(); tdo.stop_request(); endfunction // Method- set_global_timeout - DEPRECATED // // Convenience function for uvm_top.set_timeout(). See // <uvm_root::set_timeout> for more information. The overridable bit // controls whether subsequent settings will be honored. function void set_global_timeout(time timeout, bit overridable = 1); uvm_root top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); top = cs.get_root(); top.set_timeout(timeout,overridable); endfunction // Function- set_global_stop_timeout - DEPRECATED // // Convenience function for uvm_test_done.stop_timeout = timeout. // See <uvm_uvm_test_done::stop_timeout> for more information. function void set_global_stop_timeout(time timeout); uvm_test_done_objection tdo; tdo = uvm_test_done_objection::get(); tdo.stop_timeout = timeout; endfunction `endif //---------------------------------------------------------------------------- // // Group: Reporting // //---------------------------------------------------------------------------- // Function: uvm_get_report_object // // Returns the nearest uvm_report_object when called. // For the global version, it returns uvm_root. // function uvm_report_object uvm_get_report_object(); uvm_root top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); top = cs.get_root(); return top; endfunction // Function: uvm_report_enabled // // Returns 1 if the configured verbosity in ~uvm_top~ for this // severity/id is greater than or equal to ~verbosity~ else returns 0. // // See also <uvm_report_object::uvm_report_enabled>. // // Static methods of an extension of uvm_report_object, e.g. uvm_component-based // objects, cannot call ~uvm_report_enabled~ because the call will resolve to // the <uvm_report_object::uvm_report_enabled>, which is non-static. // Static methods cannot call non-static methods of the same class. function int uvm_report_enabled (int verbosity, uvm_severity severity=UVM_INFO, string id=""); uvm_root top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); top = cs.get_root(); return top.uvm_report_enabled(verbosity,severity,id); endfunction // Function: uvm_report function void uvm_report( uvm_severity severity, string id, string message, int verbosity = (severity == uvm_severity'(UVM_ERROR)) ? UVM_LOW : (severity == uvm_severity'(UVM_FATAL)) ? UVM_NONE : UVM_MEDIUM, string filename = "", int line = 0, string context_name = "", bit report_enabled_checked = 0); uvm_root top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); top = cs.get_root(); top.uvm_report(severity, id, message, verbosity, filename, line, context_name, report_enabled_checked); endfunction // Undocumented DPI available version of uvm_report export "DPI-C" function m__uvm_report_dpi; function void m__uvm_report_dpi(int severity, string id, string message, int verbosity, string filename, int line); uvm_report(uvm_severity'(severity), id, message, verbosity, filename, line); endfunction : m__uvm_report_dpi // Function: uvm_report_info function void uvm_report_info() ; endfunction // Function: uvm_report_warning function void uvm_report_warning(); endfunction // Function: uvm_report_error function void uvm_report_error(); endfunction // Function: uvm_report_fatal // // These methods, defined in package scope, are convenience functions that // delegate to the corresponding component methods in ~uvm_top~. They can be // used in module-based code to use the same reporting mechanism as class-based // components. See <uvm_report_object> for details on the reporting mechanism. // // *Note:* Verbosity is ignored for warnings, errors, and fatals to ensure users // do not inadvertently filter them out. It remains in the methods for backward // compatibility. function void uvm_report_fatal(); endfunction // Function: uvm_process_report_message // // This method, defined in package scope, is a convenience function that // delegate to the corresponding component method in ~uvm_top~. It can be // used in module-based code to use the same reporting mechanism as class-based // components. See <uvm_report_object> for details on the reporting mechanism. function void uvm_process_report_message(uvm_report_message report_message); endfunction // TODO merge with uvm_enum_wrapper#(uvm_severity) function bit uvm_string_to_severity (string sev_str, output uvm_severity sev); endfunction //---------------------------------------------------------------------------- // // Group: Miscellaneous // //---------------------------------------------------------------------------- // Function: uvm_is_match // // Returns 1 if the two strings match, 0 otherwise. // // The first string, ~expr~, is a string that may contain '*' and '?' // characters. A * matches zero or more characters, and ? matches any single // character. The 2nd argument, ~str~, is the string begin matched against. // It must not contain any wildcards. // //---------------------------------------------------------------------------- function bit uvm_is_match (string expr, string str); string s; s = uvm_glob_to_re(expr); return (uvm_re_match(s, str) == 0); endfunction //---------------------------------------------------------------------------- // // Task: uvm_wait_for_nba_region // // Callers of this task will not return until the NBA region, thus allowing // other processes any number of delta cycles (#0) to settle out before // continuing. See <uvm_sequencer_base::wait_for_sequences> for example usage. // //---------------------------------------------------------------------------- task uvm_wait_for_nba_region; string s; int nba; int next_nba; //If `included directly in a program block, can't use a non-blocking assign, //but it isn't needed since program blocks are in a separate region. `ifndef UVM_NO_WAIT_FOR_NBA next_nba++; nba <= next_nba; @(nba); `else repeat(`UVM_POUND_ZERO_COUNT) #0; `endif endtask
参考文献:
1 uvm_globals. http://blog.sina.com.cn/s/blog_466496f30100yan3.html