noobuntu
noobuntu

Reputation: 913

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.

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.

Also, is there a better way to do what I want to achieve?

Upvotes: 0

Views: 1298

Answers (1)

dave_59
dave_59

Reputation: 42698

Type parameters must be passed types. my_event is a variable, not a type. You did not show the declarations for my_sequence or reset_sequence, but I am assuming they are class types. Do you even need a parameter E? Won't it always be uvm_event?

Upvotes: 1

Related Questions