// Base class for testbench tests class test_base extends uvm_test; `uvm_component_utils(test_base) tb_env env; uvm_table_printer tb_printer; // ------------------------------------------------------------ function new(string name, uvm_component parent); super.new(name, parent); endfunction // ------------------------------------------------------------ function void build_phase(uvm_phase phase); super.build_phase(phase); env = tb_env::type_id::create("env", this); tb_printer = new("tb_printer"); uvm_config_db#(tb_env)::set(uvm_root::get(), "*", "env", env); endfunction // ------------------------------------------------------------ virtual function void end_of_elaboration_phase(uvm_phase phase); `uvm_info("end_of_elaboration_phase", $sformatf("Testbench topology:\n%s", this.sprint(tb_printer)), UVM_LOW) display_uvm_config_db(); display_uvm_config_db("uvm_test_top.env.axi_m"); display_uvm_config_db("uvm_test_top.env.axi_s"); dump_uvm_config_db(); endfunction // ------------------------------------------------------------ virtual task run_phase(uvm_phase phase); uvm_objection objection; objection = phase.get_objection(); `uvm_info("run_phase", $sformatf("Raising objection"), UVM_LOW) phase.raise_objection(this); run_reset_phase(phase); run_test_phase(phase); run_flush_phase(phase); objection.set_drain_time(this, 20); `uvm_info("run_phase", $sformatf("Dropping objection"), UVM_LOW) phase.drop_objection(this); endtask // ------------------------------------------------------------ virtual task run_reset_phase(uvm_phase phase); `uvm_info("run_reset_phase", $sformatf("Starting reset"), UVM_LOW) `uvm_info("run_reset_phase", $sformatf("Finishing reset"), UVM_LOW) endtask // ------------------------------------------------------------ virtual task run_test_phase(uvm_phase phase); `uvm_warning("run_test_phase", $sformatf("This content is expected to be implemented in specific tests")) endtask // ------------------------------------------------------------ virtual task run_flush_phase(uvm_phase phase); `uvm_info("run_flush_phase", $sformatf("Finishing test"), UVM_LOW) endtask // ------------------------------------------------------------ // Function to traverse and display all entries in uvm_config_db function void display_uvm_config_db(string scope = ".*"); uvm_resource_pool rp = uvm_resource_pool::get(); uvm_resource_types::rsrc_q_t resources; // Get all resources from the resource pool resources = rp.lookup_regex(scope, get_full_name()); rp.print_resources(resources, 1); `uvm_info("CONFIG_DB", "Traversing uvm_config_db contents:", UVM_LOW) if (resources.size() == 0) begin `uvm_info("CONFIG_DB", "No entries found in uvm_config_db", UVM_LOW) return; end // Iterate through all resources do begin uvm_resource_base r = resources.pop_front(); if (r == null) begin `uvm_info("CONFIG_DB", "No more resources to process", UVM_LOW) break; end `uvm_info("CONFIG_DB", $sformatf("Resource: %s", r.get_name()), UVM_LOW) end while (1); endfunction // ------------------------------------------------------------ // Function to dump all entries in uvm_config_db function void dump_uvm_config_db(); uvm_resource_pool rp = uvm_resource_pool::get(); endfunction endclass // ---------------------------------------------------------------------- class test_basic extends test_base; `uvm_component_utils(test_basic) // ------------------------------------------------------------ function new(string name, uvm_component parent); super.new(name, parent); endfunction // ------------------------------------------------------------ virtual task run_test_phase(uvm_phase phase); axi_simple_seq seq; `uvm_info("run_test_phase", $sformatf("Starting stimulus"), UVM_LOW) #100ns; seq = axi_simple_seq::type_id::create("seq"); if (seq == null) begin `uvm_fatal("run_test_phase", "Failed to create sequence instance") end seq.start(env.get_axi_m_sequencer()); `uvm_info("run_test_phase", $sformatf("Finishing stimulus"), UVM_LOW) endtask endclass