how to generate a queue for checking asynchronous fifo

Status
Not open for further replies.

sai685

Junior Member level 2
Joined
Sep 4, 2015
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
292
Actually for asychronous fifo if i want to compare the expected result with the produced result i need a queue . so i want to transfer the first input of my data_in into queue and later i compare the data_out and queue. so that it become first checker.
i want a code for that.

system verilog or if possible i want it in verilog
 
Last edited by a moderator:

tell me whether this code is perfect for checking the asynchronous fifo by storing the value of data_in into a queue .


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
task queue;
  reg[31:0] tail;
  reg[31:0] head;
  reg[31:0] count;
      reg[31:0] fifomem[31:0]; 
  reg[31:0] data_out;
  #5
      @(posedge wr_clk)
  begin
    if (reset_w == 0) 
  data_out = 32'h0000;
  
else 
  data_out = fifomem[tail];
end
// Update FIFO memory.
#5
      @(posedge wr_clk) 
  begin
    if (reset_w == 1'b1 && write == 1'b1 )
  fifomem[head] = data_in;
// Update the head register.
//
    @(posedge wr_clk) 
    begin
      if (reset_w == 1'b0) 
head = 2'b00;
 
else if (write == 1'b1 && wr_full ==1'b0) begin
// WRITE
head = head + 1;
 
end
end
// Update the tail register.
//
    @(posedge rd_clk) 
    begin
    if (reset_r == 1'b0) 
      begin
tail = 32'b00;
end
else if (read ==1'b1 && rd_empty== 1'b0)
  begin
// READ
tail = tail + 1;
end
end
 
// Update the count regsiter.
 
      @(posedge wr_clk ) 
    begin
      if (reset_w ) 
    begin
      count = 0; end
      else if(count!=32 & write)
begin
count=count +1;
end 
  else 
begin
    count=count;
  end
    end
      //READ
      @(posedge rd_clk)
     begin
      if(reset_r)
 begin
        count=32;
 end 
       else if (count!=0 && read)
begin
         count=count-1;
end
// Concurrent read and write.. no change in count
  else
begin
    count = count;
 end
    end
  
 
 
// *** Update the flags
//
// First, update the empty flag.
//
   @(count) 
    begin
     if (count == 0)
force rd_empty = 1'b1;
else   
force rd_empty = 1'b0;
end
// Update the full flag
//
  @(count) 
    begin
   if (count == 32)
force wr_full = 1'b1;
else
force wr_full = 1'b0;
end 
  end    
     endtask
   initial 
  begin
  queue;
    $display("data_out=%d,wr_full=%d,rd_empty",data_out,wr_full,rd_empty);
  end

 
Last edited by a moderator:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…