sv宏展开+参数化类+uvm_coreservice_t+m_sequencer的出现

发布时间 2023-09-09 12:04:38作者: 大浪淘沙、

sv的宏展开

https://www.systemverilog.io/verification/macros/

`"

包括双引号,双引号内的参数应替换,并且任何嵌入的宏都应该展开。
image

`\`"

在宏拓展结果中使用双引号。
image

参数化类

如果是要传入一种类型,使用关键字type

class packet #(int size = 1); //定义参数化类
	bit [size-1 : 0] a;
endclass:packet
packet #(.size(16)) p2;

class packet # (type T = int);
    T t;
endclass
packet #(real) p1;

uvm_coreservice_t

https://blog.csdn.net/weixin_40634003/article/details/121981228
这个单例对象是获取uvm核心服务的一个API。最重要的机制(也是必须做统一例化处理的组件)都放置在了uvm_coreservice_t类中。而该类独立于UVM环境之外。用户可以获取核心服务类中的任何一个对象,例如uvm_default_factory对象,继而直接利用factory来实现创建和覆盖,当然,创建和覆盖也可以由其他方式完成。
使用方法:
https://blog.csdn.net/weixin_40357487/article/details/110621315

// 虽然返回的是子类对象,但是调用的却是父类中的静态方法,
// 因此返回的是提供uvm_coreservice_t接口的实例。
 // 返回uvm_default_coreservice_t
uvm_coreservice_t cs = uvm_coreservice_t::get();类的对象;
// 返回uvm_factory的实例对象;
uvm_factory factory = cs.get_factory();
//----------------------------------------------------------------------
// Class: uvm_coreservice_t
//
// The singleton instance of uvm_coreservice_t provides a common point for all central 
// uvm services such as uvm_factory, uvm_report_server, ...
// The service class provides a static <::get> which returns an instance adhering to uvm_coreservice_t
// the rest of the set_<facility> get_<facility> pairs provide access to the internal uvm services
//
// Custom implementations of uvm_coreservice_t can be included in uvm_pkg::*
// and can selected via the define UVM_CORESERVICE_TYPE. They cannot reside in another package.
//----------------------------------------------------------------------

virtual class uvm_coreservice_t;
	// Function: get_factory
	//
	// intended to return the currently enabled uvm factory, 
	pure virtual function uvm_factory get_factory();

	// Function: set_factory
	//
	// intended to set the current uvm factory
	pure virtual function void set_factory(uvm_factory f);

	// Function: get_report_server
	// intended to return the current global report_server
	pure virtual function uvm_report_server get_report_server();

	// Function: set_report_server
	// intended to set the central report server to ~server~
	pure virtual function void set_report_server(uvm_report_server server);

        // Function: get_default_tr_database
        // intended to return the current default record database
        pure virtual function uvm_tr_database get_default_tr_database();

        // Function: set_default_tr_database
        // intended to set the current default record database to ~db~
        //
        pure virtual function void set_default_tr_database(uvm_tr_database db);
   
	// Function: set_component_visitor
	// intended to set the component visitor to ~v~
	// (this visitor is being used for the traversal at end_of_elaboration_phase
	// for instance for name checking)
	pure virtual function void set_component_visitor(uvm_visitor#(uvm_component) v);
	
	// Function: get_component_visitor
	// intended to retrieve the current component visitor 
	// see <set_component_visitor>
	pure virtual function uvm_visitor#(uvm_component) get_component_visitor();

	// Function: get_root
	//
	// returns the uvm_root instance
	pure virtual function uvm_root get_root();

	local static `UVM_CORESERVICE_TYPE inst;
	// Function: get
	//
	// Returns an instance providing the uvm_coreservice_t interface.
	// The actual type of the instance is determined by the define `UVM_CORESERVICE_TYPE.
	//
	//| `define UVM_CORESERVICE_TYPE uvm_blocking_coreservice
	//| class uvm_blocking_coreservice extends uvm_default_coreservice_t;
	//|    virtual function void set_factory(uvm_factory f);
	//|       `uvm_error("FACTORY","you are not allowed to override the factory")
	//|    endfunction
	//| endclass
	//|
	static function uvm_coreservice_t get();
		if(inst==null)
			inst=new;

		return inst;
	endfunction // get

endclass

m_sequencer的出现

m_sequencer是在body中才出现的,因此使用uvm_declare_p_sequencer(m_sequencer),
并不能获得p_sequencer,而是一个语法错误。