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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [rtl/] [verilog/] [buffers/] [sd_fifo_head_b.v] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ghutchis
//----------------------------------------------------------------------
2
// Srdy/Drdy FIFO Head "B"
3
//
4
// Building block for FIFOs.  The "B" (big) FIFO is design for larger FIFOs
5
// based around memories, with sizes that may not be a power of 2.
6
//
7
// The bound inputs allow multiple FIFO controllers to share a single
8
// memory.  The enable input is for arbitration between multiple FIFO
9
// controllers, or between the fifo head and tail controllers on a
10
// single port memory.
11
//
12
// The commit parameter enables write/commit behavior.  This creates
13
// two write pointers, one which is used for writing to memory and
14
// a commit pointer which is sent to the tail block.
15
//
16
// Naming convention: c = consumer, p = producer, i = internal interface
17
//----------------------------------------------------------------------
18
// Author: Guy Hutchison
19
//
20
// This block is uncopyrighted and released into the public domain.
21
//----------------------------------------------------------------------
22
 
23
// delay unit for nonblocking assigns, default is to #1
24
`ifndef SDLIB_DELAY
25
 `define SDLIB_DELAY #1
26
`endif
27
 
28
module sd_fifo_head_b
29
  #(parameter depth=16,
30
    parameter commit=0,
31
    parameter asz=$clog2(depth)
32
  )
33
  (
34
   input       clk,
35
   input       reset,
36
   input       enable,
37
   input       c_commit,
38
   input       c_abort,  // should be asserted when c_srdy == 0
39
   input       c_srdy,
40
   output      c_drdy,
41
 
42
   input [asz-1:0]  bound_low,
43
   input [asz-1:0]  bound_high,
44
 
45
   input [asz-1:0]      rdptr,
46
   output reg [asz-1:0] cur_wrptr,
47
   output reg [asz-1:0] com_wrptr,
48
   output reg         mem_we
49
   );
50
 
51
  reg [asz-1:0]       nxt_wrptr;
52
  reg [asz-1:0]       wrptr_p1;
53
  reg                   empty;
54
  reg                   full, nxt_full;
55
  reg [asz-1:0]         nxt_com_wrptr;
56
 
57
  assign                c_drdy = !full & enable;
58
 
59
  always @*
60
    begin
61
      if (cur_wrptr[asz-1:0] == bound_high)
62
        begin
63
          wrptr_p1[asz-1:0] = bound_low;
64
        end
65
      else
66
        wrptr_p1 = cur_wrptr + 1;
67
 
68
      empty = (cur_wrptr == rdptr) & !full;
69 13 ghutchis
      nxt_full = ((wrptr_p1 == rdptr) | (full & (cur_wrptr == rdptr)));
70 2 ghutchis
 
71
      if ((commit == 1) && c_abort)
72
        begin
73
          nxt_wrptr = com_wrptr;
74
        end
75
      else if (enable & c_srdy & !full)
76
        begin
77
          nxt_wrptr = wrptr_p1;
78
          mem_we = 1;
79
        end
80
      else
81
        begin
82
          nxt_wrptr = cur_wrptr;
83
          mem_we = 0;
84
        end
85
    end
86
 
87
  always @(posedge clk)
88
    begin
89
      if (reset)
90
        begin
91
          cur_wrptr <= `SDLIB_DELAY bound_low;
92
          full  <= `SDLIB_DELAY 0;
93
        end
94
      else
95
        begin
96
          cur_wrptr <= `SDLIB_DELAY nxt_wrptr;
97
          full  <= `SDLIB_DELAY nxt_full;
98
        end // else: !if(reset)
99
    end // always @ (posedge clk)
100
 
101 6 ghutchis
  generate
102
    if (commit)
103 2 ghutchis
      begin
104 6 ghutchis
        always @*
105
          begin
106
            if (enable & c_commit & !c_abort & c_srdy & !full)
107
              nxt_com_wrptr = wrptr_p1;
108
            else
109
              nxt_com_wrptr = com_wrptr;
110
          end
111 2 ghutchis
 
112 6 ghutchis
        always @(posedge clk)
113
          begin
114
            if (reset)
115
              com_wrptr <= `SDLIB_DELAY bound_low;
116
            else
117
              com_wrptr <= `SDLIB_DELAY nxt_com_wrptr;
118
          end
119
      end // if (commit)
120
    else
121 2 ghutchis
      begin
122 6 ghutchis
        always @*
123
          com_wrptr = cur_wrptr;
124 2 ghutchis
      end
125
  endgenerate
126
 
127
endmodule // fifo_head
128
 

powered by: WebSVN 2.1.0

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