| ||
OVM到UVM的代码自动转换
在完成上面的检视和修改之后,我们可以运行UVM安装包自带的脚本ovm-to-uvm10.pl,这一脚本会将.sv/.svh后缀扩展名文件代码中的OVM关键词转换为UVM关键词。通过这个脚本我们可以完成下面的自动化替换:
在.sv/.svh后缀名文件中的ovm字符会被替换为uvm字符。
文件名本生含有ovm的文件会被替换为uvm。
一个替换记录报告文件会生成,其中记录所有的替换历史即转换前后的不同。
用户可以通过--backup选项来决定是否需要备份替换前的文件,或者通过--write来决定是否需要直接在原文件上修改。
--all_text_files选项会将目录中其它的文件例如脚本文件中的ovm关键词也替换为uvm。
替换OVM phase方法
在完成了上面的基本替换之后,我们还需要考虑哪些OVM中的特性无法只通过替换关键词来实现转换步骤的。接下来在第三个步骤中需要替换OVM phase方法。下面是OVM和UVM中的一段例码:
OVM中phase的代码
class my component extends ovm_component `ovm_component_utils(my_component)
...
extern function void build();
extern function void connect();
extern task run;
endclass
function void my_component::build();
super.build();
...
endfunction
...
UVM中phase代码
class my component extends uvm_component
`uvm_component_utils(my_component)
...
extern function void build_phase(uvm_phase phase);
extern function void connect_phase(uvm_phase phase);
extern task run_phase(uvm_phase phase);
endclass
function void my_component::build_phase(uvm_phase phase);
super.build_phase(phase);
...
endfunction
...
对于两种方法学都熟悉的用户可以从上面的不同中看出,在迁移到UVM之后,建议将原有的phase方法名添加后缀“<name>_phase”,同时给添加参数“uvm_phase phase”。
替换OVM objection方法
在UVM中,原本在OVM中适用的stop()和global_stop_request()方法已经废弃,取而代之的是通过在phase阶段中挂起objection来控制仿真的结束。例如,在原来顶层的OVM test中,会使用global_stop_request()在序列发送完来结束仿真,而在UVM中需要使用uvm_phase来控制。
OVM中使用global_stop_request
task run();
seq.start( m_virtual_sequencer );
global_stop_request();
endtask
UVM中使用uvm_phase
task run_phase( uvm_phase phase );
phase.raise_objection( this );
seq.start( m_virtual_sequencer );
phase.lower_objection( this );
endtask
类似地,以前通过uvm_test_done对象来实现全局控制结束的方式,在UVM中也交给了uvm_phase的控制,这就使得objection机制保持了风格统一。
OVM中使用ovm_test_done
task run();
ovm_test_done.raise_objection( this );
seq.start( m_virtual_sequencer );
ovm_test_done.drop_objection( this );
endtask
UVM中使用run_phase
task run_phase( uvm_phase phase );
phase.raise_objection( this , "started sequence" );
seq.start( m_virtual_sequencer );