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


Tutorials



DRIVER

Take an instance of packet
Define task to generate the packet and call the drive task.
This task first, calls randomize task in the packet then calls the pack to packing the packet.
Calls the drive packet wich drives the packet to dut. Then add the sent packet to score board.

CODE:driver.v

module driver(clock,packet_valid,data,busy); 
output          packet_valid;
output    [7:0] data;
input         busy;
input clock;
reg  packet_valid;
reg  [7:0] data;

integer delay;
// Take an instance of packet
pktgen gen();
//Define task to generate the packet and call the drive task
task gen_and_drive(input integer no_of_pkts);
integer i;
begin

 for(i=0;i<no_of_pkts;i=i+1)
       begin
         delay={$random()}%4;
$display("DRIVER gen and drive pkt_no = %d delay %d",i,delay);
          repeat (delay)@(negedge clock);
// randomize the packet
         gen.randomize();
//pack the packet
         gen.packing();
// call the drive packet task.
         @(negedge clock);
         drive_packet();
// add the sent packet to score board
         top.tb.sb.add_pkt(i);

       end
end 
endtask



task    drive_packet() ;
integer i;
begin
$display("DRIVER Starting to drive packet to port %0d len %0d ",gen.Da,gen.len);
repeat(4)@(negedge clock);
for (i=0;i<gen.len+4;i=i+1)
begin
@ (negedge clock);

packet_valid = 1 ;
data[7:0] = gen.pkt[i];
$display("[DRIVER] data %b at i %d",gen.pkt[i],i);

end
@ (negedge clock);
packet_valid = 0 ;
@(negedge clock);
end
endtask

endmodule



Index
Dut Specification
Rtl
Top
Packet
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