sample_uvm_tb/test_base.sv

77 lines
2.4 KiB
Systemverilog
Raw Normal View History

2024-08-11 21:48:11 -07:00
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