program automatic test_program; //can be a module

import uvm_pkg::*;

class hello_world_test extends uvm_test;

`uvm_component_utils(hello_world_test)

function new(string name, uvm_component parent);

super.new(name, parent);

endfunction

virtual task run_phase(uvm_phase phase); //the run_phase method will be executed automatically by the UVM simulation manager

`uvm_info("DEMO", "HelloWorld!", UVM_MEDIUM); //macro

endtask

endclass

initial begin //to enable UVM route (to automatically enable) for you

run_test();

end

endprogram

-------------------------------------------------

After Compilation (vcs):

vcs -sverilog -ntb_opts uvm test.sv

Simulate with:

simv +UVM_TESTNAME=hello_world_test

-------------------------------------------------

So what is happening here in general is? On using the UVM Environment here, when you simulate the code with a +UVM_TESTNAME, the result (below) displays the new message automatically saving your time (which is a very useful automation technique and saves a lot of your time).

Result:

---------------------------------------------------------------------------------

UVM_INFO @ 0: reporter [RNTST] Running test new_world_test..

UVM_INFO ./test.sv(9) @ 0: uvm_test_top [DEMO] New World!

---------------------------------------------------------------------------------





UVM Configuration Database Example: Here, instead of "Hello World" a string variable msg is used. Compilation and Simulation will produce the same result. But now, we can use a UVM runtime switch to change the message to what we want for that simulation without running another test.





The uvm_config_db requires 3 arguments. 1> Specifies name of the uvm object you want to configure.





program automatic test_program; //can be a module import uvm_pkg::*;

class hello_world_test extends uvm_test; `uvm_component_utils(hello_world_test)

String msg; function new(string name, uvm_component parent); super.new(name, parent); msg = "Hello World!";

endfunction virtual task run_phase(uvm_phase phase); //the run_phase method

will be executed automatically by the UVM simulation manager uvm_config_db#(string)::get(this /*Target*/ , "", "message", msg);

`uvm_info("DEMO", msg, UVM_MEDIUM); endtask endclass initial begin //to enable UVM route (to automatically enable) for you run_test(); end endprogram





--------------------------------------

Simulate with:

simv +UVM_TESTNAME=hello_world_test \

+uvm_set_config_string=uvm_test_top,message,New\ World!

--------------------------------------





Arguments:

uvm_test_top = Target

message = Database entry key => It must match with the 3rd argument of the get method -- get(). The Retrieval from the Database is based on this entry key.

Set value = the Last argument that you want to store in the Database. If the target and the entry key matches, then you get the Result.