UVM:创建一个任务,所有组件每 100 个左右的周期被调用一次。

UVM: create a task that gets called every 100 or so cycles for all the component.

对于我的所有组件(监视器、驱动程序、定序器等),我需要创建一个任务,每 100 个左右的周期调用一次。 我认为有一种方法可以使用自定义阶段来执行此操作,但不确定如何操作。任何帮助。

我认为您不需要为此实现自定义阶段。这是您如何执行此操作的示例。

task run_phase(uvm_phase phase);

  forever begin  
    // wait for reset ....

    fork 
       your_task1();
    join_none

    // do other things .....
  end

endtask : run_phase

task your_task1(); // this task will keep running forever..

  int count=1; 
  forever begin
    @(posedge vif.clk);

    if(count%100 == 0)  // will be true only when count becomes multiple of 100
       your_task2();

    count++;
  end

endtask : your_task1

task your_task2(); // one which you wanted to call every 100 clk cycles
   // add your logic
endtask : your_task2

希望对您有所帮助。

您可以按照以下方式在每个组件的 run_phase 中添加该逻辑。

task run_phase (uvm_phase phase);
  fork
    begin
      forever
      begin
        repeat (100) @(posedge virtual_interface.clk);
        your_task();
      end   
    end
    // Other threads
  join_none
  wait_fork;
endtask

你可以使用 uvm_events 就像每个组件在第 100 个周期生成事件,并从您自己的 class 捕获该事件并调用任务

您能否解释一下为什么需要为每个组件 运行 一个任务?我猜你正在调试一些东西,可能是事务记录或者 uvm_printer 在这里会更有帮助

1800-2012 年通过 "interface class" 和 "implements" 引入的伪多重继承功能是最佳解决方案。 为了满足您的要求,您可以应用观察者的设计模式。下面是一个示例代码

interface class tick;
    pure virtual task trigger_tick(....);
end class

class observer extends uvm_components;
    ......
    tick tick_list[$];

    virtual function void register_tick(tick t);
        tick_list.push_back(t);
    endfunction 

    virtual task run_phase(uvm_phase phase);
        forever begin
            repeat(100) @(posedge top.clock);
            foreach (tick_list[i]) tick_list[i].trigger_tick();
        end
    endtask
end class

class my_component extends uvm_component implements tick;
......
    virtual task trigger_tick();
//do something
    endtask
end class

然后就可以创建observer实例,将所有组件注册到实例中