首页 > 编程知识 正文

uvm验证面试题,IC验证面试

时间:2023-05-04 08:55:45 阅读:222144 作者:4551

文章目录 1.UVM中,工厂覆盖机制的3个条件?2. UVM中Monitor存在的必要性?3.为什么要配置is_active呢?4.是不是只能在build_phase中进行例化的动作?5.field automation 的作用?

以下为个人答案,水平有限。如有解释不对的地方,欢迎大家评论区留言一起学习交流。

后面的题目连接:《IC验证笔试题之UVM(二)》

1.UVM中,工厂覆盖机制的3个条件?

也就是在问,怎样才能确保可以正确覆盖(override)。

首先确保原始类和覆盖类都应在工厂中注册原始类应该通过工厂实例化(使用type::type_id::create( )的方式,而不是传统的new()的方式);覆盖方法应该在原始类的对象创建之前被调用覆盖类为原始类的子类,而调用成员方法(原始类中)也应当声明为虚方法,这是为了确保句柄类型转换不会出错。注意,覆盖类为原始类的父类时会报错 2. UVM中Monitor存在的必要性?

由于 transaction 是由 driver 输出到DUT的端口,为什么不直接通过 diver 将事务发送给 scoreboard 或者 reference model,而是非要通过一个 monitor 将数据采集发送呢?

第一,在大型项目中,driver 根据某一协议发送数据,而 monitor 则根据同一协议收集数据。如果 driver 和 monitor 是不同人员实现的,将 driver 和 monitor 分开,可以大大地减少任何一方对协议理解的错误;

第二,UVM 的一个重要思想就是方便代码复用。在 agent 被集成时,有些场景可能不需要 diver 发送数据,只需要例化monitor就可以了。通过配置 agent 中的 is_active 变量( UVM_ACITVE 或 UVM_PASSIVE ),可以控制 agent 是否例化 diver 和 sequencer 。比如在输出端口上不需要任何驱动信号,只需要监测信号,agent中只需要例化 monitor 即可( agent 配置为 PASSIVE 模式)。

3.为什么要配置is_active呢?

比如你在模块级做验证时,拿验APB接口为例,你需要用一个APB VIP,包含master agent和 slave agent。master通过APB的接口进行读写操作,slave是通过APB接口去响应操作,所以需要 master agent和slave agent里面都要有driver,maser_driver来模拟从APB总线上发起读或写的操作(控制paddr、pwrite和pwdata等),slave_driver模拟从APB总线上做响应,返回pradta,pready和pslverr信号。
但是xddny这个APB接口的模块验证环境被集成到一个更大的模块时,有真正的master模块设计连接着APB总线,设计里面自己会去对总线做操作,也有slave模块通过APB总线做响应。那这个时候,我就不需要你APB VIP里面的master agent 里面的 driver 和 sequencer 来模拟master去发送激励了,因为这个时候我有真正的master连在总线上。同样,我也有真正的slave模块来响应。但这个时候,我们仍然想监测APB总线上数据的来来回回,但又不需要发送激励,这时候我们就可以通过对APB VIP的 master agent 和 slave agent 配置UVM_PASSIVE,也就是不例化 driver 和 sequencer ,只例化monitor,实现了模块级环境复用到更高级别的环境中。

4.是不是只能在build_phase中进行例化的动作?

一般创建 agent 的实例是在 env 的 build_phase 中,创建 driver 和 monitor 的实例则是在 agent 的 build_phase 中,那么是不是只能在build_phase中创建实例呢?

不一定,也可以在 new( ) 函数中执行实例化的动作。比如可以在 agent 的 new( ) 函数中实例化 driver 和 monitor 等,但是带来的问题就是,在 env 的 build_phase 中对 agent 的 is_active 赋值不会产生任何的效果。如下:

如果采用以下的方式:均在 build_phase 中创建对象。在 agent 的 build_phase 中,可以直接获取上层env配置的 is_active 值,有选择地例化 driver 和 sequencer。

class env extends uvm_env; agent agt1; function void new(string name,uvm_component parent); super.new(name,parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); agt1 = agent::type_id::create("agt1",this); agt1.is_active=PASSIVE; endfunctionendclassclass agent extends uvm_agent; driver drv; monitor mon; sequencer sqr; function void new(tring name,uvm_component parent); super.new(name,parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); if(is_active==UVM_ACTIVE) begin drv = driver::type_id::create("drv",this); sqr = sequencer::type_id::create("sqr",this); end mon = monitor::type_id::create("mon",this); endfunctionendclass

如果采用以下的方式例化:在 agent 的 new( ) 函数中例化 driver 和 monitor。那么需要在 agent 实例化之前,使用 config_db 传递 is_active 值

class env extends uvm_env; agent agt1; function void new(string name,uvm_component parent); super.new(name,parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); uvm_config_db#(uvm_active_passive_enum)::set(this,"agt1","is_active",UVM_PASSIVE); agt1 = agent::type_id::create("agt1",this); endfunctionendclassclass agent extends uvm_agent; driver drv; monitor mon; sequencer sqr; function void new(tring name,uvm_component parent); super.new(name,parent); uvm_config_db#(uvm_active_passive_enum)::get(this,"","is_active",is_active); if(is_active==UVM_ACTIVE) begin drv = driver::type_id::create("drv",this); sqr = sequencer::type_id::create("sqr",this); end mon = monitor::type_id::create("mon",this); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); endfunctionendclass 5.field automation 的作用?

这个问题当初也被面试官问到过,现在闲下来,整理了一下,可以看:域的自动化

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。