| |
The PSS env
在测试各种has_ <sub-component>字段以确定测试用例是否需要相应env之后,PSS env build过程检索配置对象并构造各种子env。如果需要使用子env,则在PSS envs配置表中设置sub-envs配置对象。connect method用于在TLM ports and exports之间建立连接,就如monitors和analysis components(如记分板)之间建立连接就是这样一个典型例子。
//
// Class Description:
//
//
class pss_env extends uvm_env;
// UVM Factory Registration Macro
//
`uvm_component_utils(pss_env)
//------------------------------------------
// Data Members
//------------------------------------------
pss_env_config m_cfg;
//------------------------------------------
// Sub Components
//------------------------------------------
spi_env m_spi_env;
gpio_env m_gpio_env;
ahb_agent m_ahb_agent;
pss_virtual_sequencer m_vsqr;
//------------------------------------------
// Methods
//------------------------------------------
// Standard UVM Methods:
extern function new(string name = "pss_env", uvm_component parent = null);
// Only required if you have sub-components
extern function void build_phase( uvm_phase phase );
// Only required if you have sub-components which are connected
extern function void connect_phase( uvm_phase phase );
endclass: pss_env
function pss_env::new(string name = "pss_env", uvm_component parent = null);
super.new(name, parent);
endfunction
// Only required if you have sub-components
function void pss_env::build_phase( uvm_phase phase );
if( !uvm_config_db #( pss_env_config )::get(this,"","pss_env_config",m_cfg) ) `uvm_error(...)【此处书上有笔误,"::get"错写成“::get_config”】
if(m_cfg.has_spi_env) begin
uvm_config_db::set( this , "m_spi_env*", "spi_env_config", m_cfg.m_spi_env_cfg);
m_spi_env = spi_env::type_id::create("m_spi_env", this);
end
if(m_cfg.has_gpio_env) begin
uvm_config_db #( gpio_env_config )::set("m_gpio_env*", "gpio_env_config", m_cfg.m_gpio_env_cfg);
m_gpio_env = gpio_env::type_id::create("m_gpio_env", this);
end
if(m_cfg.has_ahb_agent) begin
uvm_config_db #( ahb_agent_config )::set( this , "m_ahb_agent*", "ahb_agent_config", m_cfg.m_ahb_agent_cfg);
m_ahb_agent = ahb_agent::type_id::create("m_ahb_agent", this);
end
endfunction: build_phase
// Only required if you have sub-components which are connected
function void pss_env::connect_phase( uvm_phase phase );
// Inter-component TLM connections
endfunction: connect_phase
The rest of the test bench hierarchy
build过程从上到下继续进行,子envs如块级测试平台示例中所示的那样有条件地构建,并且子env中包含的agent正如agent示例中所述的那样构建。
Further levels of integration
通过扩展针对PSS示例描述的过程,可以实现用于更进一步集成水平的垂直重用。每个级别的集成都会添加另一个层,因此例如,第2级的集成环境将包含两个或更多第1级的env,而第2级的env配置对象将包含第1级 env配置对象的嵌套句柄。显然,在层次结构的test级别,每轮垂直重用的代码量都会增加,但在层次结构的下面,配置和构建过程已经在上一代垂直分层中实现。
(在http://verificationacademy.com/uvm-ovm上在线下载源代码示例)。