当前位置:首页 > > 芯片验证工程师
[导读]UVM factory允许一个类在构造时被派生类替换。这对于更改testbench的行为很有用,它将一个类替换为另一个类,而无需编辑或重新编译testbench代码。为了使factoryoverride发挥作用,需要遵循许多编码约定的先决条件。主要存在component(实例替换...

UVM factory 允许一个类在构造时被派生类替换。这对于更改testbench的行为很有用,它将一个类替换为另一个类,而无需编辑或重新编译testbench 代码。


为了使factory override发挥作用,需要遵循许多编码约定的先决条件。主要存在component (实例替换、类替换)和object(实例替换、类替换)

 

Component Type Overrides

类型覆盖适用于该组件类型的所有实例:

class colour extends uvm_component;`uvm_component_utils(colour)// etcendclass: colour // Red child classclass red extends colour;`uvm_component_utils(red)//etcendclass: red // ::type_id::set_type_override(::get_type(), replace);// Where replace is a bit which when ==1 enables the override of an existing override, otherwise// the existing override is honoured.// To override all instances of colour with red:colour::type_id::set_type_override(red::get_type(), 1);// This means that the following creation line returns a red, rather than a colourpixel = colour::type_id::create("pixel", this);参数化的组件类也可以override,但必须注意确保覆盖类具有相同的参数值,否则它们不被认为是相关类型:

class bus_driver #(int BUS_WIDTH = 32) extends uvm_component;`uvm_component_param_utils(bus_driver #(BUS_WIDTH))// etcendclass: bus_driver class bus_conductor #(int BUS_WIDTH = 32) extends bus_driver #(BUS_WIDTH);`uvm_component_param_utils(bus_conductor #(BUS_WIDTH))// etcendclass: bus_conductor // The parameterised type override needs to keep the parameterisation consistentbus_driver #(64)::type_id::set_type_override(bus_conductor #(64)::get_type(), 1); // This will succeed // Creation of a #(64) bus_driver results in a #(64) bus_conductor handle being returned:bus_person = bus_driver#(64)::type_id::create("bus_person", this);// Whereas creating a #(16) bus_driver results in a #(16) bus_driver handle being returned because// the matching type override is not found:bus_person = bus_driver#(16)::type_id::create("bus_person", this);// Similarly if a type override has non-matching parameters, then it will fail and return the original typebus_driver #(64)::type_id::set_type_override(bus_conductor #(32)::get_type(), 1); // Returns bus_driver #(64)Component Instance Overrides

一个特定的组件实例可以通过指定其在uvm组件层次结构中的路径来被覆盖。同样,这种方法可以用于参数化的类,只要注意匹配覆盖中涉及的两个类的参数:

// Using red --> colour example from type override example// ::type_id::set_inst_override(::get_type(), );colour::type_id::set_inst_override(red::get_type(), "top.env.raster.spot");// And again for a parameterised type, the parameter values must matchbus_driver #(64)::type_id::set_inst_override(bus_conductor #(64)::get_type(), "top.env.bus_agent.m_driver");Objects sequence 相关的对象通常只与类型覆盖一起使用,因为uvm_object与uvm_component不同,其不具有组件层次结构路径对象覆盖的代码与组件覆盖的形式相同。 

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭