A layered testbench architecture for FIFO

Hi, I am looking for assistance on the randomization of the input variables of FIFO.

In reply to abhishekk_07:
Lots of options, but one approach is to

  1. Define a transaction class that defines the variables that need to be randomized, along with their constraints.
  2. In the driver class, you randomize the instance of that transaction class and based on the randomized transaction (e,g, push, pop, idle) to call the needed task.
    For example:

package fifo_pkg;
  timeunit 1ns; timeprecision 100ps;
  `define TOP fifo_tb
  typedef enum {PUSH, POP, PUSH_POP, IDLE, RESET} fifo_scen_e;
.../////////////////////////////////////////////////////////////
class Fifo_xactn extends ....;
  rand fifo_scen_e kind;
  rand word_t  data;	// data to push
  rand bit [7:0] idle_cycles;
  rand bit [7:0] reset_cycles;
  time xactn_time;
    
  constraint cst_data {
      data  < 1024;
  }
 constraint cst_idle {
   idle_cycles inside {[1:3]}; 
  }  
 constraint cst_reset {
   reset_cycles inside {[1:10]}; 
  }  

  constraint cst_xact_kind {
    kind dist {
      PUSH := 400,
      POP := 300,
      PUSH_POP :=200,
      IDLE := 30, 
      RESET := 10
    };
  } // cst_xact_kind
...///////////////////////////////////////////////
//////////////////////////////////////////////////
task Fifo_cmd_xactor();
    Fifo_xactn  fifo_xactn_0;  // transaction to get 
    randomize(fifo_xactn_0); 
    case (fifo_xactn_0.kind)
        PUSH :
        begin
          this.push_task(fifo_xactn_0.data);
        end
        POP  :
        begin
         this.pop_task(); 
        end
        PUSH_POP :
        begin
         this.push_pop_task(fifo_xactn_0.data);
        end
        IDLE :
        begin
          this.idle_task(fifo_xactn_0.idle_cycles);
        end
        RESET :
          this.reset_task(fifo_xactn_0.reset_cycles); 
      endcase
.../////////////////////////
/////////////////////////////
 task Fifo_cmd_xactor::push_task (word_t data);
    f_if.driver_cb.data_in <= data;
    f_if.driver_cb.push <= 1'b1;
    f_if.driver_cb.pop  <= 1'b0;
    @ ( f_if.driver_cb);
    f_if.driver_cb.push <= 1'b0;
  endtask : push_task 

  task Fifo_cmd_xactor::pop_task;
    f_if.driver_cb.pop  <= 1'b1;
    f_if.driver_cb.push <= 1'b0;        
    @ ( f_if.driver_cb);
    f_if.driver_cb.pop  <= 1'b0;
  endtask : pop_task

  task Fifo_cmd_xactor::push_pop_task (word_t data);
    f_if.driver_cb.data_in <= data;
    f_if.driver_cb.push <= 1'b1;
    f_if.driver_cb.pop  <= 1'b1;
    @ ( f_if.driver_cb);
    f_if.driver_cb.push <= 1'b0;
    f_if.driver_cb.pop  <= 1'b0;       
  endtask : push_pop_task 
.../////////////////////////

There are of course variations to this.
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr

  • SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
  • A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
  • Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
  • Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712
  • Component Design by Example ", 2001 ISBN 0-9705394-0-1
  • VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
  • VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115

  1. SVA Alternative for Complex Assertions
    Verification Horizons - March 2018 Issue | Verification Academy
  2. SVA: Package for dynamic and range delays and repeats | Verification Academy
  3. SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy
  4. FREE BOOK: Component Design by Example … A Step-by-Step Process Using VHDL with UART as Vehicle | Verification Academy