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


Tutorials



DRIVER


Driver is a tranctor. It is extension of avm_verification_component. Get the packets from gen2drv chennel and drive them on to dut interface. Put the packets in to drv2sb channel.

CODE:driver.sv

class driver extends avm_verification_component;

  virtual switch_if intf;
  string msg;
  packet pkt;
  Configuration cfg;
  
  
  tlm_blocking_get_if#(packet) get_port;
  tlm_blocking_put_if#(packet) put_sb;

  function new(string nm,Configuration cfg);
      this.cfg = cfg;
      
    super.new(nm);
  endfunction

  function void connect;
  
  endfunction

  task run;

  
  reset_dut();
  cfg_dut();
  forever
        begin
          get_port.get(pkt);
          $display("consumer: sendging %s packet\n", pkt.convert2string);
          drive(pkt);
          avm_report_message("Driver","Puting packet to score board");
          put_sb.put(pkt);
          @(negedge intf.clock);

        end
  
  endtask


task drive(packet pkt);
logic [7:0] pack[];
int pkt_len;
pkt_len = pkt.byte_pack(pack,0,0);
$swrite(this.msg,"Packed packet length %d \n",pkt_len);
avm_report_message("Driver",this.msg);
@(negedge intf.clock);
for (int i=0;i< pkt_len - 1;i++)
begin
@(negedge intf.clock);
intf.data_status <= 1 ;
intf.data_in <= pack[i];
end
@(negedge intf.clock);
intf.data_status <= 0 ;
intf.data_in <= pack[pkt_len -1];
@(negedge intf.clock);
endtask 

task reset_dut();
 avm_report_message("reset_dut"," Starting... reset_dut \n");
  @(negedge intf.clock);
 avm_report_message("reset_dut"," Starting... reset_dut \n");
  intf.data_status  <= 0;
  intf.data_in      <= 0;
  intf.read         <= 0;
  intf.mem_data     <= 0;
  intf.mem_add      <= 0;
  intf.reset        <= 0;
  intf.mem_en       <= 0;
  intf.mem_rd_wr    <= 0; 
  @(negedge intf.clock);
  #2 intf.reset     <= 1;
  @(negedge intf.clock);
  #2 intf.reset     <= 0;
  @(negedge intf.clock);
  @(negedge intf.clock);
 avm_report_message("reset_dut"," Ending...  reset_dut \n");
endtask

task cfg_dut() ;
 avm_report_message("cfg_dut"," Starting... cfg_dut \n");
 for(int i = 0;i<4 ;i++)
 begin
 intf.mem_en    <= 1;
 @(negedge intf.clock);
 intf.mem_rd_wr <= 1;
 @(negedge intf.clock);
 intf.mem_add   <= i;
 intf.mem_data  <= cfg.da_port[i];
 end
 @(negedge intf.clock);
  intf.mem_en    <= 0;
  intf.mem_rd_wr <= 0;
  intf.mem_add   <= 0;
  intf.mem_data  <= 0;

 avm_report_message("cfg_dut"," Ending...  cfg_dut \n");

endtask
endclass 


Index
Avm Introduction
Dut Specification
Rtl
Top
Interface
Environment
Packet
Packet Generator
Configuration
Driver
Reciever
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