如何启动继承的uvm_test类?

huangapple go评论83阅读模式
英文:

How do I start inherited uvm_test class?

问题

我试图使用.start()方法而不是uvm_config_db()来启动一个UVM测试类。

我已经注释掉了uvm_config_db方法,并改为实现run_phase()如下所示。

  1. virtual class test_base extends uvm_test;
  2. ahb_agent ahb0;
  3. ahb_agent ahb1;
  4. function new(string name, uvm_component parent);
  5. super.new(name, parent);
  6. endfunction
  7. virtual function void build_phase(uvm_phase phase);
  8. ahb0 = ahb_agent::type_id::create("ahb0", this);
  9. ahb1 = ahb_agent::type_id::create("ahb1", this);
  10. endfunction
  11. endclass
  12. class test1 extends test_base;
  13. `uvm_component_utils(test1)
  14. main_ahb_sequence seq;
  15. ahb_agent agent;
  16. function new(string name, uvm_component parent);
  17. super.new(name, parent);
  18. endfunction
  19. function void build_phase(uvm_phase phase);
  20. seq = main_ahb_sequence::type_id::create("seq", this);
  21. endfunction
  22. task run_phase(uvm_phase phase);
  23. super.run_phase(phase);
  24. phase.raise_objection(this);
  25. seq.start(ahb0.sequencer);
  26. phase.drop_objection(this);
  27. endtask
  28. // ...

执行后,我收到了NULL指针错误

  1. xmsim: *E,TRNULLID: NULL pointer dereference.
  2. File: ./test1.svh, line = 42, pos = 17

我认为这是因为test_base类没有被构造好。但是,我不知道如何启动继承的测试类?

我在https://www.edaplayground.com/x/JymT 中实现了这一点。

英文:

I'm trying to start a uvm test class with .start() method instead uvm_config_db().

I commented out the uvm_config_db method and implemented run_phase() instead as below.

  1. virtual class test_base extends uvm_test;
  2. ahb_agent ahb0;
  3. ahb_agent ahb1;
  4. function new(string name, uvm_component parent);
  5. super.new(name, parent);
  6. endfunction
  7. virtual function void build_phase(uvm_phase phase);
  8. ahb0 = ahb_agent::type_id::create("ahb0", this);
  9. ahb1 = ahb_agent::type_id::create("ahb1", this);
  10. endfunction
  11. endclass
  12. class test1 extends test_base;
  13. `uvm_component_utils(test1)
  14. main_ahb_sequence seq;
  15. ahb_agent agent;
  16. function new(string name, uvm_component parent);
  17. super.new(name, parent);
  18. endfunction
  19. function void build_phase(uvm_phase phase);
  20. seq = main_ahb_sequence::type_id::create("seq", this);
  21. endfunction
  22. task run_phase(uvm_phase phase);
  23. super.run_phase(phase);
  24. phase.raise_objection(this);
  25. seq.start(ahb0.sequencer);
  26. phase.drop_objection(this);
  27. endtask
  28. /*
  29. virtual function void end_of_elaboration_phase(uvm_phase phase);
  30. uvm_config_db #(uvm_object_wrapper)::set(this, "ahb0.sequencer.run_phase",
  31. "default_sequence", main_ahb_sequence::get_type());
  32. uvm_config_db #(uvm_object_wrapper)::set(this, "ahb1.sequencer.run_phase",
  33. "default_sequence", main_ahb_sequence::get_type());
  34. endfunction
  35. */

After execute, I get the NULL pointer Error

  1. xmsim: *E,TRNULLID: NULL pointer dereference.
  2. File: ./test1.svh, line = 42, pos = 17

I think this caused by test_base class not being constructed as well. But, I don't know how to start the inherited test class?

I implemented this in https://www.edaplayground.com/x/JymT

答案1

得分: 1

该错误指向顺序控制器的句柄:ahb0.sequencer。这意味着代理尚未被构建。

您需要在扩展的测试类的build_phase函数中调用super.build_phase

  1. class test1 extends test_base;
  2. `uvm_component_utils(test1)
  3. main_ahb_sequence seq;
  4. ahb_agent agent;
  5. function new(string name, uvm_component parent);
  6. super.new(name, parent);
  7. endfunction
  8. function void build_phase(uvm_phase phase);
  9. super.build_phase(phase);
  10. seq = main_ahb_sequence::type_id::create("seq", this);
  11. endfunction
  12. endclass

这将消除NULL指针解引用错误。

英文:

The error points to the handle of the sequencer: ahb0.sequencer. This means the agent has not been constructed.

You need to call super.build_phase in the extended test class build_phase function:

  1. class test1 extends test_base;
  2. `uvm_component_utils(test1)
  3. main_ahb_sequence seq;
  4. ahb_agent agent;
  5. function new(string name, uvm_component parent);
  6. super.new(name, parent);
  7. endfunction
  8. function void build_phase(uvm_phase phase);
  9. super.build_phase(phase);
  10. seq = main_ahb_sequence::type_id::create("seq", this);
  11. endfunction

That will eliminate the NULL pointer dereference error.

huangapple
  • 本文由 发表于 2023年3月15日 18:05:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743192.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定