110 lines
4.2 KiB
Systemverilog
110 lines
4.2 KiB
Systemverilog
// -----
|
|
//
|
|
// Copyright (c) 2024 Mahesh Asolkar
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
// this software and associated documentation files (the "Software"), to deal in
|
|
// the Software without restriction, including without limitation the rights to
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
// of the Software, and to permit persons to whom the Software is furnished to do
|
|
// so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
//
|
|
// -----
|
|
class test_base extends uvm_test;
|
|
`uvm_component_utils(test_base)
|
|
|
|
testbench_env tb_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);
|
|
|
|
tb_env = testbench_env::type_id::create("tb_env", this);
|
|
tb_printer = new("tb_printer");
|
|
|
|
uvm_config_db#(testbench_env)::set(uvm_root::get(), "*", "tb_env", tb_env);
|
|
endfunction
|
|
|
|
// ------------------------------------------------------------
|
|
virtual function void end_of_elaboration_phase(uvm_phase phase);
|
|
`uvm_info("end_of_elaboration_phase", $sformatf("Topology:\n%s", this.sprint(tb_printer)), UVM_LOW)
|
|
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);
|
|
seq_reset rst_seq;
|
|
|
|
`uvm_info("run_reset_phase", $sformatf("Starting reset"), UVM_LOW)
|
|
rst_seq = seq_reset::type_id::create("reset_seq", this);
|
|
rst_seq.start(tb_env.tb_sequencer);
|
|
`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
|
|
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);
|
|
seq_basic tst_seq;
|
|
|
|
tst_seq = seq_basic::type_id::create("test_seq_basic");
|
|
`uvm_info("run_test_phase", $sformatf("Starting stimulus"), UVM_LOW)
|
|
tst_seq.start(tb_env.tb_sequencer);
|
|
`uvm_info("run_test_phase", $sformatf("Finishing stimulus"), UVM_LOW)
|
|
endtask
|
|
endclass
|