UVM- run test() in top block and Macros

I’m reading the following guide:
https://colorlesscube.com/uvm-guide-for-beginners/chapter-3-top-block/

In Code 3.2 line 24- run_test();
I realized that it supposed to execute the test, but how it know which test, and how, and why should I write it in the top block.

In Code 4.1 lines 11-14 (Chapter 4 – Sequences and sequencers – Pedro Araújo):
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
Why should I add the “uvm_field_int” , what would happend if i didn’t add them, and what is “UVM_ALL_ON”?

Hi,

run_test() can be used in two ways,

  1. Without any arguments - run_test()
  2. With test_name as argument - run_test(“test_name”)

Use of run_test() without arguments is preferred as you can provide tests from your makefile/script using +UVM_TESTNAME=test_name with simulation command.

run_test() is a task defined in uvm-1.2/src/base/uvm_globals.svh in UVM library. When you use import uvm_pkg::* in top it is available in top module as well.


`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 macros are use for automation, meaning to avoid re-writing frequently used methods on transactions e.g. copy,print,clone transactions etc. When we use a macro uvm_field_int(ina, UVM_ALL_ON) , our variable here 'ina' gets included into all these methods (UVM_ALL_ON) copy, print, clone etc. and (uvm_field_int) ‘int’ is used if variable ‘inta’ is of type bit,int,logic,bit[vector] etc.

It is better to use do_ hooks e.g. do_print, do_copy methods once you go through SV concepts like dynamic casting, deep copy. As field macros adds many lines of codes and are less efficient!