typedef class函數new變量use_uvm_seeding成員變量和局部變量的區別set_name get_name get_full_name上述函數有一些是virtual function還有一些是靜態函數上述函數有一些是與uvm_object_wraper有關屬于factory的范疇暫時搞不懂后面再說還有很多函數packPRintcopyclonerecord之類的先看uvm class reference文檔再結合代碼理解
typedef class uvm_component; 表示uvm_object
會使用到uvm_component
類,但是uvm_component
類還沒有定義。 不過,在uvm_object,暫時沒發現使用。所以,個人理解,這一句刪掉也沒關系。
相關源代碼:
static protected int m_inst_count; //m是member,成員的意思吧。類實例化的個數。local int m_inst_id; //類實例化的id。跟類實例化個數有關系,比如類實例化3個,則類實例化的id為1,2,3local string m_leaf_name; //類的實例化名稱,是uvm樹形層次結構的一個枝葉。function uvm_object::new (string name=""); m_inst_id = m_inst_count++; m_leaf_name = name;endfunctionfunction int uvm_object::get_inst_count(); return m_inst_count;endfunctionfunction int uvm_object::get_inst_id(); return m_inst_id;endfunction注意: 如果基類構造函數new()有參數,那么擴展類,必須有一個構造函數,并在構造函數的第一行調用基類的構造函數。
Class basel Function new(input int var); this.var = var;//利用this關鍵詞,把new函數的參數,傳遞給類成員變量。 endfunction endclassclass extended extends basel function new(input int var); super.new(var); endfunctionendclass相關源代碼:
static bit use_uvm_seeding = 1; //靜態變量,所以systemverilog全部對象,都可以訪問它,可寫可讀。function void uvm_object::reseed (); if(use_uvm_seeding) this.srandom(uvm_create_random_seed(get_type_name(), get_full_name())); //類的方法,如果使用成員函數和成員變量的話,需要this關鍵詞定位為當前類。理解這個,需要了解成員變量和局部變量的區別。見下面介紹。//這里的意思,個人理解,是重新產生一個uvm_object類的隨機種子,默認隨機種子是與process進程有關。endfunction參考: 類聲明中的靜態方法,類的全范圍內可以調用,也可以無創建對象的方式被訪問,不可以訪問非靜態的成員(屬性和其他方法); 不能聲明為virtual,聲明中不能使用this句柄; this指針,涉及類的屬性、變量參數、對象本地的變量參數或方法,應用在非靜態方法中。
function | description |
---|---|
get_type | Returns the type-proxy (wrapper) for this object. |
get_object_type | Returns the type-proxy (wrapper) for this object. |
get_type_name | This function returns the type name of the object, which is typically the type identifier enclosed in quotes. |
有需要的時候,再看吧。
新聞熱點
疑難解答