uvm_component源代码分析
1.uvm_component继承自uvm_report_object,该类又继承自uvm_object, uvm_report_object和uvm_object更多的只是提供一些接口,而uvm_component中的内容才更具有实质意义。
2.UVM的树形组织结构由uvm_component中的三个属性实现:m_parent,m_children, m_children_by_handle。
每一个component在实例化时会传入parent变量,然后其m_parent就会设置为此component的parent。
每一个component在实例化时会调用其父亲的添加child函数即m_parent.m_add_child将它自己加入到父亲的m_children数组中
3.uvm_root的new函数是protected类型,get函数是static类型,get中调用new,如果之前已经new过那么直接返回该uvm_root指针。
4.top_tb initial中的run_test就是执行的uvm_root的run_test函数,其作用有两个:得到命令行中testcase的名字,然后用factory机制创建该testcase,该testcase被创建时会调用uvm_root::get,那么这是uvm_root的第一次例化,也是最后一次例化。
5.uvm_root的new函数传入parent为null,uvm_component的new中如果判断到传入的parent是null,则直接返回,不会设置m_parent和m_children。
report机制源代码分析
1.`uvm_error宏展开之后主要是两个函数:uvm_report_enabled和uvm_report_error。
2.如果是component调用`uvm_error那么执行的是component自己的uvm_report_enabled函数,该函数在uvm_object中实现;如果是sequence等调用uvm_error,那么执行的是uvm_root中的 uvm_report_enabled函数。
3.uvm_report_error在uvm_report_object中实现,该函数会调用uvm_report_handler的report函数,该report函数又会调用uvm_report_sever的report函数。
4.uvm_report_server这个类也是通过get_server进行单一实例化的。