System verilog 动态更改时钟块时钟极性
我正在创建能够切换时钟极性的UVM VIP。接口中使用时钟块。 例如,监视器应根据UVM配置使用传入时钟的posedge或NEGDEDGE对数据进行采样,这种极性变化可能会在运行中发生 这可以通过以下方式实现:System verilog 动态更改时钟块时钟极性,system-verilog,uvm,System Verilog,Uvm,我正在创建能够切换时钟极性的UVM VIP。接口中使用时钟块。 例如,监视器应根据UVM配置使用传入时钟的posedge或NEGDEDGE对数据进行采样,这种极性变化可能会在运行中发生 这可以通过以下方式实现: // In the interface, two clocking blocks are defined // one for posedge (passive_cb), one for negedge (passive_cbn). task wait_clock_event();
// 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
这似乎可行,但浪费了代码行,而且容易出错
有更好的解决方案吗?< /P> < P>假设监视器对时钟块有独占访问权,您可以考虑在接口中使用<代码> 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();
endtask