Basic uvm question for the hello_world.sv from examples/simple

Hi,

I started to run the uvm examples that are part of the general uvm example released by Cadence and Mentor.

for the first example:

simple/hello_world.sv

I don’t understand the lines below with “<=======”.

mytop = new("top");  // what's the purpose of this line of code ?  <================
                     // Isn't "top mytop" already declared/constructed by the "mytop" object? <=====

Thanks,

David

module hello_world;

import uvm_pkg::*;
`include “uvm_macros.svh”

include "packet.sv" include “producer.sv”
include "consumer.sv" include “top.sv”

top mytop; // I believe this is to instantiate the top as “mytop”.

initial begin

mytop = new(“top”); // what’s the purpose of this line of code ? <================
// Isn’t “top mytop” already declared/constructed by the “mytop” object? <=====
uvm_default_table_printer.knobs.type_width=20;
run_test();
end
endmodule

In reply to david_fong_encore_semi:

Hi David,
A mere declaration of a class handle isn’t enough, you need a construction step to make the handle to point to an object (Else it will be NULL). Maybe you were thinking of:

top mytop = new (“top”);

IN general that’s a discouraged style and recommended you do it in 2 steps as done in that example.

HTH
Srini
www.verifworks.com