標籤:style blog color 使用 io art
功能類似verilog裡的$display函數,在vmm裡做了強化,可以在模擬過程中看到整個平台的運行資訊,用來調試模擬平台。
函數原型在vmm.sv裡(class vmm_log;),其建構函式為extern function new(string name,string inst,vmm_log under=null),name表示包含vmm_log的類的名稱,inst是包含vmm_log的類的例化名字,vmm的驗證組件(test/generator/driver,etc)都包含vmm_log的隱式例化,在編寫驗證組件時不需要再次例化,對於transaction則不同,因為在驗證期間,transcation往往會被例化很多次,這時的vmm_log往往需要在編寫驗證組件時單獨例化,例化為靜態函數,可以讓transactions一直使用,比如:
class wb_spi_trans extends vmm_data; static vmm_log log = new("wb_spi_trans","WB_SPI_TRANS"); ...
function new();
super.new(this.log);
‘vmm_note(this,log,"Create an object");
endfunction: newendclass : wb_spi_trans
這樣在例化wb_spi_trans時就會輸出資訊“Normal[NOTE] on wb_spi_trans(WB_SPI_TRANS) at 0
Create an object”,參數name的作用在於告訴你是哪個組件輸出的資訊,參數inst的作用在於告訴你這個組件在整個驗證環境中的層次(例化名稱)。VMM通過參數化的宏定義輸出資訊,比如上面的‘vmm_note,展開後:
do if(log.start_msg(vmm_log::NOTE_TYP)) begin ‘void(log.text("Create an object")); log.end_msg(); endwhile(0)
log.start_msg函數輸出”Normal[NOTE] on wb_spi_trans(WB_SPI_TRANS) at 0",log.test輸出"Create an object",log.end_msg結束輸出。vmm_log關鍵的屬性有資訊種類types_e(枚舉類型:FAILURE_TYP/NOTE_TYP/DEBUG_TYP/REPORT_TYP/NOTIFY_TYP...),資訊等級(枚舉類型:FATAL_SEV/ERROR_SEV/WARNING_SEV/NORMAL_SEV/TRACE_SEV/DEBUG_SEV...),函數根據這兩個變數來決定是否將資訊輸出,start_msg根據這兩個變數決定是否輸出資訊,根據name和inst決定是哪個組件在輸出資訊。