In this phase we will see the scoreboard implementation.
Scoreboard has 2 mailboxes. One is used to for getting the packets from the driver and other from the receiver. Then the packets are compared and if they don't match, then error is asserted.
Scoreboard in implemented in file Scoreboard.sv.
1) Declare 2 mailboxes drvr2sb and rcvr2sb.
mailbox drvr2sb;
mailbox rcvr2sb;
2) Declare a constructor method with "drvr2sb" and "rcvr2sb" mailboxes as arguments.
function new(mailbox drvr2sb,mailbox rcvr2sb);
3) Connect the mailboxes of the constructor to the mail boxes of the scoreboard.
this.drvr2sb = drvr2sb;
this.rcvr2sb = rcvr2sb;
4) Define a start method.
Do the following steps forever.
Wait until there is a packet is in "rcvr2sb". Then pop the packet from the mail box.
rcvr2sb.get(pkt_rcv);
$display(" %0d : Scorebooard : Scoreboard received a packet from receiver ",$time);
Then pop the packet from drvr2sb.
drvr2sb.get(pkt_exp);
Compare both packets and increment an error counter if they are not equal.
task start();
packet pkt_rcv,pkt_exp;
forever begin rcvr2sb.get(pkt_rcv);
$display(" %0d : Scorebooard : Scoreboard received a packet from receiver ",$time);
drvr2sb.get(pkt_exp);
if(pkt_rcv.compare(pkt_exp))
$display(" %0d : Scoreboardd :Packet Matched ",$time);
else $root.error++;
end endtask : start
endclass
`endif
Now we will see how to connect the scoreboard in the Environment class.
1) Declare a scoreboard.
Scoreboard sb;
2) Construct the scoreboard in the build method. Pass the drvr2sb and rcvr2sb mailboxes to the score board constructor.
sb = new(drvr2sb,rcvr2sb);
3) Start the scoreboard method in the start method.
sb.start();
4) Now we are to the end of building the verification environment.
In the report() method of environment class, print the TEST PASS or TEST FAIL status based on the error count.
task report();
$display("\n\n*************************************************");
if( 0 == $root.error)
$display("******** TEST PASSED *********");
else $display("******** TEST Failed with %0d errors *********",$root.error);