Code Browser Pages:
| //////////////////////////////////////////////// ////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) this.rcvr2sb_chan = new("rcvr2sb_channel","chan",10); 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); $display(" size 0 ****",bytes.size); `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 |