In this phase, we will write a receiver and use the receiver in environment class to collect the packets coming from the switch output_interface.
Receiver collects the data bytes from the interface signal. And then unpacks the bytes in to packet and pushes it into channel for score boarding.
Receiver class is written in Reveicer.sv file.
1) Extend vmm_xactor and define Receiver class.
class Receiver extends vmm_xactor;
1) Declare a virtual output_interface. We will connect this to the Physical interface of the top module, same as what we did in environment class.
virtual output_interface.OP output_intf;
2) Declare a channel "rcvr2sb_chan" which is used to send the packets to the score board
Packet_channel rcvr2sb_chan;
3) Define new constructor with arguments, virtual input interface and a channel which is used to send packets from the receiver to scoreboard. Implement the restof the logic as it was done in the driver constructor.
if(rcvr2sb_chan == null)
`vmm_fatal(log,"rcvr2sb_channel is null");
else this.rcvr2sb_chan = rcvr2sb_chan;
`vmm_note(log,"Receiver created ");
endfunction : new
4) Define the main() method.
In start method, do the following
First call the super.main() method.
Then start a thread which collects the data from the outputinterface and then unpack the data to a packet and put into channel.
Now we will take the instance of the receiver in the environment class.
1) Declare a channel "rcvr2sb_chan" which will be used to connect the scoreboard and receiver.
Packet_channel rcvr2sb_chan;
2) Declare 4 receiver object "rcvr".
Receiver rcvr[4];
3) In build method, construct the rcvr2sb_chan.
rcvr2sb_chan = new("rcvr2sb","chan");
4) In build method, construct the receiver object. Pass the output_intf and rcvr2sb_chan. There are 4 output interfaces and receiver objects. We will connect one receiver for one output interface.
(S)Run the command: vcs -sverilog -f filelist -R -ntb_opts rvm
(S)Log file report.
******************* Start of testcase **************** Normal[NOTE] on Environemnt() at 0: Created env object Normal[NOTE] on Environemnt() at 0: Start of gen_cfg() method Normal[NOTE] on Environemnt() at 0: End of gen_cfg() method Normal[NOTE] on Environemnt() at 0: Start of build() method Normal[NOTE] on driver(Drvr) at 0: Driver created Normal[NOTE] on Receiver(Rcvr-0) at 0: Receiver created Normal[NOTE] on Receiver(Rcvr-1) at 0: Receiver created Normal[NOTE] on Receiver(Rcvr-2) at 0: Receiver created Normal[NOTE] on Receiver(Rcvr-3) at 0: Receiver created Normal[NOTE] on Environemnt() at 0: End of build() method Normal[NOTE] on Environemnt() at 0: Start of reset_dut() method Normal[NOTE] on Environemnt() at 60: End of reset_dut() method Normal[NOTE] on Environemnt() at 60: Start of cfg_dut() method Normal[NOTE] on Environemnt() at 90: Port 0 Address 00 Normal[NOTE] on Environemnt() at 110: Port 1 Address 11 Normal[NOTE] on Environemnt() at 130: Port 2 Address 22 Normal[NOTE] on Environemnt() at 150: Port 3 Address 33 Normal[NOTE] on Environemnt() at 170: End of cfg_dut() method Normal[NOTE] on Environemnt() at 170: Start of start() method Normal[NOTE] on Environemnt() at 170: End of start() method Normal[NOTE] on Environemnt() at 170: Start of wait_for_end() method Normal[NOTE] on driver(Drvr) at 170: started main task Normal[NOTE] on Receiver(Rcvr-0) at 170: started main task Normal[NOTE] on Receiver(Rcvr-1) at 170: started main task Normal[NOTE] on Receiver(Rcvr-2) at 170: started main task Normal[NOTE] on Receiver(Rcvr-3) at 170: started main task Normal[NOTE] on Receiver(Rcvr-0) at 470: Received a packet rcvr packet #0.0.0 rcvr da:0x00 rcvr sa:0xac rcvr length:0x05 (data.size=4) rcvr data[0]:0xcb data[1]:0x7e data[2]:0x52 data[3]:0xa4 rcvr fcs:0x29
Normal[NOTE] on Receiver(Rcvr-1) at 710: Received a packet rcvr packet #0.0.0 rcvr da:0x11 rcvr sa:0xf3 rcvr length:0x06 (data.size=5) rcvr data[0]:0xc4 data[1]:0xd5 .... data[3]:0xf3 data[4]:0x88 rcvr fcs:0x5b
Normal[NOTE] on Receiver(Rcvr-3) at 890: Received a packet rcvr packet #0.0.0 rcvr da:0x33 rcvr sa:0x6b rcvr length:0x03 (data.size=2) rcvr data[0]:0x32 data[1]:0x27 rcvr fcs:0x1c
Normal[NOTE] on Environemnt() at 10170: End of wait_for_end() method Normal[NOTE] on Environemnt() at 10170: Start of stop() method Normal[NOTE] on Environemnt() at 10170: End of stop() method Normal[NOTE] on Environemnt() at 10170: Start of cleanup() method Normal[NOTE] on Environemnt() at 10170: End of cleanup() method Normal[NOTE] on Environemnt() at 10170: Start of report() method --------------------------------------------------------------------- Simulation PASSED on /./ (/./) at 10170 (0 warnings, 0 demoted errors & 0 demoted warnings) ---------------------------------------------------------------------
Normal[NOTE] on Environemnt() at 10170: End of report() method ******************** End of testcase *****************