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


Tutorials



PHASE 7 SCOREBOARD


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.

   if(pkt_rcv.compare(pkt_exp)) 
    $display(" %0d : Scoreboardd :Packet Matched ",$time);
    else
      $root.error++;

Scoreboard Class Source Code:

`ifndef GUARD_SCOREBOARD
`define GUARD_SCOREBOARD

class Scoreboard;

mailbox drvr2sb;
mailbox rcvr2sb;

function new(mailbox drvr2sb,mailbox rcvr2sb);
  this.drvr2sb = drvr2sb;
  this.rcvr2sb = rcvr2sb;
endfunction:new


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);
  
   $display("*************************************************\n\n");
endtask : report


Source Code Of The Environment Class:

`ifndef GUARD_ENV
`define GUARD_ENV

class Environment ;


  virtual mem_interface.MEM    mem_intf       ;
  virtual input_interface.IP  input_intf     ;
  virtual output_interface.OP output_intf[4] ;
  
  Driver drvr;
  Receiver rcvr[4];

  Scoreboard sb;

  mailbox drvr2sb ;
  mailbox rcvr2sb ;

function new(virtual mem_interface.MEM    mem_intf_new       ,
             virtual input_interface.IP  input_intf_new     ,
             virtual output_interface.OP output_intf_new[4] );

  this.mem_intf      = mem_intf_new    ;
  this.input_intf    = input_intf_new  ;
  this.output_intf   = output_intf_new ;

  $display(" %0d : Environment  : created env object",$time);
endfunction : new

function void build();
   $display(" %0d : Environment  : start of build() method",$time);
   drvr2sb = new();
   rcvr2sb = new();

   sb = new(drvr2sb,rcvr2sb);

   drvr= new(input_intf,drvr2sb);
   foreach(rcvr[i])
     rcvr[i]= new(output_intf[i],rcvr2sb);
   $display(" %0d : Environment  : end of build() method",$time);
endfunction : build

task reset();
  $display(" %0d : Environment  : start of reset() method",$time);
  // Drive all DUT inputs to a known state
  mem_intf.cb.mem_data      <= 0;
  mem_intf.cb.mem_add       <= 0;
  mem_intf.cb.mem_en        <= 0;
  mem_intf.cb.mem_rd_wr     <= 0;
  input_intf.cb.data_in     <= 0;
  input_intf.cb.data_status <= 0;
  output_intf[0].cb.read    <= 0;
  output_intf[1].cb.read    <= 0;
  output_intf[2].cb.read    <= 0;
  output_intf[3].cb.read    <= 0;
  
  // Reset the DUT
  input_intf.reset       <= 1;
  repeat (4) @ input_intf.clock;
  input_intf.reset       <= 0;
  
  $display(" %0d : Environment  : end of reset() method",$time);
endtask : reset
  
task cfg_dut();
  $display(" %0d : Environment  : start of cfg_dut() method",$time);
  
  mem_intf.cb.mem_en <= 1;
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_rd_wr <= 1;
  
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_add  <= 8'h0;
  mem_intf.cb.mem_data <= `P0;
  $display(" %0d : Environment  : Port 0 Address %h ",$time,`P0);
  
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_add  <= 8'h1;
  mem_intf.cb.mem_data <= `P1;
  $display(" %0d : Environment  : Port 1 Address %h ",$time,`P1);
  
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_add  <= 8'h2;
  mem_intf.cb.mem_data <= `P2;
  $display(" %0d : Environment  : Port 2 Address %h ",$time,`P2);
  
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_add  <= 8'h3;
  mem_intf.cb.mem_data <= `P3;
  $display(" %0d : Environment  : Port 3 Address %h ",$time,`P3);
  
  @(posedge mem_intf.clock);
  mem_intf.cb.mem_en    <=0;
  mem_intf.cb.mem_rd_wr <= 0;
  mem_intf.cb.mem_add   <= 0;
  mem_intf.cb.mem_data  <= 0;
  
  
  $display(" %0d : Environment  : end of cfg_dut() method",$time);
endtask :cfg_dut

task start();
  $display(" %0d : Environment  : start of start() method",$time);
  fork
    drvr.start();
    rcvr[0].start();
    rcvr[1].start();
    rcvr[2].start();
    rcvr[3].start();

    sb.start();

  join_any
  $display(" %0d : Environment  : end of start() method",$time);
endtask : start

task wait_for_end();
   $display(" %0d : Environment  : start of wait_for_end() method",$time);
   repeat(10000) @(input_intf.clock);
   $display(" %0d : Environment  : end of wait_for_end() method",$time);
endtask : wait_for_end

task run();
   $display(" %0d : Environment  : start of run() method",$time);
   build();
   reset();
   cfg_dut();
   start();
   wait_for_end();
   report();
   $display(" %0d : Environment  : end of run() method",$time);
endtask: run  
  
task report();

   $display("\n\n*************************************************");
   if( 0 == $root.error)
       $display("********            TEST PASSED         *********");
   else
       $display("********    TEST Failed with %0d errors *********",$root.error);
  
   $display("*************************************************\n\n");

endtask : report

endclass
`endif


Download the phase 7 score code:

switch_7.tar
Browse the code in switch_7.tar

Run the simulation:
vcs -sverilog -f filelist -R -ntb_opts dtm


Index
Introduction
Specification
Verification Plan
Phase 1 Top
Phase 2 Environment
Phase 3 Reset
Phase 4 Packet
Phase 5 Driver
Phase 6 Receiver
Phase 7 Scoreboard
Phase 8 Coverage
Phase 9 Testcase

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