在我的验证环境中,我为可重用性设置了一些常见的序列:
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
我收到编译错误: class specialization参数必须是常量,用于common_sequence_with_event#(my_sequence,my_event)行。
我想这意味着传递给类的参数必须是常量。因此,在这种情况下,为什么它接受reset_sequence,它也作为参数传入。
另外,有没有更好的方法来实现我想要实现的目标?
答案 0 :(得分:1)
类型参数必须是传递类型。 my_event
是变量,而不是类型。您没有显示my_sequence
或reset_sequence
的声明,但我假设它们是类类型。你甚至需要一个参数E
吗?它不会永远是uvm_event
吗?