我正在创建UVM VIP,它能够切换其时钟极性。在接口中使用时钟块。例如,监视器应该根据UVM配置使用传入时钟的posedge或negedge对数据进行采样-而这种极性变化可能会在运行中发生。
这可以按如下方式实现:
// In the interface, two clocking blocks are defined
// one for posedge (passive_cb), one for negedge (passive_cbn).
task wait_clock_event();
if (cfg.pol == 0) @vif.passive_cb;
else @vif.passive_cbn;
endtask
task sample_data();
if (cfg.pol == 0) pkt.data = vif.passive_cb.data;
else pkt.data = vif.passive_cbn.data;
endtask
task run();
wait_clock_event();
sample_data();
endtask这看起来很有效,但浪费了代码行,而且容易出错。
有没有更好的解决方案?
发布于 2019-07-10 07:32:03
假设监视器独占访问时钟块,您可以考虑使用iff限定符修改接口中的时钟事件。
bit pol;
clocking passive_cb @(posedge clk iff !pol, negedge clk iff pol);
input data;
endclocking如果pol在与目标时钟极性相同的时间步长内更改,则存在潜在的竞争条件。
您的监视器代码将包括一个设置函数,其他任务可以简化为我们只有一个时钟块。
function void set_vifcb_pol();
vif.pol = cfg.pol;
endfunction
task wait_clock_event();
@vif.passive_cb;
endtask
task sample_data();
pkt.data = vif.passive_cb.data;
endtask
task run();
set_vifcb_pol();
wait_clock_event();
sample_data();
endtaskhttps://stackoverflow.com/questions/56949594
复制相似问题