2016-12-09 8 views

답변

1

"인터페이스 클래스"와 "구현"을 통해 1800-2012 년에 소개 된 의사 다중 상속 기능이 가장 좋은 해결책입니다. 요구 사항을 충족시키기 위해 Observer의 디자인 패턴을 적용 할 수 있습니다. 다음은

interface class tick; 
    pure virtual task trigger_tick(....); 
end class 

class observer extends uvm_components; 
    ...... 
    tick tick_list[$]; 

    virtual function void register_tick(tick t); 
     tick_list.push_back(t); 
    endfunction 

    virtual task run_phase(uvm_phase phase); 
     forever begin 
      repeat(100) @(posedge top.clock); 
      foreach (tick_list[i]) tick_list[i].trigger_tick(); 
     end 
    endtask 
end class 

class my_component extends uvm_component implements tick; 
...... 
    virtual task trigger_tick(); 
//do something 
    endtask 
end class 

이 그럼 당신은 관찰자의 인스턴스를 creat에와 인스턴스에 모든 구성 요소를 등록 할 수 있습니다 예제 코드입니다.

0

사용자 지정 단계를 구현하지 않아도됩니다. 다음은이를 수행 할 수있는 방법의 예입니다.

task run_phase(uvm_phase phase); 

    forever begin 
    // wait for reset .... 

    fork 
     your_task1(); 
    join_none 

    // do other things ..... 
    end 

endtask : run_phase 

task your_task1(); // this task will keep running forever.. 

    int count=1; 
    forever begin 
    @(posedge vif.clk); 

    if(count%100 == 0) // will be true only when count becomes multiple of 100 
     your_task2(); 

    count++; 
    end 

endtask : your_task1 

task your_task2(); // one which you wanted to call every 100 clk cycles 
    // add your logic 
endtask : your_task2 

희망이 있습니다.

+0

이것은 단일 인스턴스에 유용합니다. 모든 구성 요소에 적용 할 수있는 일반적인 솔루션이 필요합니다. – Romeo

+0

기본 클래스를 만들어 드라이버, 모니터, 시퀀서 구성 요소에서 상속받을 수 있습니다. SystemVerilog 2012 표준을 사용하면 "implements"키워드 (java와 유사)를 사용하여 둘 이상의 클래스에서 클래스를 확장하여 다중 상속을 구현할 수 있습니다. 이 링크를 확인하십시오 http://cfs-vision.com/2016/03/10/multiple-inheritance-in-systemverilog/하지만 이것을 지원하는 시뮬레이터가 필요합니다. – sundar

0

로직을 다음 mannger의 모든 구성 요소에 run_phase에 추가 할 수 있습니다.

task run_phase (uvm_phase phase); 
    fork 
    begin 
     forever 
     begin 
     repeat (100) @(posedge virtual_interface.clk); 
     your_task(); 
     end 
    end 
    // Other threads 
    join_none 
    wait_fork; 
endtask 
0

당신이 작업을 실행해야하는 이유 당신은

당신이 설명 할 수 작업을 100 사이클에서 이벤트를 생성하는 각 구성 요소에서 같은 uvm_events에게 을 사용하고, 자신의 클래스 캐치 이벤트로부터 호출 할 수 있습니다 각 구성 요소? 나는 당신이 뭔가를 디버깅하는 것 같아요, 트랜잭션 기록이나 uvm_printer가 더 도움이 될 것 같네요.