OVM Test Example for testbench :
`ifndef __MEM_TEST_LIB
`define __MEM_TEST_LIB
class mem_base_test extends ovm_test;
`ovm_component_utils(mem_base_test)
mem_tb mem_tb_inst0;
ovm_table_printer printer;
function new (string name="mem_base_test", ovm_component parent=null);
super.new (name, parent);
endfunction : new
virtual function void build();
super.build();
//set_config_string("*.m_sequencer", "default_sequence", "simple_seq");
// Enable transaction recording for everything
set_config_int("*", "recording_detail", OVM_FULL);
mem_tb_inst0 = mem_tb::type_id::create("mem_tb", this);
// Create a specific depth printer for printing the created topology
// set_config_string("mem_tb_inst0.m_env0.m_sequencer", "default_sequence", "simple_seq");
printer = new();
printer.knobs.depth = 3;
endfunction : build
task run ();
mem_tb_inst0.m_env0.m_sequencer.default_sequence = "simple_seq";
$display("SEQUENCER : Puneet \n");
mem_tb_inst0.m_env0.m_sequencer.print();
#10000;
ovm_report_info(get_type_name(),"Calling global_stop_request() to end the run phase", OVM_LOW);
global_stop_request();
endtask : run
function void end_of_elaboration();
// Set verbosity for the bus monitor
mem_tb_inst0.m_env0.m_monitor.set_report_verbosity_level(OVM_FULL);
ovm_report_info(get_type_name(), $psprintf("Printing the test topology :\n%s", this.sprint(printer)), OVM_LOW);
endfunction : end_of_elaboration
endclass : mem_base_test
class mem_read_write_test extends mem_base_test;
`ovm_component_utils(mem_read_write_test)
function new (string name="mem_read_write_test", ovm_component parent=null);
super.new (name, parent);
endfunction : new
virtual function void build ();
set_config_string("mem_tb_inst0.m_env0.m_sequencer", "default_sequence", "ovm_random_sequence");
super.build();
ovm_report_info(get_type_name(),"INSIDE mem_read_write_test BUILD METHOD", OVM_LOW);
endfunction : build
task run ();
ovm_report_info(get_type_name(),"INSIDE mem_read_write_test RUN METHOD", OVM_LOW);
#2000;
ovm_report_info(get_type_name(),"Calling global_stop_request() to end the run phase", OVM_LOW);
global_stop_request();
endtask : run
endclass : mem_read_write_test
class mem_bitwalk_test extends mem_base_test;
`ovm_component_utils(mem_bitwalk_test)
function new (string name="mem_bitwalk_test", ovm_component parent=null);
super.new (name, parent);
endfunction : new
virtual function void build ();
set_config_string("mem_tb_inst0.m_env0.m_sequencer", "default_sequence", "mem_bit_walk_seq");
super.build();
endfunction : build
task run ();
#2000;
ovm_report_info(get_type_name(),"Calling global_stop_request() to end the run phase", OVM_LOW);
global_stop_request();
endtask : run
endclass : mem_bitwalk_test
// Boundry Value Check
class mem_boundry_val_test extends mem_base_test;
`ovm_component_utils(mem_boundry_val_test)
function new(string name = "mem_boundry_val_test", ovm_component parent=null);
super.new(name,parent);
endfunction : new
virtual function void build();
// Create the tb
super.build();
// Set the default sequence for the master and slave
//set_config_string("*.m_sequencer", "default_sequence", "mem_boundry_val_seq");
set_config_string("mem_tb_inst0.m_env0.m_sequencer", "default_sequence", "mem_boundry_val_seq");
endfunction : build
task run ();
mem_tb_inst0.m_env0.m_sequencer.default_sequence = "mem_boundry_val_seq";
$display("SEQUENCER : Puneet \n");
mem_tb_inst0.m_env0.m_sequencer.print();
ovm_report_info(get_type_name(),"STARTING mem_boundry_val_test : Puneet ", OVM_LOW);
#2000;
ovm_report_info(get_type_name(),"Calling global_stop_request() to end the run phase", OVM_LOW);
global_stop_request();
endtask : run
endclass : mem_boundry_val_test
`endif //__MEM_TEST_LIB
|
Posted By : zied - 2009-08-14 05:07:29
are u sure that this test code is working, because there is no mem_tb class available. Thanks.