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


Tutorials



PHASE 5 GENERATOR




In This phase, we will the usage of vmm atomic generator. In phase 4, using`vmm_atomic_gen macro we defined Packet_atomic_gen.

In Environment class, we will create an instance of Packet_atomic_gen, and connect it to the instance of Packet_channel, i.e gen2drvr_chan. The Packet_channel instance gen2drvr_chan will be used to connect the atomic generator to the driver instance. We will also configure the atomic generator to generate 10 instances of packet.



1) In Environment class, declare a Packet_atomic_gen instance.


Packet_atomic_gen atomic_gen;


2) Declare a Packet_channel instance.


Packet_channel gen2drvr_chan;


3) Construct the gen2drvr_chan in build() method.


gen2drvr_chan = new("gen2drvr","chan");


4) Construct the atomic_gen in build() method.


atomic_gen = new("atomic_gen",0,gen2drvr_chan);


5) Configure the atomic_gen to generate 10 instances.


atomic_gen.stop_after_n_insts = 10;


6) In start() method, start the atomic_gen.


atomic_gen.start_xactor();


7) In stop() method, call the stop_xactor() method of atomic_gen.


atomic_gen.stop_xactor();

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] ;

Packet_atomic_gen atomic_gen;
Packet_channel gen2drvr_chan;

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 ");

gen2drvr_chan = new("gen2drvr","chan");
atomic_gen = new("atomic_gen",0,gen2drvr_chan);
atomic_gen.stop_after_n_insts = 10;

`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 ");
mem_intf.cb.mem_data <= 0;
mem_intf.cb.mem_add <= 0;
mem_intf.cb.mem_en <= 0;
mem_intf.cb.mem_rd_wr <= 0;
input_intf.cb.data_in <= 0;
input_intf.cb.data_status <= 0;
output_intf[0].cb.read <= 0;
output_intf[1].cb.read <= 0;
output_intf[2].cb.read <= 0;
output_intf[3].cb.read <= 0;

// Reset the DUT
input_intf.reset <= 1;
repeat (4) @ input_intf.clock;
input_intf.reset <= 0;

`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 ");
mem_intf.cb.mem_en <= 1;
@(posedge mem_intf.clock);
mem_intf.cb.mem_rd_wr <= 1;

@(posedge mem_intf.clock);
mem_intf.cb.mem_add <= 8'h0;
mem_intf.cb.mem_data <= `P0;
`vmm_note(this.log ,$psprintf(" Port 0 Address %h ",`P0));

@(posedge mem_intf.clock);
mem_intf.cb.mem_add <= 8'h1;
mem_intf.cb.mem_data <= `P1;
`vmm_note(this.log ,$psprintf(" Port 1 Address %h ",`P1));

@(posedge mem_intf.clock);
mem_intf.cb.mem_add <= 8'h2;
mem_intf.cb.mem_data <= `P2;
`vmm_note(this.log ,$psprintf(" Port 2 Address %h ",`P2));

@(posedge mem_intf.clock);
mem_intf.cb.mem_add <= 8'h3;
mem_intf.cb.mem_data <= `P3;
`vmm_note(this.log ,$psprintf(" Port 3 Address %h ",`P3));

@(posedge mem_intf.clock);
mem_intf.cb.mem_en <=0;
mem_intf.cb.mem_rd_wr <= 0;
mem_intf.cb.mem_add <= 0;
mem_intf.cb.mem_data <= 0;

`vmm_note(this.log,"End of cfg_dut() method ");
endtask

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

atomic_gen.start_xactor();

`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 ");
repeat(1000) @(input_intf.clock);
`vmm_note(this.log,"End of wait_for_end() method ");
endtask

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

atomic_gen.stop_xactor();

`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

(S)Download the phase 5 source code.


vmm_switch_5.tar
Browse the code in vmm_switch_5.tar


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

(S)Log file report:

******************* 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 Environemnt() at 60:
End of reset_dut() method
Normal[NOTE] on Environemnt() at 60:
Start of cfg_dut() method
Normal[NOTE] on Environemnt() at 90:
Port 0 Address 00
Normal[NOTE] on Environemnt() at 110:
Port 1 Address 11
Normal[NOTE] on Environemnt() at 130:
Port 2 Address 22
Normal[NOTE] on Environemnt() at 150:
Port 3 Address 33
Normal[NOTE] on Environemnt() at 170:
End of cfg_dut() method
Normal[NOTE] on Environemnt() at 170:
Start of start() method
Normal[NOTE] on Environemnt() at 170:
End of start() method
Normal[NOTE] on Environemnt() at 170:
Start of wait_for_end() method
Normal[NOTE] on Environemnt() at 10170:
End of wait_for_end() method
Normal[NOTE] on Environemnt() at 10170:
Start of stop() method
Normal[NOTE] on Environemnt() at 10170:
End of stop() method
Normal[NOTE] on Environemnt() at 10170:
Start of cleanup() method
Normal[NOTE] on Environemnt() at 10170:
End of cleanup() method
Normal[NOTE] on Environemnt() at 10170:
Start of report() method



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



Normal[NOTE] on Environemnt() at 10170:
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