|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



PHASE 3 ENVIRONMENT N TESTCASE




In the phase we will implement the skeleton for environment class.
We will declare virtual interfaces and Extend Required Environment class virtual methods.
We will also implement a simple testcase and run the simulation.




Environment class is used to implement verification environments in OVM. It is extension on ovm_env class. The testbench simulation needs some systematic flow like building the components, connection the components, starting the components etc. ovm_env base class has methods formalize the simulation steps. All methods are declared as virtual methods.


We will not implement all the ovm_env virtual methods in this phase but will we print messages from these methods which are required for this example to understand the simulation execution.

Testcase contains the instance of the environment class. This testcase Creates a Environment object and defines the required test specific functionality.

Verification environment contains the declarations of the virtual interfaces. These virtual interfaces are pointed to the physical interfaces which are declared in the top module. These virtual interfaces are made to point to physical interface in the testcase.



Environment



1) Extend ovm_env class to define Environment class.


`ifndef GUARD_ENV
`define GUARD_ENV

class Environment extends ovm_env;

endclass : Environment

`endif


2) Declare the utility macro. This utility macro provides the implementation of create() and get_type_name() methods.


`ovm_component_utils(Environment)


3) Define the constructor. In the constructor, call the super methods and pass the parent object. Parent is the object in which environment is instantiated.


function new(string name , ovm_component parent = null);
super.new(name, parent);
endfunction: new


4) Define build method. In build method, just print messages and super.build() must be called. This method is automatically called.
Build is the first phase in simulation. This phase is used to construct the child components of the current class.


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

ovm_report_info(get_full_name(),"START of build ",OVM_LOW);

ovm_report_info(get_full_name(),"END of build ",OVM_LOW);

endfunction


5) Define connect method. In connect method, just print messages and super.connect() must be called.
This method is called automatically after the build() method is called. This method is used for connecting port and exports.


function void connect();
super.connect();
ovm_report_info(get_full_name(),"START of connect ",OVM_LOW);

ovm_report_info(get_full_name(),"END of connect ",OVM_LOW);
endfunction


(S)Environment class Source Code
`ifndef GUARD_ENV
`define GUARD_ENV

class Environment extends ovm_env;

`ovm_component_utils(Environment)

function new(string name , ovm_component parent = null);
super.new(name, parent);
endfunction: new

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

ovm_report_info(get_full_name(),"START of build ",OVM_LOW);

ovm_report_info(get_full_name(),"END of build ",OVM_LOW);

endfunction

function void connect();
super.connect();
ovm_report_info(get_full_name(),"START of connect ",OVM_LOW);

ovm_report_info(get_full_name(),"END of connect ",OVM_LOW);
endfunction

endclass : Environment
`endif

Testcase



Now we will implement testcase. In OVM, testcases are implemented by extending ovm_test. Using ovm_test , provides the ability to select which test to execute using the OVM_TESTNAME command line option or argument to the ovm_root::run_test task. We will use OVM_TESTNAME command line argument.




1) Define a testcase by extending ovm_test class.


class test1 extends ovm_test;

endclass


2) Declare the utility macro.


`ovm_component_utils(test1)


3) Take the instance of Environemtn.


Environment t_env ;


4) Define the constructor method.
In this method, construct the environment class object and dont forget to pass the parent argument.


function new (string name="test1", ovm_component parent=null);
super.new (name, parent);
t_env = new("t_env",this);
endfunction : new


5) Define run() method.
run() method is the only task which is time consuming. After completing the start_of_simulation() phase , this method is called.
To terminate this task, we will use global_stop_request().

As we dont have anything now to write in this testcase, just call the global_stop_request() after some delay.


task run ();
#1000;
global_stop_request();
endtask : run


With this, for the first time, we can do the simulation.



(S)Testcase Source code
class test1 extends ovm_test;

`ovm_component_utils(test1)

Environment t_env ;

function new (string name="test1", ovm_component parent=null);
super.new (name, parent);
t_env = new("t_env",this);
endfunction : new

task run ();
#1000;
global_stop_request();
endtask : run

endclass : test1


(S)Download the Source Code


ovm_switch_3.tar
Browse the code in ovm_switch_3.tar


(S)Command to run the simulation


vcs -sverilog +incdir+$OVM_HOME/src $OVM_HOME/src/ovm_pkg.sv +incdir+. rtl.sv interface.sv top.sv -R +OVM_TESTNAME=test1
qverilog +incdir+$OVM_HOME/src $OVM_HOME/src/ovm_pkg.sv +incdir+. rtl.sv interface.sv top.sv -R +OVM_TESTNAME=test1


(S)Log report after simulation

OVM_INFO @ 0 [RNTST] Running test test1...
OVM_INFO @ 0: ovm_test_top.t_env [ovm_test_top.t_env] START of build
OVM_INFO @ 0: ovm_test_top.t_env [ovm_test_top.t_env] END of build
OVM_INFO @ 0: ovm_test_top.t_env [ovm_test_top.t_env] START of connect
OVM_INFO @ 0: ovm_test_top.t_env [ovm_test_top.t_env] END of connect

--- OVM Report Summary ---

** Report counts by severity
OVM_INFO : 5
OVM_WARNING : 0
OVM_ERROR : 0
OVM_FATAL : 0
** Report counts by id
[RNTST ] 1
[ovm_test_top.t_env ] 4




Index
Introduction
Specification
Verification Plan
Phase 1 Top
Phase 2 Configuration
Phase 3 Environment N Testcase
Phase 4 Packet
Phase 5 Sequencer N Sequence
Phase 6 Driver
Phase 7 Receiver
Phase 8 Scoreboard

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer