UVM- 运行 顶部块和宏中的 test()
UVM- run test() in top block and Macros
我正在阅读以下指南:
https://colorlesscube.com/uvm-guide-for-beginners/chapter-3-top-block/
代码 3.2 第 24 行- run_test();
我意识到它应该执行测试,但它如何知道哪个测试,以及如何以及为什么我应该将它写在顶部块中。
代码 4.1 第 11-14 行(https://colorlesscube.com/uvm-guide-for-beginners/chapter-4-transactions-sequences-and-sequencers/):
`uvm_object_utils_begin(simpleadder_transaction)
`uvm_field_int(ina, UVM_ALL_ON)
`uvm_field_int(inb, UVM_ALL_ON)
`uvm_field_int(out, UVM_ALL_ON)
`uvm_object_utils_end
为什么我要添加 "uvm_field_int" ,如果我不添加它们会发生什么,什么是 "UVM_ALL_ON"?
run_test 在文档 (link) 中定义为:
virtual task run_test (
string test_name = ""
)
因此,原则上,您可以将测试名称作为字符串声明在那里。但通常做的是使用参数在模拟器的命令行中传递它:+UVM_TESTNAME=TEST_NAME
uvm_object 宏有点复杂。他们生成了几种方法,更重要的是,他们在 UVM 工厂中注册了对象,这就是使它们成为必要的原因(至少如果你正在使用,正如你应该的那样,工厂来创建它们)。引用自 UVM Class Reference documentation (第 20.2 节组件和对象宏):
Simple (non-parameterized) objects use the uvm_object_utils* versions,
which do the following:
- Implements get_type_name, which returns TYPE as a string
- Implements create, which allocates an object of type TYPE by calling its constructor with no arguments. TYPE’s constructor, if
defined, must have default values on all it arguments.
- Registers the TYPE with the factory, using the string TYPE as the factory lookup string for the type.
- Implements the static get_type() method which returns a factory proxy object for the type.
- Implements the virtual get_object_type() method which works just like the static get_type() method, but operates on an already
allocated object.
run_test 是一个辅助全局函数,它调用 uvm_root class 的 run_test 函数到 运行 测试用例。有两种方法可以将测试名称传递给 function.The,第一种是通过函数参数,第二种是通过命令行参数。命令行参数优先于通过函数参数传递的测试名称。
+UVM_TESTNAME=YOUR_TEST_NAME
run_test("YOUR_TEST_NAME");
run_test uvm_root 中的函数使用工厂机制来创建 umm_test class 的适当实例,因此测试用例必须向工厂注册自己使用宏 `uvm_component_utils 让工厂机制 (create_component_by_name) 发挥作用。
class YOUR_TEST_NAME extends umm_test ;
// register the class with the factory
// so that run_test can find this class when the
// string test_name is passed to it.
`uvm_component_utils(YOUR_TEST_NAME)
.....
endclass
run_test 函数然后启动 uvm_phases (..,build_phase,connect_phase,...) 开始模拟的 uvm 部分。在 run_phase 开始之前不应消耗任何时间滴答,因此在初始块本身中调用 run_test 案例是必不可少的。我们还希望 uvm 和测试台准备好在 RTL 准备就绪后立即驱动和接收数据,为此我们必须尽早启动 run_test。这样做的任何延迟都会产生错误。
`uvm_field_int/uvm_field_object/.. 称为字段自动化宏。它们在 class 定义中不是强制性的,而是作为辅助宏提供的,以简化 uvm_object 的许多 common/routine 函数的使用。 uvm_object 中这些函数的示例是 - 复制、比较、打包、解包、打印等,这些宏生成代码以自动使用这些函数。
如果您不使用 uvm_object 常用函数,从 class 定义中省略这些宏将不会产生任何错误。
如果您实现自己的通用操作版本,您也可以从 class.
中省略这些宏
UVM_ALL_ON - 为特定字段启用 compare/copy/... 等所有功能。
link 举例 -
http://www.testbench.in/UT_04_UVM_TRANSACTION.html
例如 uvm_object 有一个比较函数,它比较相同 class 和 return 的两个实例,如果 class 中的所有变量都相等则为真。
virtual function bit do_compare( uvm_object rhs, uvm_comparer comparer );
.....
// return 1 if all the variables match
return ( super.do_compare( rhs, comparer ) &&
this.var_1 == rhs.var_1 &&
this.var_2 == rhs.var_2 &&
......
this.var_n == rhs.var_n );
endfunction: do_compare
// use in main code
if ( new_class.compare(old_classs) )
...
//instead of
if ( new_class.var1 == old_class.var1 && new_class.var2 == old_class.var2 && ... new_class.varn == old_class.varn )
...
必须为每个 class 编写上述比较,并为添加到 class 的每个新变量更新和维护。随着新变量的添加,这可能会变得容易出错。 uvm_object 提供的所有标准功能都必须遵循类似的过程。
现场自动化宏生成函数来自动处理所有这些功能。因此,使用宏为 class 执行 do_print 将打印出所有字段,而无需明确为其编写任何代码。
// compare/print/.. functions for class simpleadder_transaction are provided by using `uvm_field_int macro.
`uvm_object_utils_begin(simpleadder_transaction)
`uvm_field_int(ina, UVM_ALL_ON)
`uvm_object_utils_end
但请注意,不鼓励使用这些宏,因为它们会在 class. 中添加大量代码。 class 可能不需要这些函数中的大多数,但它们会默认生成。
我正在阅读以下指南: https://colorlesscube.com/uvm-guide-for-beginners/chapter-3-top-block/
代码 3.2 第 24 行- run_test();
我意识到它应该执行测试,但它如何知道哪个测试,以及如何以及为什么我应该将它写在顶部块中。
代码 4.1 第 11-14 行(https://colorlesscube.com/uvm-guide-for-beginners/chapter-4-transactions-sequences-and-sequencers/):
`uvm_object_utils_begin(simpleadder_transaction)
`uvm_field_int(ina, UVM_ALL_ON)
`uvm_field_int(inb, UVM_ALL_ON)
`uvm_field_int(out, UVM_ALL_ON)
`uvm_object_utils_end
为什么我要添加 "uvm_field_int" ,如果我不添加它们会发生什么,什么是 "UVM_ALL_ON"?
run_test 在文档 (link) 中定义为:
virtual task run_test (
string test_name = ""
)
因此,原则上,您可以将测试名称作为字符串声明在那里。但通常做的是使用参数在模拟器的命令行中传递它:+UVM_TESTNAME=TEST_NAME
uvm_object 宏有点复杂。他们生成了几种方法,更重要的是,他们在 UVM 工厂中注册了对象,这就是使它们成为必要的原因(至少如果你正在使用,正如你应该的那样,工厂来创建它们)。引用自 UVM Class Reference documentation (第 20.2 节组件和对象宏):
Simple (non-parameterized) objects use the uvm_object_utils* versions, which do the following:
- Implements get_type_name, which returns TYPE as a string
- Implements create, which allocates an object of type TYPE by calling its constructor with no arguments. TYPE’s constructor, if defined, must have default values on all it arguments.
- Registers the TYPE with the factory, using the string TYPE as the factory lookup string for the type.
- Implements the static get_type() method which returns a factory proxy object for the type.
- Implements the virtual get_object_type() method which works just like the static get_type() method, but operates on an already allocated object.
run_test 是一个辅助全局函数,它调用 uvm_root class 的 run_test 函数到 运行 测试用例。有两种方法可以将测试名称传递给 function.The,第一种是通过函数参数,第二种是通过命令行参数。命令行参数优先于通过函数参数传递的测试名称。
+UVM_TESTNAME=YOUR_TEST_NAME
run_test("YOUR_TEST_NAME");
run_test uvm_root 中的函数使用工厂机制来创建 umm_test class 的适当实例,因此测试用例必须向工厂注册自己使用宏 `uvm_component_utils 让工厂机制 (create_component_by_name) 发挥作用。
class YOUR_TEST_NAME extends umm_test ;
// register the class with the factory
// so that run_test can find this class when the
// string test_name is passed to it.
`uvm_component_utils(YOUR_TEST_NAME)
.....
endclass
run_test 函数然后启动 uvm_phases (..,build_phase,connect_phase,...) 开始模拟的 uvm 部分。在 run_phase 开始之前不应消耗任何时间滴答,因此在初始块本身中调用 run_test 案例是必不可少的。我们还希望 uvm 和测试台准备好在 RTL 准备就绪后立即驱动和接收数据,为此我们必须尽早启动 run_test。这样做的任何延迟都会产生错误。
`uvm_field_int/uvm_field_object/.. 称为字段自动化宏。它们在 class 定义中不是强制性的,而是作为辅助宏提供的,以简化 uvm_object 的许多 common/routine 函数的使用。 uvm_object 中这些函数的示例是 - 复制、比较、打包、解包、打印等,这些宏生成代码以自动使用这些函数。
如果您不使用 uvm_object 常用函数,从 class 定义中省略这些宏将不会产生任何错误。 如果您实现自己的通用操作版本,您也可以从 class.
中省略这些宏UVM_ALL_ON - 为特定字段启用 compare/copy/... 等所有功能。
link 举例 - http://www.testbench.in/UT_04_UVM_TRANSACTION.html
例如 uvm_object 有一个比较函数,它比较相同 class 和 return 的两个实例,如果 class 中的所有变量都相等则为真。
virtual function bit do_compare( uvm_object rhs, uvm_comparer comparer );
.....
// return 1 if all the variables match
return ( super.do_compare( rhs, comparer ) &&
this.var_1 == rhs.var_1 &&
this.var_2 == rhs.var_2 &&
......
this.var_n == rhs.var_n );
endfunction: do_compare
// use in main code
if ( new_class.compare(old_classs) )
...
//instead of
if ( new_class.var1 == old_class.var1 && new_class.var2 == old_class.var2 && ... new_class.varn == old_class.varn )
...
必须为每个 class 编写上述比较,并为添加到 class 的每个新变量更新和维护。随着新变量的添加,这可能会变得容易出错。 uvm_object 提供的所有标准功能都必须遵循类似的过程。
现场自动化宏生成函数来自动处理所有这些功能。因此,使用宏为 class 执行 do_print 将打印出所有字段,而无需明确为其编写任何代码。
// compare/print/.. functions for class simpleadder_transaction are provided by using `uvm_field_int macro.
`uvm_object_utils_begin(simpleadder_transaction)
`uvm_field_int(ina, UVM_ALL_ON)
`uvm_object_utils_end
但请注意,不鼓励使用这些宏,因为它们会在 class. 中添加大量代码。 class 可能不需要这些函数中的大多数,但它们会默认生成。