OPPRU 2025. 2. 23. 09:57

 

※ pipe_basic_test.sv
// Test class
class pipe_basic_test_c extends uvm_test;
  `uvm_component_utils(pipe_basic_test_c)
  
  tb_c  tb;
  
  function new (string name, uvm_component parent);
super.new(name, parent);
  endfunction  
  
  function void build_phase(uvm_phase phase);
super.build_phase(phase);
      
    tb = tb_c::type_id::create("tb", this);

    uvm_config_db#(uvm_object_wrapper)::set(this, "tb.vseqr.run_phase", "default_sequence", pipe_basic_vseq_c::type_id::get());
  endfunction
  
  virtual function void start_of_simulation_phase(uvm_phase phase);
    super.start_of_simulation_phase(phase);
    
    uvm_top.print_topology();
  endfunction
  
  virtual task run_phase(uvm_phase phase);
    super.run_phase(phase);
    `uvm_info(get_type_name(), $sformatf("run_phase() starts.."), UVM_LOW)
    
    //phase.raise_objection(this);
    //pipe_basic_vseq = pipe_basic_vseq_c::type_id::create("pipe_basic_vseq");
    //pipe_basic_vseq.start(tb.vseqr);
      //ERROR: pipe_basic_vseq.start(tb.vseqr.pipe_seqr);
    //phase.drop_objection(this);
    
    `uvm_info(get_type_name(), $sformatf("run_phase() ends.."), UVM_LOW)
  endtask
     
endclass

 

 top module 에서 run_test("..") 로 호출한 test class 이다. pipe_basic_test_c 는 uvm_test 로 부터 상속을 받는데 uvm_test class 가 hierarchy 와 관련된 component class 로 구조 상 가장 top 쪽에 위치한다.

 가장 먼저 tb class 를 tb 이라는 이름의 object 로 선언 및 생성한다. tb class 는 뒤에서 설명하겠지만 uvm_env 로 부터 상속 받는 component class 이다.

 그 다음 중요한 내용은 build_phase() 에서 기술한 uvm_config_db 이다. 해당 UVM 문법은 test class 에서 호출하여 simulation run 을 시킬 sequence class 를 set 을 하기 위함이다. 전체 코드를 보면 tb class 내 vseqr(virtual sequencer) 를 사전에 선언 해놨었고 tb.vseqr 의 run_phase() 에서 API 에서 제공하는 default_sequence 에 run 을 돌릴 sequence class 이름을 선언해주면 된다. 여기서 pipe_basic_vseq_c 기술한 내용은 뒤에서 설명한다.

 start_of_simulation_phase() 에서 기술한 print_topology()는 로그에서 testbench hierarchy 를 보여주는 UVM 에서 제공하는 API 이다.

 마지막으로 run_phase() 이다. 아래 주석처리 된 phase.raise_objection(this) 에서 phase.drop_objection(this) 는 원래 한 쌍으로 쓰이며 uvm_config_db 문법과 동일하게 simulation run 을 돌릴 sequence class 를 기술하기 위한 목적이다. build_phase()에서 uvm_config_db 의 defualt sequence 로 선언하는 방법과 run_phase 에서 start 하는 방법은 목적이 동일하되 기호에 맞게 선택하여 하나만 사용하면 된다. sequence 와 sequencer 를 기술하고 simulation 을 돌리는 코드에서 보듯이 "SEQ.start(SEQR)" 와 같이 쓰는 문법을 알아두면 좀 더 보기 용이하다.