Test Environment Nitty Gritty Code
- Configuration - Connecting virtual interface from top level to DUT.
- Use configuration table to store the wrapper(s) of virtual interface properties.
- This way, the test bench can be used with different configurations, changing wrappers.
- Configuration using "set_config_object" and "get_config_object" overrides top-down.
( from ovm_test -> ovm_env -> ovm_component)
// 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_inst1 (); dut dut_inst0 (._if (dut_if_inst1) ); initial begin: blk dut_if_wrapper if_wrapper = new ("if_wrapper", dut_if_inst1); // path field_name value 0: don't clone set_config_object("*", "dut_if_wrapper", if_wrapper, 0); run_test ("my_test_set"); end endmodule : top
class dut_if_wrapper extends ovm_object; virtual dut_if dut_vi; function new (string s, virtual dut_if if_arg); super.new(s); dut_vi = if_arg; endfunction : new endclass : dut_if_wrapper
// 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) virtual dut_if dut_virtual_if_inst; // constructor function new (string s, ovm_component inst_parent); super.new (s, inst_parent); endfunction : new function void build; super.build (); begin ovm_object obj; dut_if_wrapper if_wrapper; get_config_object("dut_if_wrapper", obj, 0); assert( $cast(if_wrapper, obj) ); dut_virtual_if_inst = if_wrapper.dut_vi; end endfunction : build task run; #10 dut_virtual_if_inst.data = 0; #10 dut_virtual_if_inst.data = 1; #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 (); logic clock, reset; logic data_input; endinterface : dut_if // Design under test module DUT (dut_if _if); always @ (posedge _if.clock) begin end endmodule : dut
// Higher level overriding lower level configuration // Overriding Example: // in ovm_test set_config_object ("*", "data", x); // in ovm_env get_config_object ("opt", y); set_config_object ("*", "data", y); // in ovm_component get_config_object ("data", obj); // obj = x
No comments:
Post a Comment