打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
自由而无用的uvm
userphoto

2015.02.01

关注

 一个同事提出说在UVM的环境里有个事情不太方便。

他写的monitor不希望在DUT还没有出Reset的时候就启动,因为那个时候会有很多X信号,monitor会报出假Error。所以他希望monitor只在resetphase之后开始运行,在main phase结束的时候结束。

UVM没有内建的机制让你可以方便的写一段代码在多个runtimephase里执行。出于看看可不可以的目的,我写了如下的uvm_flex_phaseclass。用的时候只要继承一下uvm_flex_phase_monitor,写上在哪个phase和哪个phase之前连续运行,再把代码放到flex_phasetask里去就行了。

但是需要提醒大家的是,这件用法其实并不推荐。创建User defined phase本来就是个不推荐的事情。所以,看看就好。


 

// uvm_flex_phase.svhtypedef class uvm_flex_phase_component; class uvm_flex_phase #(type AFTER_PHASE = uvm_post_reset_phase,                       type BEFORE_PHASE = uvm_pre_shutdown_phase) extends uvm_task_phase;     virtual task exec_task(uvm_component comp, uvm_phase phase);        uvm_flex_phase_component#(AFTER_PHASE, BEFORE_PHASE) flex_phase_comp;        if ($cast(flex_phase_comp, comp))            flex_phase_comp.flex_phase(phase);    endtask : exec_task     local static uvm_flex_phase #(AFTER_PHASE, BEFORE_PHASE) m_inst;    static const string type_name = "uvm_flex_phase";     protected function new(string name = {"flex", "_after_", AFTER_PHASE::get().get_name(), "_before_", BEFORE_PHASE::get().get_name()});        super.new(name);    endfunction : new     static function uvm_flex_phase #(AFTER_PHASE, BEFORE_PHASE) get();        if (m_inst == null)            m_inst = new();        return m_inst;    endfunction : get     virtual function string get_type_name();        return {type_name, "_after_", AFTER_PHASE::get().get_type_name(), "_before_", BEFORE_PHASE::get().get_type_name()};    endfunction : get_type_name; endclass : uvm_flex_phase // uvm_flex_phase_component.svhtypedef class uvm_flex_phase; virtual class uvm_flex_phase_component    #(type AFTER_PHASE = uvm_post_reset_phase,      type BEFORE_PHASE = uvm_pre_shutdown_phase) extends uvm_component;      local uvm_phase uvm_schedule;    local uvm_phase after_phase, before_phase;     function new (string name, uvm_component parent);        super.new(name, parent);         after_phase = AFTER_PHASE::get();        before_phase = BEFORE_PHASE::get();         if (uvm_flex_phase#(AFTER_PHASE, BEFORE_PHASE)::get().is_after(after_phase) ||            uvm_flex_phase#(AFTER_PHASE, BEFORE_PHASE)::get().is_before(before_phase))            return;         uvm_schedule = uvm_domain::get_uvm_schedule();         uvm_schedule.add(uvm_flex_phase#(AFTER_PHASE, BEFORE_PHASE)::get(), .after_phase(after_phase), .before_phase(before_phase));     endfunction : new     const static string type_name = "uvm_flex_phase_component #(AFTER_PHASE, BEFORE_PHASE)";     virtual function string get_type_name();        return type_name;    endfunction : get_type_name     virtual task flex_phase(uvm_phase phase);        return;    endtask: flex_phase endclass : uvm_flex_phase_component // uvm_flex_phase_monitor.svhtypedef class uvm_flex_phase_component; virtual class uvm_flex_phase_monitor    #(type AFTER_PHASE = uvm_post_reset_phase,      type BEFORE_PHASE = uvm_pre_shutdown_phase) extends uvm_flex_phase_component #(AFTER_PHASE, BEFORE_PHASE);     function new (string name, uvm_component parent);        super.new(name, parent);    endfunction : new     const static string type_name = "uvm_flex_phase_monitor #(AFTER_PHASE, BEFORE_PHASE)";     virtual function string get_type_name();        return type_name;    endfunction : get_type_name; endclass : uvm_flex_phase_monitor // Usage -- set the after/before phases parameters when you extends the monitor//          and put your logic codes in the flex_phase task. class your_monitor extends uvm_flex_monitor #(uvm_post_reset_phase, uvm_pre_shutdown_phase); virtual task flex_phase(uvm_phase phase);... Your code ...;endtask....endclass

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
UVM系统验证基础知识1(基于UVM的verilog验证 )
UVM中的put/get response
React Native学习之自定义NavigationBar
一文讲透设计模式(C 版)
Flash导出SWC与Flex中使用SWC - Flex - Flash - JavaEy...
【博文精选】UVM使用双顶层的用法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服