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

Subversion Repositories dma_axi

[/] [dma_axi/] [trunk/] [src/] [dma_axi64/] [prgen_fifo.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 eyalhoc
//---------------------------------------------------------
2
//-- File generated by RobustVerilog parser
3
//-- Version: 1.0
4
//-- Invoked Fri Mar 25 23:36:54 2011
5
//--
6
//-- Source file: prgen_fifo.v
7
//---------------------------------------------------------
8
 
9
 
10
 
11
module prgen_fifo(clk,reset,push,pop,din,dout,empty,full);
12
 
13
   parameter                  WIDTH      = 8;
14
   parameter                  DEPTH_FULL = 8;
15
 
16
   parameter               SINGLE     = DEPTH_FULL == 1;
17
   parameter               DEPTH      = SINGLE ? 1 : DEPTH_FULL -1;
18
   parameter               DEPTH_BITS =
19
                  (DEPTH <= 2)   ? 1 :
20
                  (DEPTH <= 4)   ? 2 :
21
                  (DEPTH <= 8)   ? 3 :
22
                  (DEPTH <= 16)  ? 4 :
23
                  (DEPTH <= 32)  ? 5 :
24
                  (DEPTH <= 64)  ? 6 :
25
                  (DEPTH <= 128) ? 7 :
26
                  (DEPTH <= 256) ? 8 : 0; //0 is ilegal
27
 
28
   parameter               LAST_LINE  = DEPTH-1;
29
 
30
 
31
 
32
   input                      clk;
33
   input                      reset;
34
 
35
   input               push;
36
   input               pop;
37
   input [WIDTH-1:0]           din;
38
   output [WIDTH-1:0]           dout;
39
   //output               next;
40
   output               empty;
41
   output               full;
42
 
43
 
44
   wire               reg_push;
45
   wire               reg_pop;
46
   wire               fifo_push;
47
   wire               fifo_pop;
48
 
49
   reg [DEPTH-1:0]           fullness_in;
50
   reg [DEPTH-1:0]           fullness_out;
51
   reg [DEPTH-1:0]           fullness;
52
   reg [WIDTH-1:0]           fifo [DEPTH-1:0];
53
   wire               fifo_empty;
54
   wire               next;
55
   reg [WIDTH-1:0]           dout;
56
   reg                   dout_empty;
57
   reg [DEPTH_BITS-1:0]       ptr_in;
58
   reg [DEPTH_BITS-1:0]       ptr_out;
59
 
60
 
61
 
62
 
63
   assign               reg_push  = push & fifo_empty & (dout_empty | pop);
64
   assign               reg_pop   = pop & fifo_empty;
65
   assign               fifo_push = !SINGLE & push & (~reg_push);
66
   assign               fifo_pop  = !SINGLE & pop & (~reg_pop);
67
 
68
 
69
   always @(posedge clk or posedge reset)
70
     if (reset)
71
       begin
72
      dout       <= #1 {WIDTH{1'b0}};
73
      dout_empty <= #1 1'b1;
74
       end
75
     else if (reg_push)
76
       begin
77
      dout       <= #1 din;
78
      dout_empty <= #1 1'b0;
79
       end
80
     else if (reg_pop)
81
       begin
82
      dout       <= #1 {WIDTH{1'b0}};
83
      dout_empty <= #1 1'b1;
84
       end
85
     else if (fifo_pop)
86
       begin
87
      dout       <= #1 fifo[ptr_out];
88
      dout_empty <= #1 1'b0;
89
       end
90
 
91
   always @(posedge clk or posedge reset)
92
     if (reset)
93
       ptr_in <= #1 {DEPTH_BITS{1'b0}};
94
     else if (fifo_push)
95
       ptr_in <= #1 ptr_in == LAST_LINE ? 0 : ptr_in + 1'b1;
96
 
97
   always @(posedge clk or posedge reset)
98
     if (reset)
99
       ptr_out <= #1 {DEPTH_BITS{1'b0}};
100
     else if (fifo_pop)
101
       ptr_out <= #1 ptr_out == LAST_LINE ? 0 : ptr_out + 1'b1;
102
 
103
   always @(posedge clk)
104
     if (fifo_push)
105
       fifo[ptr_in] <= #1 din;
106
 
107
 
108
   always @(/*AUTOSENSE*/fifo_push or ptr_in)
109
     begin
110
    fullness_in = {DEPTH{1'b0}};
111
    fullness_in[ptr_in] = fifo_push;
112
     end
113
 
114
   always @(/*AUTOSENSE*/fifo_pop or ptr_out)
115
     begin
116
    fullness_out = {DEPTH{1'b0}};
117
    fullness_out[ptr_out] = fifo_pop;
118
     end
119
 
120
   always @(posedge clk or posedge reset)
121
     if (reset)
122
       fullness <= #1 {DEPTH{1'b0}};
123
     else if (fifo_push | fifo_pop)
124
       fullness <= #1 (fullness & (~fullness_out)) | fullness_in;
125
 
126
 
127
   assign next       = |fullness;
128
   assign fifo_empty = ~next;
129
   assign empty      = fifo_empty & dout_empty;
130
   assign full       = SINGLE ? !dout_empty : &fullness;
131
 
132
 
133
 
134
 
135
endmodule
136
 
137
 
138
 
139
 

powered by: WebSVN 2.1.0

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