Asynchronous fifo verification

Can anyone explain me how to generate checkers for asynchronous fifo . And tell me some clue codes to generate those . what i want is

  1. fifo empty output signal is generated when queue size becomes 0.
  2. fifo full output signal is generated when queue size becomes 32.

I presume that you have a fifo that looks like https://goo.gl/mubUbA
For verification, I am assuming that you keep track of the queue using and external verification queue. Below is code that does that, using write enbable(wenb), read enable (renb), read and write clocks.


import uvm_pkg::*; `include "uvm_macros.svh" 
module asyncq; 
	bit rempty, wfull;
	bit rclk, wclk, renb, wenb; 
	int fifoQ [$]; // queue,
	int wdata, rdata;
	int qsize; 
	initial forever #10 wclk=!wclk;  
	initial forever #13 rclk=!rclk;
	// 1. fifo empty output signal is generated when queue size becomes 0.
    // 2. fifo full output signal is generated when queue size becomes 32.
	
	ap_mt:   assert property(@(posedge rclk) fifoQ.size==0 |-> rempty); 
	ap_full: assert property(@(posedge wclk) fifoQ.size==32 |-> wfull); 
	assign qsize =fifoQ.size; 
	always @ (posedge wclk)  
		if(wenb) fifoQ.push_back(wdata); 
		
    always @ (posedge rclk)  
    	if(renb) rdata<= fifoQ.pop_front(); 

	initial begin 
     repeat(200) begin 
       @(posedge wclk);   
       if (!randomize(wenb, wdata)  with 
           { wenb dist {1'b1:=1, 1'b0:=3};})
       	          `uvm_error("MYERR", "This is a randomize error")
       end 
    end 
    
     initial begin 
     repeat(200) begin 
       @(posedge rclk);   
       if (!randomize(renb)  with 
           { renb dist {1'b1:=1, 1'b0:=5};})
       	          `uvm_error("MYERR", "This is a randomize error")
       end 
       $finish; 
    end 
endmodule 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us

  • SystemVerilog Assertions Handbook 3rd Edition, 2013 ISBN 878-0-9705394-3-6
  • 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 0-9705394-2-8
  • 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