如何启动继承的uvm_test类?

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

How do I start inherited uvm_test class?

问题

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

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

virtual class test_base extends uvm_test;
  ahb_agent ahb0;
  ahb_agent ahb1;

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  virtual function void build_phase(uvm_phase phase);
    ahb0 = ahb_agent::type_id::create("ahb0", this);
    ahb1 = ahb_agent::type_id::create("ahb1", this);
  endfunction
endclass

class test1 extends test_base;
  `uvm_component_utils(test1)
  main_ahb_sequence seq;
  ahb_agent agent;
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    seq = main_ahb_sequence::type_id::create("seq", this);
  endfunction

  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    phase.raise_objection(this);

    seq.start(ahb0.sequencer);

    phase.drop_objection(this);
  endtask
  // ...

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

xmsim: *E,TRNULLID: NULL pointer dereference.
          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.

virtual class test_base extends uvm_test;
  ahb_agent ahb0;
  ahb_agent ahb1;

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  virtual function void build_phase(uvm_phase phase);
    ahb0 = ahb_agent::type_id::create("ahb0", this);
    ahb1 = ahb_agent::type_id::create("ahb1", this);
  endfunction
endclass

class test1 extends test_base;
  `uvm_component_utils(test1)
   main_ahb_sequence seq;
   ahb_agent agent;
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    seq = main_ahb_sequence::type_id::create("seq", this);
  endfunction


  task run_phase(uvm_phase phase);
    super.run_phase(phase);
    phase.raise_objection(this);

    seq.start(ahb0.sequencer);

    phase.drop_objection(this);
  endtask

/*
  virtual function void end_of_elaboration_phase(uvm_phase phase);
    uvm_config_db #(uvm_object_wrapper)::set(this, "ahb0.sequencer.run_phase",
      "default_sequence", main_ahb_sequence::get_type());
    uvm_config_db #(uvm_object_wrapper)::set(this, "ahb1.sequencer.run_phase",
      "default_sequence", main_ahb_sequence::get_type());
  endfunction
*/

After execute, I get the NULL pointer Error

xmsim: *E,TRNULLID: NULL pointer dereference.
          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

class test1 extends test_base;
  `uvm_component_utils(test1)
  main_ahb_sequence seq;
  ahb_agent agent;

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    seq = main_ahb_sequence::type_id::create("seq", this);
  endfunction
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:

class test1 extends test_base;
  `uvm_component_utils(test1)
   main_ahb_sequence seq;
   ahb_agent agent;
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    seq = main_ahb_sequence::type_id::create("seq", this);
  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:

确定