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


Tutorials



PHASE 2 ENVIRONMENT




In this phase, we will write

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.
Environment class is extension on vmm_env class. The testbench simulation needs some systematic flow like reset, initialize etc. vmm_env base class has methods formalize the simulation steps. All methods are declared as virtual methods.

We will not implement all the vmm_env virtual methods in this phase but will we print messages from these methods to understand the simulation execution.

Testcase contains the instance of the environment class and has access to all the public declaration of environment class. This testcase Creates a Environment object and calls the run() method which are defined in the environment class. Run() method runs all the simulation methods which are defined in environment class.

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.

Constructor method should be declared with virtual interface as arguments, so that when the object is created, in the testcase can pass the interfaces in to environment class.



Connecting the virtual interfaces of Environment class to the physical interfaces of top module.



Extend vmm_env class to define Environment class.



`ifndef GUARD_ENV
`define GUARD_ENV

class Environment extends vmm_env;


endclass

`endif




Declare virtual interfaces in Environment class.


virtual mem_interface.MEM mem_intf ;
virtual input_interface.IP input_intf ;
virtual output_interface.OP output_intf[4] ;



The construction of Environment class is declared with virtual interface as arguments.


function new(virtual mem_interface.MEM mem_intf_new ,
virtual input_interface.IP input_intf_new ,
virtual output_interface.OP output_intf_new[4] );

super.new("Environment ");



In constructor methods, the interfaces which are arguments are connected to the virtual interfaces of environment class.


this.mem_intf = mem_intf_new ;
this.input_intf = input_intf_new ;
this.output_intf = output_intf_new ;

`vmm_note(this.log, "Created env object");



Extend all the vmm_env virtual methods. Call the super.<method_name> in all the vmm_env virtual method extensions.

Include `vmm_note() messages for identifying the simulation steps in the log file.



virtual function void gen_cfg();
super.gen_cfg();
`vmm_note(this.log,"Start of gen_cfg() method ");
`vmm_note(this.log,"End of gen_cfg() method ");
endfunction
virtual function void build();
super.build();
`vmm_note(this.log,"Start of build() method ");
`vmm_note(this.log,"End of build() method ");
endfunction
....
....
....



Do the above for reset_dut(), cfg_dut(), start(), wait_for_end(), stop() cleanup() and report() methods.



Run :



The run method is called from the testcase to start the simulation. run method calls all the methods which are defined in the Environment class.










Environment Class Source Code:


`ifndef GUARD_ENV
`define GUARD_ENV

class Environment extends vmm_env;

virtual mem_interface.MEM mem_intf ;
virtual input_interface.IP input_intf ;
virtual output_interface.OP output_intf[4] ;

function new(virtual mem_interface.MEM mem_intf_new ,
virtual input_interface.IP input_intf_new ,
virtual output_interface.OP output_intf_new[4] );
super.new("Environment ");
this.mem_intf = mem_intf_new ;
this.input_intf = input_intf_new ;
this.output_intf = output_intf_new ;

`vmm_note(this.log, "Created env object");
endfunction : new


virtual function void gen_cfg();
super.gen_cfg();
`vmm_note(this.log,"Start of gen_cfg() method ");
`vmm_note(this.log,"End of gen_cfg() method ");
endfunction

virtual function void build();
super.build();
`vmm_note(this.log,"Start of build() method ");
`vmm_note(this.log,"End of build() method ");
endfunction

virtual task reset_dut();
super.reset_dut();
`vmm_note(this.log,"Start of reset_dut() method ");
`vmm_note(this.log,"End of reset_dut() method ");
endtask

virtual task cfg_dut();
super.cfg_dut();
`vmm_note(this.log,"Start of cfg_dut() method ");
`vmm_note(this.log,"End of cfg_dut() method ");
endtask

virtual task start();
super.start();
`vmm_note(this.log,"Start of start() method ");
`vmm_note(this.log,"End of start() method ");
endtask

virtual task wait_for_end();
super.wait_for_end();
`vmm_note(this.log,"Start of wait_for_end() method ");
`vmm_note(this.log,"End of wait_for_end() method ");
endtask

virtual task stop();
super.stop();
`vmm_note(this.log,"Start of stop() method ");
`vmm_note(this.log,"End of stop() method ");
endtask

virtual task cleanup();
super.cleanup();
`vmm_note(this.log,"Start of cleanup() method ");
`vmm_note(this.log,"End of cleanup() method ");
endtask

virtual task report();
`vmm_note(this.log,"Start of report() method \n\n\n");
$display("---------------------------------------------------------------------");
super.report();
$display("---------------------------------------------------------------------");
$display("\n\n");
`vmm_note(this.log,"End of report() method");
endtask

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.



`ifndef GUARD_GLOBALS
`define GUARD_GLOBALS

`define P0 8'h00
`define P1 8'h11
`define P2 8'h22
`define P3 8'h33


`endif



Now We will update the testcase. Take an instance of the Environment class and call the run method of the Environment class.



`ifndef GUARD_TESTCASE
`define GUARD_TESTCASE

program testcase(mem_interface.MEM mem_intf,input_interface.IP input_intf,output_interface.OP output_intf[4]);

`include "vmm.sv"

Environment env;

initial
begin
$display(" ******************* Start of testcase ****************");

env = new(mem_intf,input_intf,output_intf);
env.run();

end

final
$display(" ******************** End of testcase *****************");

endprogram
`endif

(S)Download the phase 2 source code:


vmm_switch_2.tar
Browse the code in vmm_switch_2.tar


(S)Run the simulation:
vcs -sverilog -f filelist -R -ntb_opts rvm

(S)Log report after the simulation:

******************* Start of testcase ****************
Normal[NOTE] on Environment() at 0:
Created env object
Normal[NOTE] on Environment() at 0:
Start of gen_cfg() method
Normal[NOTE] on Environment() at 0:
End of gen_cfg() method
Normal[NOTE] on Environment() at 0:
Start of build() method
Normal[NOTE] on Environment() at 0:
End of build() method
Normal[NOTE] on Environment() at 0:
Start of reset_dut() method
Normal[NOTE] on Environment() at 0:
End of reset_dut() method
Normal[NOTE] on Environment() at 0:
Start of cfg_dut() method
Normal[NOTE] on Environment() at 0:
End of cfg_dut() method
Normal[NOTE] on Environment() at 0:
Start of start() method
Normal[NOTE] on Environment() at 0:
End of start() method
Normal[NOTE] on Environment() at 0:
Start of wait_for_end() method
Normal[NOTE] on Environment() at 0:
End of wait_for_end() method
Normal[NOTE] on Environment() at 0:
Start of stop() method
Normal[NOTE] on Environment() at 0:
End of stop() method
Normal[NOTE] on Environment() at 0:
Start of cleanup() method
Normal[NOTE] on Environment() at 0:
End of cleanup() method
Normal[NOTE] on Environment() at 0:
Start of report() method



---------------------------------------------------------------------
Simulation PASSED on /./ (/./) at 0 (0 warnings, 0 demoted errors & 0 demoted warnings)
---------------------------------------------------------------------



Normal[NOTE] on Environment() at 0:
End of report() method
******************** End of testcase *****************

Index
Introduction
Specification
Verification Plan
Phase 1 Top
Phase 2 Environment
Phase 3 Reset
Phase 4 Packet
Phase 5 Generator
Phase 6 Driver
Phase 7 Receiver
Phase 8 Scoreboard
Phase 9 Coverage

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