typedef class函數(shù)new變量use_uvm_seeding成員變量和局部變量的區(qū)別set_name get_name get_full_name上述函數(shù)有一些是virtual function還有一些是靜態(tài)函數(shù)上述函數(shù)有一些是與uvm_object_wraper有關(guān)屬于factory的范疇暫時(shí)搞不懂后面再說還有很多函數(shù)packPRintcopyclonerecord之類的先看uvm class reference文檔再結(jié)合代碼理解
typedef class uvm_component; 表示uvm_object
會(huì)使用到uvm_component
類,但是uvm_component
類還沒有定義。 不過,在uvm_object,暫時(shí)沒發(fā)現(xiàn)使用。所以,個(gè)人理解,這一句刪掉也沒關(guān)系。
相關(guān)源代碼:
static protected int m_inst_count; //m是member,成員的意思吧。類實(shí)例化的個(gè)數(shù)。local int m_inst_id; //類實(shí)例化的id。跟類實(shí)例化個(gè)數(shù)有關(guān)系,比如類實(shí)例化3個(gè),則類實(shí)例化的id為1,2,3local string m_leaf_name; //類的實(shí)例化名稱,是uvm樹形層次結(jié)構(gòu)的一個(gè)枝葉。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注意: 如果基類構(gòu)造函數(shù)new()有參數(shù),那么擴(kuò)展類,必須有一個(gè)構(gòu)造函數(shù),并在構(gòu)造函數(shù)的第一行調(diào)用基類的構(gòu)造函數(shù)。
Class basel Function new(input int var); this.var = var;//利用this關(guān)鍵詞,把new函數(shù)的參數(shù),傳遞給類成員變量。 endfunction endclassclass extended extends basel function new(input int var); super.new(var); endfunctionendclass相關(guān)源代碼:
static bit use_uvm_seeding = 1; //靜態(tài)變量,所以systemverilog全部對象,都可以訪問它,可寫可讀。function void uvm_object::reseed (); if(use_uvm_seeding) this.srandom(uvm_create_random_seed(get_type_name(), get_full_name())); //類的方法,如果使用成員函數(shù)和成員變量的話,需要this關(guān)鍵詞定位為當(dāng)前類。理解這個(gè),需要了解成員變量和局部變量的區(qū)別。見下面介紹。//這里的意思,個(gè)人理解,是重新產(chǎn)生一個(gè)uvm_object類的隨機(jī)種子,默認(rèn)隨機(jī)種子是與process進(jìn)程有關(guān)。endfunction參考: 類聲明中的靜態(tài)方法,類的全范圍內(nèi)可以調(diào)用,也可以無創(chuàng)建對象的方式被訪問,不可以訪問非靜態(tài)的成員(屬性和其他方法); 不能聲明為virtual,聲明中不能使用this句柄; this指針,涉及類的屬性、變量參數(shù)、對象本地的變量參數(shù)或方法,應(yīng)用在非靜態(tài)方法中。
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. |
有需要的時(shí)候,再看吧。
新聞熱點(diǎn)
疑難解答