|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 UVM. It is extension on uvm_env class. The testbench simulation needs some systematic flow like building the components, connection the components, starting the components etc. uvm_env base class has methods formalize the simulation steps. All methods are declared as virtual methods.


We will not implement all the uvm_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 uvm_env class to define Environment class.


`ifndef GUARD_ENV
`define GUARD_ENV

class Environment extends uvm_env;

endclass : Environment

`endif


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


`uvm_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 , uvm_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.


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

uvm_report_info(get_full_name(),"START of build ",UVM_LOW);

uvm_report_info(get_full_name(),"END of build ",UVM_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.


virtual function void connect();
super.connect();
uvm_report_info(get_full_name(),"START of connect ",UVM_LOW);

uvm_report_info(get_full_name(),"END of connect ",UVM_LOW);
endfunction


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

class Environment extends uvm_env;

`uvm_component_utils(Environment)

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

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

uvm_report_info(get_full_name(),"START of build ",UVM_LOW);

uvm_report_info(get_full_name(),"END of build ",UVM_LOW);

endfunction

virtual function void connect();
super.connect();
uvm_report_info(get_full_name(),"START of connect ",UVM_LOW);

uvm_report_info(get_full_name(),"END of connect ",UVM_LOW);
endfunction

endclass : Environment
`endif

Testcase



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




1) Define a testcase by extending uvm_test class.


class test1 extends uvm_test;

endclass


2) Declare the utility macro.


`uvm_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", uvm_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.


virtual task run ();
#3000ns;
global_stop_request();
endtask : run


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



(S)Testcase Source code
class test1 extends uvm_test;

`uvm_component_utils(test1)

Environment t_env ;


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

virtual task run ();
#3000ns;
global_stop_request();
endtask : run

endclass : test1


(S)Download the Source Code


uvm_switch_3.tar
Browse the code in uvm_switch_3.tar


(S)Command to run the simulation


VCS Users : make vcs
Questa Users: make questa


(S)Log report after simulation

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

--- UVM Report Summary ---

** Report counts by severity
UVM_INFO : 5
UVM_WARNING : 0
UVM_ERROR : 0
UVM_FATAL : 0
** Report counts by id
[RNTST ] 1
[uvm_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