在UVM中環境中,在我們執行simulation的過程中,會在指令行添加一些simulation args。比如
./simv –l vcs_run.log +UVM_TESTNAME=my_test
在UVM世界中,有一個class專門來處理這些參數。這個類就是uvm_cmdline_processor
類的繼承關系是:
uvm_object->uvm_report_object->uvm_cmdline_processor,這個類與factory相似,均是single模式的類,靜态方法get_inst拿到唯一的對象。比如uvm_cmdline_processor cpl= uvm_cmdline_processor::get_inst();
在這個類中有3個重要的變量(隊列)
1:string
m_argv[$] //存放所有cmdline參數,m_argv[0]=./simv
2:string
m_plus_argv[$]//存放所有cmdline參數中以+為開頭的參數
3:string
m_uvm_argv[$]//存放所有cmdline參數中以+UVM*,+uvm或者-UVM*,-uvm為開頭的參數
比如./simv –l vcs_run.log +UVM_TESTNAME=my_test
m_argv[$]有4個參數
m_plus_argv[$]有1個參數
m_uvm_argv[$]有1個參數
這個類中封裝了相應的方法來擷取上述3個隊列的元素,(由于上述3個隊列的protected屬性)
get_args(output string args[$])
get_plusargs(output string plusargs[$])
get_uvm_args(output string uvm_args[$])
這個類中還有方法
get_tool_name//擷取仿真器的名字
get_tool_version//擷取仿真器的版本
方法:
get_arg_matches(string match,ref string args[$])//擷取m_argv與string
match比對的參數個數
get_arg_value(string match,ref string args)// 擷取m_argv與string
match 最先比對的參數個數
get_arg_values(string match,ref string args)// 擷取m_argv與string
match 所有比對的參數個數
其實uvm_cmdline_procesor隻是一種實作方式,使用者也可以直接使用SV自帶的方法,比如valuepluson等指令行傳參的方式,但是基于複用性以及內建性的角度,還是使用已經封裝好的uvm_cmdline_processor來實作指令行參數的傳遞,這樣也便于指令行傳參的集中管理。
uvm_cmdline_processor的架構圖
