Environment class.
Virtual interface declaration.
Defining Environment class constructor.
Defining required methods for execution. Currently these methods will not be implemented in this phase.
All the above are done in Environment.sv file.
We will write a testcase using the above define environment class in testcase.sv file.
Environment Class:
The class is a base class used to implement verification environments. Testcase contains the instance of the environment class and has access to all the public declaration of environment class.
All methods are declared as virtual methods. In environment class, we will formalize the simulation steps using virtual methods. The methods are used to control the execution of the simulation.
Following are the methods which are going to be defined in environment class.
1) new() : In constructor method, we will connect the virtual interfaces which are passed as argument to the virtual interfaces to those which are declared in environment class.
2) build(): In this method , all the objects like driver, monitor etc are constructed. Currently this method is empty as we did not develop any other component.
3) reset(): in this method we will reset the DUT.
4) cfg_dut(): In this method, we will configure the DUT output port address.
5) start(): in this method, we will call the methods which are declared in the other components like driver and monitor.
6) wait_for_end(): this method is used to wait for the end of the simulation. Waits until all the required operations in other components are done.
7) report(): This method is used to print the TestPass and TestFail status of the simulation, based on the error count..
8) run(): This method calls all the above declared methods in a sequence order. The testcase calls this method, to start the simulation.
We are not implementing build(), reset(), cfg_dut() , strat() and report() methods in this phase.
Connecting the virtual interfaces of Environment class to the physical interfaces of top module.
Verification environment contains the declarations of the virtual interfaces. Virtual interfaces are just a handles(like pointers). When a virtual interface is declared, it only creats a handle. It doesnot creat a real interface.
Constructor method should be declared with virtual interface as arguments, so that when the object is created in testcase, new() method can pass the interfaces in to environment class where they are assigned to the local virtual interface handle. With this, the Environment class virtual interfaces are pointed to the physical interfaces which are declared in the top module.
$display(" %0d : Environment : created env object",$time);
endfunction : new
functionvoid build();
$display(" %0d : Environment : start of build() method",$time);
$display(" %0d : Environment : end of build() method",$time);
endfunction :build
task reset();
$display(" %0d : Environment : start of reset() method",$time);
$display(" %0d : Environment : end of reset() method",$time);
endtask : reset
task cfg_dut();
$display(" %0d : Environment : start of cfg_dut() method",$time);
$display(" %0d : Environment : end of cfg_dut() method",$time);
endtask : cfg_dut
task start();
$display(" %0d : Environment : start of start() method",$time);
$display(" %0d : Environment : end of start() method",$time);
endtask : start
task wait_for_end();
$display(" %0d : Environment : start of wait_for_end() method",$time);
$display(" %0d : Environment : end of wait_for_end() method",$time);
endtask : wait_for_end
task run();
$display(" %0d : Environment : start of run() method",$time);
build();
reset();
cfg_dut();
start();
wait_for_end();
report();
$display(" %0d : Environment : end of run() method",$time);
endtask : run
task report();
endtask : report
endclass
`endif
We will create a file Global.sv for global requirement. In this file, define all the port address as macros in this file. Define a variable error as integer to keep track the number of errors occurred during the simulation.