UVM:Hello World Example

 

     Hello again, so in this blog we will see a basic hello world example in UVM, 

TB Architecture :

agent.sv

 
// class  -> agent
// class  -> env
// class  -> test
// module -> top

class agent extends uvm_agent;
    `uvm_component_utils(agent)

    function new(string name="agent",uvm_component parent);
        super.new(name,parent);
    endfunction
    
    function void build_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside build phase", UVM_MEDIUM)
    endfunction: build_phase

    function void end_of_elaboration_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside end of eleboration phase", UVM_MEDIUM)
    endfunction: end_of_elaboration_phase

    function void start_of_simulation_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside start of simulation phase", UVM_MEDIUM)
    endfunction: start_of_simulation_phase

    function void report_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside report phase", UVM_MEDIUM)
    endfunction: report_phase

    function void hello_world();
        `uvm_info(get_type_name(), "----- HELLO WORLD -----", UVM_MEDIUM)
    endfunction

endclass

env.sv


class env extends uvm_env;
    `uvm_component_utils(env)

    function new(string name="env",uvm_component parent);
        super.new(name,parent);
    endfunction
    
    agent agent_h;


    function void build_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside build phase", UVM_MEDIUM)
        agent_h=agent::type_id::create("agent_h");
    endfunction: build_phase

    function void end_of_elaboration_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside end of eleboration phase", UVM_MEDIUM)
    endfunction: end_of_elaboration_phase

    function void start_of_simulation_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside start of simulation phase", UVM_MEDIUM)
         `uvm_info(get_type_name(), "----- calling : agent_h.hello_world();", UVM_MEDIUM)
        agent_h.hello_world();
    endfunction: start_of_simulation_phase

    function void report_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside report phase", UVM_MEDIUM)
    endfunction: report_phase

endclass

test.sv


class test extends uvm_test;
    `uvm_component_utils(test)

    function new(string name="test",uvm_component parent);
        super.new(name,parent);
    endfunction
    
    env env_h;
    function void build_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside build phase", UVM_MEDIUM)
        env_h=env::type_id::create("env_h");
    endfunction: build_phase

    function void end_of_elaboration_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside end of eleboration phase", UVM_MEDIUM)
    endfunction: end_of_elaboration_phase

    function void start_of_simulation_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside start of simulation phase", UVM_MEDIUM)
    endfunction: start_of_simulation_phase

    task task run_phase(uvm_phase phase);
        phase.raise_objection(this);
        `uvm_info(get_name(), "<run_phase> started, objection raised.", UVM_NONE)
        #10;
        `uvm_info(get_type_name(), "Inside RUN phase", UVM_MEDIUM)
        phase.drop_objection(this);
        `uvm_info(get_name(), "<run_phase> finished, objection dropped.", UVM_NONE)
    endtask: run_phase
    
    function void report_phase(uvm_phase phase);
        `uvm_info(get_type_name(), "Inside report phase", UVM_MEDIUM)
    endfunction: report_phase

endclass

 tb_pkg.sv


`ifndef tb_pkg
`define tb_pkg
`include "uvm_macros.svh"
package tb_pkg;
    import uvm_pkg::*;
    `include "agent.sv"
    `include "env.sv"
    `include "test.sv"
endpackage
`endif

top.sv


`include "uvm_macros.svh"
`include "tp_pkg.sv"
module top;
    import uvm_pkg::*;
    import tb_pkg::*;
    
    initial begin
        run_test("test");
    end

endmodule

 

Link for Code : https://www.edaplayground.com/x/ZLhx

 

Thank you for reading have a nice day. 😇😇😉.

Share:
Copyright © VLSI Verification Concepts . Designed by OddThemes