通过uvm_printer的print_generic进行扩展打印
admin
2024-01-22 04:16:38

uvmfield automation机制实现的其中一项功能就是sprint功能,该函数通过调用do_print函数实现。在某些情况的,uvm的打印功能不是我们所期望的,比如多维数组的field automation机制就不支持,struct之类的结构体打印结果为大数。因此我们需要对uvmsprint功能进行扩展,使其打印的log内容符合我们的预期。

1. do_print函数的定义

virtual function void do_print( uvm_printer printer );super.do_print( printer );//print customed variables or structs...
endfunction: do_print

2. print_generic

uvm源码中对uvm_sequen_item的打印是通过调用如下函数实现的,因此我们可以通过调用该函数实现打印功能扩展。

virtual function void print_generic (string 	name,	  	string 	type_name,	  	int 	size,	  	string 	value,	  	byte 	scope_separator	 = 	"."
)

功能描述:Prints a field having the given name, type_name, size, and value.

3. application example

假如我们在扩展的uvm_transaction中定义了如下的结构体变量:

typedef struct {bit [7:0] x;bit [7:0] y;bit [7:0] z;
} point_spoint_s p;`uvm_field_int(p, UVM_ALL_ON)
...

如果要对uvm_transaction的派生类的实例调用sprint函数进行打印,p打印的结果为整数,而我们期望的结果是打印出p的x,y,z的值。

通过对do_print函数的扩展可以实现上述功能,如下:

virtual function void do_print( uvm_printer printer );super.do_print( printer );//print customed variables or structsprinter.print_generic("p",  	"struct"$size(p),	  	$sformatf("x='h%0h,y='h%0h,z='h%0h",p.x,p.y,p.z));
endfunction: do_print

相关内容

热门资讯

夺冠!中国机器人赢了 转自:央视新闻中国机器人在格斗机器人大赛中夺冠  第二届未来运动会17日至23日在阿联酋阿布扎比举行...
兴证策略张启尧团队:本轮躁动行...   炒股就看金麒麟分析师研报,权威,专业,及时,全面,助您挖掘潜力主题机会!   来源:尧望后势 ...
中国首部院线AIGC动画电影《... 中新网北京12月21日电 (记者 高凯)由中央广播电视总台、北京灌木互娱文化科技有限公司、北京新影联...
中芭新版芭蕾舞剧《海盗》首演 ... 中新网北京12月21日电 (记者 应妮)中央芭蕾舞团新版芭蕾舞剧《海盗》20日晚在北京天桥剧场揭开面...
医生一上午检查11人全确诊癌症... 近日,河南郑州一肿瘤医院内,内镜医生正在进行常规的超声内镜检查。令人震惊的是,一上午检查的11位患者...