UVM面试题(61 65)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

UVM⾯试题(61-65)

61、什么是UVM Call back?

uvm_callback 类是⽤于实现回调(callbacks)的基类,这些回调⽤于在不更改组件类代码的情况下修改组件的⾏为。

⼀种常见⽤法是在driver将激励发送到DUT之前将错误注⼊到⽣成的数据包中。以下伪代码显⽰了如何实现Call back。

classPacket_c;

byte[4] src_addr, dst_addr;byte[] data;byte[4] crc;endclass//Userdefined callback class extended from base classclass
PktDriver_Cb extends uvm_callback;function new (string name = “PktDriver_Cb”);super.new(name);endfunctionvirtual task
corrupt_packet (Packet_c pkt);//Implement how to corrupt packet//example – flip one bit of byte 0 in CRCpkt.crc[0][0] =
~pkt.crc[0][0]endtaskendclass : PktDriver_Cb//Main Driver Classclass PktDriver extends
uvm_component; uvm_component_utils(PktDriver)//Register callback class with driver uvm_register_cb(PktDriver,PktDriver_Cb)function
new (string name, uvm_component parent=null);super.new(name,parent);endfunctionvirtual task run();forever
beginseq_item_port.get_next_item(pkt);`uvm_do_callbacks(PktDriver,PktDriver_Cb, corrupt_packet(pkt))//other code to
derive to DUT etcend

endtask

endclass

1) 定义数据包packet类

2) 定义从sequence中接收此数据包并将其发送到DUT的driver类

3) 定义⼀个从uvm_callback基类派⽣的driver callback类,并添加⼀个虚拟⽅法,该⽅法可⽤于注⼊错误或翻转数据包中的某个位。

4) 使⽤`uvm_register_cb()宏注册callback类

5) 在driver类的run()⽅法中接收数据包并将其发送到DUT

62、什么是uvm_root 类?

uvm_root类充当所有UVM组件的 隐式顶层 和 phase控制器 。⽤户不直接实例化uvm_root。UVM⾃动创建⼀个uvm_root实例,⽤户可


以通过全局实例变量uvm_top访问。

63、uvm_test的⽗类是什么?

uvm_test类是⽤户可以实现的顶层类,并且没有提到显式⽗类。但是,UVM有⼀个称为uvm_top的特殊组件,它被指定为test类的⽗类。

64、为异步Fifo编写Uvm Sequence Item

class seqItem extends uvm_sequence_item;

`uvm_object_utils(seqItem)logic [8-1:0] rdata;logic wfull;logic rempty;rand logic [8-1:0] wdata;logic winc, wrst_n;logic rinc,
rrst_n;function new (string name=”seqItem”);super.new(name);endfunctionendclass
65、UVM是否独⽴于SystemVerilog?

UVM建⽴在SystemVerilog基础上,不⽀持SystemVerilog的⼯具也不会⽀持UVM。

You might also like