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


Tutorials



RECIEVER




Receiver receives the packet and unpacks the packet and sends the unpacked packet to scoreboard.

Reciver is a class. Declare a port . ports allows the reciver to communicate to dut. Take four instancess of the reciver.


CODE:receiver.vr

class receiver{
static integer id;
cfg_drvr cfg;
rec_ports ports;
// declare packet to store received packet
packet rcv_packet;
rand integer rcv_delay;
integer port_num;

constraint rev_dela {rcv_delay in {1:5} ;}

task new (cfg_drvr cfg,rec_ports ports){
this.ports = ports;
this.cfg = cfg;
id = 0;
void = this.randomize();
printf("[RECIVER] created reciver object\n ");
}

// Define a task to collect data and unpack
task collect_packets(){
// Define queue of byte that will hold the received bytes
bit [7:0] temp;
integer i;
bit [7:0] received_bytes[$] ;
while(1) {

@(posedge ports.$ready);
rcv_delay = random() % 10;
repeat (rcv_delay)@(posedge intf.clk);

while (ports.$ready) {

ports.$read = 1;

@(posedge intf.clk);
received_bytes.push_back(ports.$data_out);
printf("[RECIVER] chanel valid 0 data %x num %d\n ",ports.$data_out,received_bytes.size());
}
ports.$read = 0;



repeat (1)@(posedge intf.clk);
rcv_packet=new(id,cfg);
id++;
printf("[RECIVER]pkt id is %d size is %d\n",id,received_bytes.size());
//void = received_bytes.pop_front();
//unpack the recived data
rcv_packet.byte_unpack(received_bytes);
//as queues are used,delete it
received_bytes.delete();

// call the scoreboard task to check the packets
score_board.checkpacket(rcv_packet);
}
}
}
Index
Dut Specification
Rtl
Top
Interface
Packet
Packet Generator
Cfg Driver
Driver
Reciever
Scoreboard
Env

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