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


Tutorials



DRIVER




Driver is a tranctor. It is extension of rvm_xactor. Get the packets from gen2drv_chan chennel and drive them on to dut interface. Put the packets in to drv2sb_chan channel.


CODE:driver.vr
#ifndef DRVR_CLASS
#define DRVR_CLASS
//Transactors shall be implemented in classes derived from the rvm_xactor

class drvr_xtor extends rvm_xactor{
packet_channel gen2drv_chan;
packet_channel drv2sb_chan;
packet pkt,drv_pkt;
string msg;


task new(string inst = "class",
integer stream_id = -1,
packet_channel gen2drv_chan = null,
packet_channel drv2sb_chan = null);

virtual task main_t();
virtual task drive(packet pkt);

}

task drvr_xtor::new(string inst,integer stream_id ,
packet_channel gen2drv_chan ,
packet_channel drv2sb_chan ){
super.new("driver",inst,stream_id);

if(gen2drv_chan == null)
this.gen2drv_chan = new("gen2drv_channel","chan",10);
else
this.gen2drv_chan = gen2drv_chan;

if(drv2sb_chan == null)
this.drv2sb_chan = new("drv2sb_channel","chan",10);
else
this.drv2sb_chan = drv2sb_chan;

rvm_note(log,"Driver created \n");
}

//All threads shall be started in the extension of the rvm_xactor::main_t() method
//Extensions of the rvm_xactor::main_t() method shall fork a call to super.main_t()

task drvr_xtor::main_t(){
super.main_t();
rvm_note(this.log," STARTED main task ");
while(1){

//wait_if_stopped_or_empty(this.gen2drv_chan);
pkt = this.gen2drv_chan.get_t();
sprintf(this.msg,"pkt da %x pkt sa %x pkt len %d \n",pkt.da,pkt.sa,pkt.len);
rvm_note(this.log,msg);
if (!cast_assign(drv_pkt, pkt.copy()))
rvm_fatal(this.log, "Attempting to copy to a non Packet instance");
drive(drv_pkt);
@(posedge intf.clk);
this.drv2sb_chan.sneak(drv_pkt);

}
}

task drvr_xtor::drive(packet pkt){
bit [7:0] pack_pkt[*];
integer pkt_len,i;
pkt_len = pkt.byte_pack(pack_pkt,0,0);
sprintf(this.msg,"Packed packet length %d \n",pkt_len);
rvm_note(this.log,this.msg);
@(posedge intf.clk);
for (i=0;i< pkt_len - 1;i++)
{
@(posedge intf.clk);
intf.data_status <= 1 ;
intf.data_in <= pack_pkt[i];
}
@(posedge intf.clk);
intf.data_status <= 0 ;
intf.data_in <= 0;
@(posedge intf.clk);
}

#endif

Index
Introduction
Rtl
Top
Interface
Program Block
Environment
Packet
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