UVM的Messages机制有些时候很繁琐,很多时候希望能够在UVM messages的基础上做一些个人化的订制,这里给出来一个找到的例子作为参考。
my_macros.sv:
`define my_info(MSG, VERBOSITY) \
begin \
if(uvm_report_enabled(VERBOSITY,UVM_INFO,get_full_name())) \
uvm_report_info(get_full_name(), $sformatf MSG, 0, `uvm_file, `uvm_line); \
end
`define my_err(MSG) \
begin \
if(uvm_report_enabled(UVM_NONE,UVM_ERROR,get_full_name())) \
uvm_report_error(get_full_name(), $sformatf MSG, UVM_NONE, `uvm_file, `uvm_line); \
end
`define my_warn(MSG) \
begin \
if(uvm_report_enabled(UVM_NONE,UVM_WARNING,get_full_name())) \
uvm_report_warning(get_full_name(), $sformatf MSG, UVM_NONE, `uvm_file, `uvm_line); \
end
`define my_fatal(MSG) \
begin \
if(uvm_report_enabled(UVM_NONE,UVM_FATAL,get_full_name())) \
uvm_report_fatal(get_full_name(), $sformatf MSG, UVM_NONE, `uvm_file, `uvm_line); \
end
my_init.sv:
initial begin
my_report_server_c report_server = new("my_report_server");
if($value$plusargs("fname_width=%d", fwidth)) begin
report_server.file_name_width = fwidth;
end
if($value$plusargs("hier_width=%d", hwidth)) begin
report_server.hier_width = hwidth;
end
uvm_pkg::uvm_report_server::set_server(report_server);
// all "%t" shall print out in ns format with 8 digit field width
$timeformat(-9,0,"ns",8);
end
my_report_server.sv:
class my_report_server_c extends uvm_report_server;
`uvm_object_utils(my_report_server_c)
string filename_cache[string];
string hier_cache[string];
int unsigned file_name_width = 28;
int unsigned hier_width = 60;
uvm_severity_type sev_type;
string prefix, time_str, code_str, fill_char, file_str, hier_str;
int last_slash, flen, hier_len;
function new(string name="my_report_server");
super.new();
endfunction : new
virtual function string compose_message(uvm_severity severity, string name, string id, string message,
string filename, int line);
// format filename & line-number
last_slash = filename.len() - 1;
if(file_name_width > 0) begin
if(filename_cache.exists(filename))
file_str = filename_cache[filename];
else begin
while(filename[last_slash] != "/" && last_slash != 0)
last_slash--;
file_str = (filename[last_slash] == "/")?
filename.substr(last_slash+1, filename.len()-1) :
filename;
flen = file_str.len();
file_str = (flen > file_name_width)?
file_str.substr((flen - file_name_width), flen-1) :
{{(file_name_width-flen){" "}}, file_str};
filename_cache[filename] = file_str;
end
$swrite(file_str, "(%s:%6d) ", file_str, line);
end else
file_str = "";
// format hier
hier_len = id.len();
if(hier_width > 0) begin
if(hier_cache.exists(id))
hier_str = hier_cache[id];
else begin
if(hier_len > 13 && id.substr(0,12) == "uvm_test_top.") begin
id = id.substr(13, hier_len-1);
hier_len -= 13;
end
if(hier_len < hier_width)
hier_str = {id, {(hier_width - hier_len){" "}}};
else if(hier_len > hier_width)
hier_str = id.substr(hier_len - hier_width, hier_len - 1);
else
hier_str = id;
hier_str = {"[", hier_str, "]"};
hier_cache[id] = hier_str;
end
end else
hier_str = "";
// format time
$swrite(time_str, " {%t}", $time);
// determine fill character
sev_type = uvm_severity_type'(severity);
case(sev_type)
UVM_INFO: begin code_str = "%I"; fill_char = " "; end
UVM_ERROR: begin code_str = "%E"; fill_char = "_"; end
UVM_WARNING: begin code_str = "%W"; fill_char = "."; end
UVM_FATAL: begin code_str = "%F"; fill_char = "*"; end
default: begin code_str = "%?"; fill_char = "?"; end
endcase
// create line's prefix (everything up to time)
$swrite(prefix, "%s-%s%s%s", code_str, file_str, hier_str, time_str);
if(fill_char != " ") begin
for(int x = 0; x < prefix.len(); x++)
if(prefix[x] == " ")
prefix.putc(x, fill_char);
end
// append message
return {prefix, " ", message};
endfunction : compose_message
endclass : my_report_server_c
- 定制个性化码表技术 ibus
在不同用户的工作环境中,都会根据各自使用的字符集的不同,而需要定制优化各自的输入法码表,例如,在GB18030中的大量汉字,或许因为输入法码表的老旧,而难于利用自己熟悉的“五笔”方法快速录入,同样,需 ...
- 【OpenStack】OpenStack系列14之Dashboard定制开发
django概述 参考资料:http://blog.javachen.com/2014/01/11/how-to-create-a-django-site.html http://djangobook ...
- scss组件定制的一些学习
应组织上的要求,简化前端开发,提高工作效率,开始着手研究scss框架及组件化. 把一些长的像的弄在一起,就有了组件化. 但组件只用一部分需要的,就有了定制. 下面是参考一个button组件写出的一些简 ...
- 浏览器扩展系列————在WPF中定制WebBrowser快捷菜单
原文:浏览器扩展系列----在WPF中定制WebBrowser快捷菜单 关于如何定制菜单可以参考codeproject上的这篇文章:http://www.codeproject.com/KB/book ...
- [技术] 如何正确食用cnblogs的CSS定制
用过cnblogs的估计都知道cnblogs提供了相对比较开放的个性化选项,其中最为突出的估计就是页面CSS定制了.但是没学过Web前端的人可能并不会用这个东西... 所以我打算在此分享一些定制CSS ...
- django学习记录
1.参考资料问题: 现在django发布了1.11版本,离线文档下载引擎地址 文档下载地址 在线文档:https://docs.djangoproject.com/en/1.10/intro/tuto ...
- gson笔记 解析json数据
gson中负责json数据解析的类是JsonReader. Json格式有两种结构,一种是对象(键值对的组合,无序),另外一种是数组(值的有序集合). 因此针对这两种格式,JsonReader提供了不 ...
- PostgreSQL全文检索zhparser使用
本文引用自: http://blog.chinaunix.net/uid-20726500-id-4820580.html 防止文章丢失才进行复制 PostgreSQL支持全文检索,其内置的缺省的分词 ...
- linux PPTP VPN客户端安装
转载于http://www.2cto.com/os/201209/157462.html 下载pptp-1.7.2.tar.gz http://pptpclient.sourceforge.net/ ...
随机推荐
- [luoguP1069] 细胞分裂(数论)
传送门 分解质因数,不说了 这题坑了我2个多小时 教训 不熟悉位运算的优先级一定要加括号!!!! #include <cstdio> #include <iostream> # ...
- VScode输出中文乱码的解决方法------测试过可以用
用python写个爬虫,配置个VScode环境,发现输出都是乱码,翻阅网站后发现一个简单有效的方法,在此谢过网络上的大牛们的无私分享,我也在此记录一下,以备后用: 文件---->首选项----& ...
- 【转】建立一个更高级别的查询 API:正确使用Django ORM 的方式
这个就比较深入啦... http://www.oschina.net/translate/higher-level-query-api-django-orm 结论: 在视图和其他高级应用中使用源生的O ...
- Ubuntu 16.04安装迅雷(兼容性不高)
迅雷官方没有提供LInux的版本,但是提供了一个Xware的版本,这个是用来制作离线下载的,但是网上已经有人通过这个集成了桌面应用:但是没怎么测试过,稳定性不高. http://forum.ubunt ...
- Redhat 6.1安装ArcGIS Server10.1
http://blog.csdn.net/linghe301/article/details/7762985 操作环境:Redhat 6.1 Linux 安装ArcGIS Server10.1之前,还 ...
- 20170623_oracle备份和恢复_常见问题
1 为什么需要备份?备份分类? 1)故障.迁移.误操作 2)备份分类: 物理与逻辑角度:物理备份.逻辑备份 备份策略角度:完全备份.增量备份.差异备份 2 使用导入导出进行备份和恢复及其四种模式:其他 ...
- TGraphicControl和TCustomControl自绘过程的理论解释
TGraphicControl = class(TControl) // 这个类实在是简单,因为所有事情都已经委托给它的父Win控件了,只要管自己即可 private FCanvas: TCanvas ...
- luogu1641 [SDOI2010]生成字符串
题目大意 把$n$个$1$和$m$个$0$组成字符串,在任意的前$k$个字符中,$1$的个数不能少于$0$的个数.求这样的字符串的个数.$1\leq m\leq n\leq 1000000$. 原始模 ...
- ios14--购物车优化2
// // ViewController.m // 03-综合练习 // // Created by xiaomage on 15/12/28. // Copyright © 2015年 小码哥. A ...
- Linux gadget驱动分析3------复合设备驱动
windows上面对usb复合设备的识别需要下面条件. “ 如果设备满足下列要求,则总线驱动程序还会报告 USB\COMPOSITE 的兼容标识符: 设备描述符的设备类字段 (bDeviceClass ...