UVM常用函数 uvm_top.print_topology()& factory.print()&
1 uvm_top.print_topology;
要打印验证环境的结构,需要在验证环境构建之后打印,可以在final_phase中打印。
virtual function void final_phase(uvm_phase phase);
super,finial_phase(phase);
uvm_top.print_topology();
factory.print();
endfunction
在log中打印的结果如下图所示:
2 factory.print();
这个函数用于打印注册到UVM工厂中的类,使用方式如第一个图所示。
3 get_full_name();
返回当前组件所在的路径,它的返回值是一个字符串。比如在一个sequence中使用上述函数如下:
`uvm_info("GET_FULL",get_full_name, UVM_NONE);
打印出的信息为:
uvm_test_top.env.i_agent.seqr.sequence
可见sequence也参与了路径的构建。
4. typedef class
声明:本部分引用自dong_learning的博客
有时在一个类的变量使用前没有声明,去编译的时候会报错。比如,有两个类需要彼此的句柄,即一个类中需要引用另一个类时,但是那个类还没有声明,就像是先有鸡还是先有蛋的问题。
class ABC;
DEF def;
endclass
class DEF;
ABC abc;
endclass
Compile errer
在这种情况下,对于类DEF需要提前声明一下,使用typedef。
typedef class DEF;//Inform compiler that DEF might be used before actual class definition
class ABC;
DEF def;
endclass
class DEF;
ABC abc;
endclass
5. $feof的原理和用法
feof()是检测流上的文件结束符的函数,如果文件结束,则返回非0值,否则返回0
一般在文件操作,中经常使用feof()判断文件是否结束
//读取文件
while(!feof(plain))
{
//每次读16个字节,并返回成功读取的字节数
if((count = fread(dataBlock,sizeof(unsigned char),16,plain)) == 16)
{
fwrite(outdata,sizeof(unsigned char),16,cipher);
}
}