OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [FIFOs/] [CummingsSNUG2002SJ_FIFO1/] [rptr_empty.v] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// --------------------------------------------------------------------
2
//
3
 
4
 
5
module
6
  rptr_empty
7
  #(
8
    parameter ADDRSIZE = 4
9
  )
10
  (
11
    output reg                  rempty,
12
    output      [ADDRSIZE-1:0]  raddr,
13
    output reg  [ADDRSIZE :0]   rptr,
14
    input       [ADDRSIZE :0]   rq2_wptr,
15
    input                       rinc,
16
    input                       rclk,
17
    input                       rrst_n
18
  );
19
 
20
  reg [ADDRSIZE:0] rbin;
21
  wire [ADDRSIZE:0] rgraynext, rbinnext;
22
 
23
  //-------------------
24
  // GRAYSTYLE2 pointer
25
  //-------------------
26
  always @(posedge rclk or negedge rrst_n)
27
    if(!rrst_n)
28
      {rbin, rptr} <= 0;
29
    else
30
      {rbin, rptr} <= {rbinnext, rgraynext};
31
 
32
  // Memory read-address pointer (okay to use binary to address memory)
33
  assign raddr = rbin[ADDRSIZE-1:0];
34
  assign rbinnext = rbin + (rinc & ~rempty);
35
  assign rgraynext = (rbinnext>>1) ^ rbinnext;
36
 
37
  //---------------------------------------------------------------
38
  // FIFO empty when the next rptr == synchronized wptr or on reset
39
  //---------------------------------------------------------------
40
  assign rempty_val = (rgraynext == rq2_wptr);
41
 
42
  always @(posedge rclk or negedge rrst_n)
43
    if(!rrst_n)
44
      rempty <= 1'b1;
45
    else
46
      rempty <= rempty_val;
47
 
48
endmodule
49
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.