Friday, October 7, 2016

OVM 101.

Test Environment Structure
diagram
// Top level "module" contains class based test environment
//        and structural interface that drives DUT (module)
module top;

import ovm_pkg::*;
import my_pkg::*;

...
dut_if dut_if_inst0 ();
dut dut_inst0 (._if (dut_if_inst0) );

initial
begin
    run_test ("my_test_set");
end

endmodule : top

// ovm classes
// usually classes of test environment that includes fixed test bench
// and variable test sets

`include "ovm_macros.svh"

package my_package;
import ovm_pkg::*;

// Fixed test environment
class my_test_env extends ovm_env;
    `ovm_component_utils (my_test_env)

    // constructor
    function new (string s, ovm_component inst_parent);
        super.new (s, inst_parent);
    endfunction : new

    function void build;
        super.build ();
    endfunction : build

    task run;
        #10 ovm_top.stop_request();
    endtask : run

endclass : my_test_env

class my_test_set extends ovm_test;
    `ovm_component_utils (my_test_set)

    my_test_env my_test_env_handle;

    // constructor
    function new(string s, ovm_component inst_parent); 
        super.new(s, inst_parent);
    endfunction : new

    function void build;
        super.build();
        my_test_env_handle = my_test_env::type_id::create 
            ("my_test_env_handle", this);
    endfunction : build

endclass : my_test_set

// interface dut_if(); -> between test components and DUT
interface dut_if ();
...
endinterface : dut_if

// Design under test
module DUT (dut_if _if); 
endmodule : dut


No comments:

Post a Comment