The information reporting mechanism in UVM is relatively simple, and the function is mainly divided into two parts:
First, the Information Report redundancy level of component is controlled by ID, and different behavior control is performed for each redundancy level. This part of work is mainly implemented by uvm_report_hander: The main involved methods include get_report_verbosity_level (severity, ID)/get_report_action (severity, ID) = uvm_action '(uvm_no_action) the second is to format the message output. uvm_report_server is used to implement message_compose.
We analyze the execution of a 'vm _ error macro, 'vm _ error ("driver", "The Config object is null ")
This is a UVM macro called in TB. It mainly receives two parameter IDs and the MSG to be printed. This macro is defined in uvm_message_defines.svh and is defined as follows:
140 'define uvm_error (ID, MSG) \ 141 begin \ 142 If (uvm_report_enabled (uvm_none, uvm_error, ID) \ 143 uvm_report_error (ID, MSG, uvm_none, 'uvm _ file, 'uvm _ line); \ 144 end
The uvm_report_enabled function is called to check whether the message allows output. This function has two versions. If the uvm_error macro is called in a component, the component function is used, which is defined in uvm_report_object: 447 function int uvm_report_enabled (INT verbosity, 448 uvm_severity severity = uvm_info, string id = ""); 449 If (if (severity, ID) <verbosity | // check the corresponding severity, whether the verbosity (redundancy level) of the ID is greater than the verbosity450 get_report_action (severity, ID) = uvm_action '(uvm_no_action) that can be output. // check the corresponding severity, whether the ID action is uvm_no_action451 return 0; 452 else 453 return 1; 454 if the endfunction uses this macro in a sequence or a class derived from uvm_object, the global function 115 function bit uvm_report_enabled (INT verbosity, 116 uvm_severity severity = uvm_info, string id = ""); 117 uvm_root top; 118 Top = uvm_root :: get (); 119 return top. uvm_report_enabled (verbosity, severity, ID); 120 endfunction
Get_report_verbosity_level is defined as follows: m_rh is a uvm_report_handler type variable, which will be instantiated when each component is instantiated, that is, each component corresponds to a m_rh, this variable is used to record some report information of this component, such as whether the report redundancy level (verbosity_lever) is set for this component separately ). The get_report_verbosity_level function calls the get_verbosity_level function of uvm_report_handler.
81 class uvm_report_object extends uvm_object; 82 83 uvm_report_handler m_rh ;... 90 function new (string name = ""); 91 super. New (name); 92 m_rh = new (); 93 endfunction... 413 function int get_report_verbosity_level (uvm_severity severity = uvm_info, string id = ""); 414 return m_rh.get_verbosity_level (severity, ID); 415 endfunction... 539 endclas
The following is a brief analysis of the get_verbosity_level function used in uvm_report_handler. We can learn some Array Control Methods: 55 class uvm_report_handler ;... 236 function int get_verbosity_level (uvm_severity severity = uvm_info, string id = ""); 237 238 239 rows array; If (if (severity) Begin // first judge severity_id_verbosities (Union array, whether the index is severity) has a 240 array = severity_id_verbosities [severity] record corresponding to serverity; // The Union array returns a uvm_id_verbosities_array, which is an instance of uvm_pool, 241 if (array. exists (ID) Begin // This uvm_id_v The index of erbosities_array is the corresponding message_id, And the content is the redundant integer 242 return array of the message_id. get (ID); // Where is the severity_id_verbosities written ?? 243 end 244 end 245 246 if (id_verbosities.exists (ID) Begin // id_verbosities is a sort type variable 247 return id_verbosities.get (ID); // The index is the corresponding message_id, the content is the same as the redundant integer of message_id 248 end //. When will this id_verbosities be written ?? 249 250 return m_max_verbosity_level; 251 252 endfunction... 622 endclass: uvm_report_handle
The processing of uvm_action and file handle is similar to get_verbosity_level. We will not analyze them here. Now we analyze the two problems mentioned in the code analysis above:
1. Where is the severity_id_verbosities written? We will analyze the uvm_report_handler Code directly, because as mentioned above, handler is used to implement and manage this part of work:
Function void set_severity_id_verbosity (uvm_severity severity, string ID, int verbosity); If (! Severity_id_verbosities.exists (severity) severity_id_verbosities [severity] = new; severity_id_verbosities [severity]. Add (ID, verbosity); endfunction
2. When will id_verbosities be written? Function void set_id_verbosity (input string ID, input int verbosity); id_verbosities.add (ID, verbosity); endfunction
The code above shows that set_severity_id_verbosity has a higher priority than set_id_verbosity. As we mentioned earlier, the output of message formatting is mainly implemented by uvm_report_server. Therefore, after uvm_report_error is passed, the report function in uvm_report_server will be called, here we need to mention that uvm_report_server is a single instance. Here we reiterate the relationship between several classes in the uvm_report mechanism. The relationship between Report-object and report_handler is one-to-one, of course, multiple report_objects can correspond to one report_handler (set_report_handler ). the handler-to-server relationship is many-to-one.
243 virtual function void report (244 uvm_severity severity, 245 string name, 246 string ID, 247 string message, 248 int verbosity_level, 249 string filename, 250 int line, 251 uvm_report_object client 252 ); 253 string m; 254 uvm_action A; 255 uvm_file F; 256 bit report_ OK; 257 uvm_report_handler RH; 258 259 RH = client. get_report_handler (); // get the instance pointer of uvm_component again to perform uvm_report_enabled check again and get file_handle260 261/Filter Based on verbosity level 262 In uvm_report_handler.
273 F = RH. get_file_handle (severity, ID); 274 275 // The hooks can do additional filtering. if the hook function 276 // return 1 then continue processing the report. if the hook 277 // returns 0 Then skip processing the report. 278 279 if (A & uvm_call_hook) 280 report_ OK = RH. run_hooks (client, severity, ID, 281 message, verbosity_level, filename, line); // call the run_hooks function to confirm whether to print the information again. Define in ort_handler and call the report_info_hook/hooks/report_error_hook/report_fatal_hook function defined in uvm_report_object. You can reload these hooks when inheriting uvm_component. In this way, message control is implemented.
282 else 283 report_ OK = 1;
285 If (report_ OK) 286 report_ OK = uvm_report_catcher: process_all_report_catchers (// This Is A uvm_callback class. Its main use is to control the information to be printed again before the actual information is printed, every uvm_catcher must implement a catch function! 287 this, client, severity, name, ID, message, 288 verbosity_level, A, filename, line); 289 290 if (report_ OK) Begin 291 M = compose_message (severity, name, ID, message, filename, line); 292 process_report (severity, name, ID, message, A, F, filename,
This is the process_report_catcher function in uvm_catcher:
Local function int process_report_catcher (); action_e Act; Act = This. catch (); If (Act = unknown_action) This. uvm_report_error ("rptcthr", {"uvm_report_this.catch () in Catcher instance", this. get_name (), "Must return throw or caught"}, uvm_none, 'vm _ file, 'uvm _ line); If (m_debug_flags & do_not_modify) Begin m_modified_severity = m_orig_severity; m_modified_id = m_orig_id; m_modified_verbosity = M _ Orig_verbosity; m_modified_action = m_orig_action; m_modified_message = m_orig_message; end if (Act = caught &&! (M_debug_flags & do_not_catch) Begin return 0; end return 1; endfunction
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.