Code Browser Pages:
Files in
vmm_switch_7.tar



Driver.sv
Environment.sv
filelist
Globals.sv
interface.sv
Packet.sv
README.txt
Current file: Receiver.sv
rtl.sv
testcase.sv
top.sv



////////////////////////////////////////////////
////s~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~s////
////s           www.testbench.in           s////
////s                                      s////
////s             VMM Tutorial             s////
////s           gopi@testbench.in          s////
////s~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~s////
////////////////////////////////////////////////
`ifndef GUARD_RECEIVER
`define GUARD_RECEIVER

class Receiver extends vmm_xactor;

virtual output_interface.OP output_intf;
Packet_channel rcvr2sb_chan;

function new(string inst = "class",
             int unsigned stream_id = -1,
             virtual output_interface.OP  output_intf_new,
             Packet_channel rcvr2sb_chan);

   super.new("Receiver",inst,stream_id);

   this.output_intf    = output_intf_new  ;

   if(rcvr2sb_chan == null)
        `vmm_fatal(log,"rcvr2sb_channel is null");
   else
        this.rcvr2sb_chan = rcvr2sb_chan;

   `vmm_note(log,"Receiver created ");

endfunction : new


task main();
logic [7:0] bytes[];
Packet pkt;

    super.main();
    `vmm_note(this.log," started main task ");

     forever
     begin
         repeat(2) @(posedge output_intf.clock);
         wait(output_intf.cb.ready)
         output_intf.cb.read <= 1;
         repeat(2) @(posedge output_intf.clock);

         while (output_intf.cb.ready)
         begin
               bytes = new[bytes.size + 1](bytes);
               bytes[bytes.size - 1] = output_intf.cb.data_out;
              @(posedge output_intf.clock);
         end

         bytes[bytes.size - 1] = output_intf.cb.data_out;
         output_intf.cb.read <= 0;
         @(posedge output_intf.clock);
         `vmm_note(this.log,"Received a packet ");
         pkt = new();
         pkt.byte_unpack(bytes);
         pkt.display("rcvr");

         rcvr2sb_chan.put(pkt);

         bytes.delete();
     end
endtask : main

endclass

`endif