0

在我的验证环境中,我设置了一些通用序列以实现可重用性:

    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

我想创建类似的东西,我可以在其中传递一个事件。

    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

我会从我的测试中设置这个事件如下:

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

我收到编译错误: common_sequence_with_event#(my_sequence, my_event) 行的类专业化参数必须是常量

我想这意味着传递给类的参数必须是一个常量。那么,在这种情况下,为什么它接受也作为参数传入的reset_sequence。

另外,有没有更好的方法来做我想要实现的目标?

4

1 回答 1

1

类型参数必须是传递类型。my_event是变量,不是类型。您没有显示my_sequenceor的声明reset_sequence,但我假设它们是类类型。你甚至需要一个参数E吗?不会一直这样uvm_event吧?

于 2014-06-19T23:32:39.150 回答