天天看點

如何在UVM的sequence中控制objection前言一、Objections can be raised/dropped in sequence總結

文章目錄

  • 前言
  • 一、Objections can be raised/dropped in sequence
  • 總結

前言

在張強的《UVM實戰》的5.2.3節中提到,控制objection的最佳選擇,是在sequence中去控制。那麼如何去控制比較簡潔、美觀、通用性強呢,本文主要介紹如何在sequence中,有效的控制objection。

一、Objections can be raised/dropped in sequence

如下代碼所示,建立一個sequence的基類,如果用的是UVM-1.2,則在new函數中打開objection的開關;如果用的是UVM-1.1,則分别在pre_start和post_start任務中去raised/dropped。

class base_sequence extends uvm_sequence; // other code not shown
    function new(string name = "base_sequence");
        super.new(name);
        `ifdef UVM_POST_VERSION_1_1
            set_automatic_phase_objection(1); // UVM-1.2 & IEEE UVM Only!
        `endif
    endfunction : new
    
    virtual task pre_start();
        `ifdef UVM_VERSION_1_1
            if (get_parent_sequence() == null && starting_phase != null)
                starting_phase.raise_objection(this); // UVM-1.1 ONLY!
        `endif
    endtask : pre_start
    
    virtual task post_start();
        `ifdef UVM_VERSION_1_1
            if (get_parent_sequence() == null && starting_phase != null)
                starting_phase.drop_objection(this); // UVM-1.1 ONLY!
        `endif
    endtask : post_start
    
    virtual task body();

    endtask : body
    
endclass : base_sequence 
           

其他的sequence隻需要從這個基類中繼承過來,在body的task中寫測試激勵就可以了。

class test_sequence extends base_sequence;
    function new(string name = "test_sequence");
        super.new(name);
    endfunction : new

    virtual task body();
		// TODO: 
    endtask : body

endclass : test_sequence
           

總結

本文主要介紹,在sequence中,有效的控制objection的方法。

繼續閱讀