简体   繁体   English

为uvm_sequence参数化uvm_events

[英]Parametrized uvm_events for uvm_sequence

In my verification environment, I have some common sequences set up for reusability: 在我的验证环境中,我为可重用性设置了一些通用序列:

    class common_sequence(type T = uvm_sequence) extends uvm_sequence#(uvm_sequence_item);

       `uvm_object_param_utils(common_sequence_t#(T))

       function new(string name="common_sequence");
          super.new(name);
       endfunction

       T sequence;

       virtual task body();
          `uvm_do(sequence);
       endtask
    endclass

I would like to create something similar where I can pass in an event. 我想创建一个类似的东西来传递事件。

    class common_sequence_with_event(type T = uvm_sequence, type E = uvm_event) extends uvm_sequence#(uvm_sequence_item);

       `uvm_object_param_utils(common_sequence_t#(T,E))

       function new(string name="common_sequence");
          super.new(name);
       endfunction

       T sequence;
       E event;

       virtual task body();
          event.wait_trigger();
          `uvm_do(sequence);
       endtask
    endclass

I would set this event from my test as follows: 我将从测试中设置此事件,如下所示:

class my_test extends uvm_test;
   `uvm_component_utils(my_test)
   uvm_event my_event;

   function new(string name = "my_test", uvm_component parent=null);
      super.new(name,parent);
   endfunction

   virtual function void build_phase(uvm_phase phase);
      super.build_phase(phase);

      uvm_event my_event = new ("my_event");
   endfunction

   virtual function void end_of_elaboration_phase(uvm_phase phase);
      super.end_of_elaboration_phase(phase);

      // Schedule sequences with sequencers
      uvm_config_db#(uvm_object_wrapper)::set(this,
                                              "env.my_agent.sequencer.reset_phase",
                                              "default_sequence",
                                              common_sequence#(reset_sequence)::get_type());

      uvm_config_db#(uvm_object_wrapper)::set(this,
                                              "env.my_agent.sequencer.main_phase",
                                              "default_sequence",
                                              common_sequence_with_event#(my_sequence, my_event )::get_type());

   endfunction

endclass

I get the compilation error: class specialization parameter must be constant for the common_sequence_with_event#(my_sequence, my_event) line. 我收到编译错误: class specialization参数对于common_sequence_with_event#(my_sequence,my_event)行必须是恒定的。

I guess this means that parameters passed to classes must be a constant. 我想这意味着传递给类的参数必须是常量。 So, in this case, why does it accept the reset_sequence which is also passed in as a parameter. 因此,在这种情况下,为什么它接受还作为参数传递的reset_sequence。

Also, is there a better way to do what I want to achieve? 另外,有没有更好的方法来实现我想要的目标?

Type parameters must be passed types. 类型参数必须是传递的类型。 my_event is a variable, not a type. my_event是变量,而不是类型。 You did not show the declarations for my_sequence or reset_sequence , but I am assuming they are class types. 您没有显示my_sequencereset_sequence的声明,但我假设它们是类类型。 Do you even need a parameter E ? 您是否还需要参数E Won't it always be uvm_event ? 会永远是uvm_event吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM