关于用irun跑uvm
时间:10-02
整理:3721RD
点击:
各位:
我正在学习UVM,看的是《A Practical Guide to Adopting the Universal Verification Methodology(UVM)》。书中第四章的例子4-4与4-2是关于UVM object automation的,我把这两个例子放一起用书中前面提供的命令irun -uvmhome $UVM_HOME automation_example.sv apb_transfer.sv 来试着编译一下,结果出了很多错误,其中一条大概是说uvm_object数据类型并不在当前范围可见。不知道这是为什么呢?是代码没全还是我的命令有问题,还是我使用UVM的方法错了?
附上两段代码。example 4-2:
typedef enum bit {APB_READ,APB_WRITE} apb_direction_enum;
class apb_transfer extends uvm_object;
rand bit [31:0] addr;
rand bit [31:0] data;
rand apb_direction_enum direction;
// Control field - does not translate into signal data
rand int unsigned transmit_delay; //delay between transfers
//UVM automation macros for data items
`uvm_object_utils_begin (apb_transfer)
`uvm_field_int(addr, UVM_DEFAULT)
`uvm_field_int(data, UVM_DEFAULT)
`uvm_field_enum(apb_direction_enum, direction, UVM_DEFAULT)
`uvm_field_int(transmit_delay, UVM_DEFAULT|UVM_NOCOMPARE)
`uvm_object_utils_end
// Constructor - required UVM syntax
function new (string name="apb_transfer");
super.new(name);
endfunction : new
endclass : apb_transfer
example 4-4
`include "uvm_pkg.sv"
module automation_exampble;
//Import the UVM library and liclude the UVM macros
import uvm_pkg::*;
`include "uvm_macros.svh"
//Include the APB transfer class
`include "apb_transfer.sv"
apb_transfer my_xfer,tx1,tx2,tx3;
initial begin
my_xfer = apb_transfer::type_id::create("my_xfer");
if(!my_xfer.randomize())
`uvm_fatal("RENDFAIL","can not randomize my_xfer")
tx1 = my_xfer;//tx1 and my_xfer share the same memory
//Create a new apb_transfer
tx2=apb_transfer::type_id::create("tx2");
tx2.copy(tx1);//Copies fields from tx1 to tx2
$cast(tx3,tx1.clone()); //Creates a new apb_transfer and copy all
//specified fields from tx1 to tx3
if(!tx3.compare(tx2))
`uvm_error("CompareFailed","The comparion failed")
my_xfer.print();//Prints my_xfer in a table format
my_xfer.print(uvm_default_tree_printer);// Prints in "tree" format
end
endmodule:automation_exampble
然后irun.log中的错误提示为
class apb_transfer extends uvm_object;
|
ncvlog: *E,SVNOTY (apb_transfer.sv,2|36): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.
请问,有没有人知道,这个到底是怎么回事的呀?
确认一下你是否加载了UVM的lib
那个,怎么确认?
直接用 -uvm 吧,或者加 +incdir+$UVM_HOME/src
非常感谢!
我用了-uvm
后来也试过了-uvm_home $UVM_HOME,都不行啊。+incdir的还没试过,试试看。
小编,找到解决办法了没?
木有
改变一下include "uvm_pkg.sv"的位置试试
现编译uvm_pkg.sv
vlog -incr +incdir+$(UVM_HOME)/src$(UVM_HOME)/src/uvm_pkg.sv
vlog -incr +incdir+$(UVM_HOME)/srcyour_file.sv
vsim -sv_lib $(UVM_HOME)/lib/uvm_dpiyour_test
Thanks!
这个明显是questa/modelsim啊。
差不多吧,改为ncvlog和ncsim就可以啦。
另外,我想他的意思是说,把uvm源代码所在的文件夹加入到incdir中,然后再编译。
最后问题解决了吗?
解决了,把库所在加入incdir中就可以了
OK,我也在搞这个。谢谢。
每一个文件都要
`include "uvm_macros.svh"
import uvm_pkg::*;
thanks for your reply
thank you for sharing
小编怎么做到的啊?能把命令给我看看吗……纠结一天了,thank you~