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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [Projects/] [opencores.org/] [wishbone/] [ip/] [wb_uart16550/] [rtl/] [verilog/] [tfifo] - Blame information for rev 131

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  uart_tfifo.v                                                ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the "UART 16550 compatible" project    ////
7
////  http://www.opencores.org/cores/uart16550/                   ////
8
////                                                              ////
9
////  Documentation related to this project:                      ////
10
////  - http://www.opencores.org/cores/uart16550/                 ////
11
////                                                              ////
12
////  Projects compatibility:                                     ////
13
////  - WISHBONE                                                  ////
14
////  RS232 Protocol                                              ////
15
////  16550D uart (mostly supported)                              ////
16
////                                                              ////
17
////  Overview (main Features):                                   ////
18
////  UART core transmitter FIFO                                  ////
19
////                                                              ////
20
////  To Do:                                                      ////
21
////  Nothing.                                                    ////
22
////                                                              ////
23
////  Author(s):                                                  ////
24
////      - gorban@opencores.org                                  ////
25
////      - Jacob Gorban                                          ////
26
////      - Igor Mohor (igorm@opencores.org)                      ////
27
////                                                              ////
28
////  Created:        2001/05/12                                  ////
29
////  Last Updated:   2002/07/22                                  ////
30
////                  (See log for the revision history)          ////
31
////                                                              ////
32
////                                                              ////
33
//////////////////////////////////////////////////////////////////////
34
////                                                              ////
35
//// Copyright (C) 2000, 2001 Authors                             ////
36
////                                                              ////
37
//// This source file may be used and distributed without         ////
38
//// restriction provided that this copyright statement is not    ////
39
//// removed from the file and that any derivative work contains  ////
40
//// the original copyright notice and the associated disclaimer. ////
41
////                                                              ////
42
//// This source file is free software; you can redistribute it   ////
43
//// and/or modify it under the terms of the GNU Lesser General   ////
44
//// Public License as published by the Free Software Foundation; ////
45
//// either version 2.1 of the License, or (at your option) any   ////
46
//// later version.                                               ////
47
////                                                              ////
48
//// This source is distributed in the hope that it will be       ////
49
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
50
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
51
//// PURPOSE.  See the GNU Lesser General Public License for more ////
52
//// details.                                                     ////
53
////                                                              ////
54
//// You should have received a copy of the GNU Lesser General    ////
55
//// Public License along with this source; if not, download it   ////
56
//// from http://www.opencores.org/lgpl.shtml                     ////
57
////                                                              ////
58
//////////////////////////////////////////////////////////////////////
59
//
60
// CVS Revision History
61
//
62
// $Log: not supported by cvs2svn $
63
// Revision 1.1  2002/07/22 23:02:23  gorban
64
// Bug Fixes:
65
//  * Possible loss of sync and bad reception of stop bit on slow baud rates fixed.
66
//   Problem reported by Kenny.Tung.
67
//  * Bad (or lack of ) loopback handling fixed. Reported by Cherry Withers.
68
//
69
// Improvements:
70
//  * Made FIFO's as general inferrable memory where possible.
71
//  So on FPGA they should be inferred as RAM (Distributed RAM on Xilinx).
72
//  This saves about 1/3 of the Slice count and reduces P&R and synthesis times.
73
//
74
//
75
// Revision 1.16  2001/12/20 13:25:46  mohor
76
// rx push changed to be only one cycle wide.
77
//
78
// Revision 1.15  2001/12/18 09:01:07  mohor
79
// Bug that was entered in the last update fixed (rx state machine).
80
//
81
// Revision 1.14  2001/12/17 14:46:48  mohor
82
// overrun signal was moved to separate block because many sequential lsr
83
// reads were preventing data from being written to rx fifo.
84
// underrun signal was not used and was removed from the project.
85
//
86
// Revision 1.13  2001/11/26 21:38:54  gorban
87
// Lots of fixes:
88
// Break condition wasn't handled correctly at all.
89
// LSR bits could lose their values.
90
// LSR value after reset was wrong.
91
// Timing of THRE interrupt signal corrected.
92
// LSR bit 0 timing corrected.
93
//
94
// Revision 1.12  2001/11/08 14:54:23  mohor
95
// Comments in Slovene language deleted, few small fixes for better work of
96
// old tools. IRQs need to be fix.
97
//
98
// Revision 1.11  2001/11/07 17:51:52  gorban
99
// Heavily rewritten interrupt and LSR subsystems.
100
// Many bugs hopefully squashed.
101
//
102
// Revision 1.10  2001/10/20 09:58:40  gorban
103
// Small synopsis fixes
104
//
105
// Revision 1.9  2001/08/24 21:01:12  mohor
106
// Things connected to parity changed.
107
// Clock devider changed.
108
//
109
// Revision 1.8  2001/08/24 08:48:10  mohor
110
// FIFO was not cleared after the data was read bug fixed.
111
//
112
// Revision 1.7  2001/08/23 16:05:05  mohor
113
// Stop bit bug fixed.
114
// Parity bug fixed.
115
// WISHBONE read cycle bug fixed,
116
// OE indicator (Overrun Error) bug fixed.
117
// PE indicator (Parity Error) bug fixed.
118
// Register read bug fixed.
119
//
120
// Revision 1.3  2001/05/31 20:08:01  gorban
121
// FIFO changes and other corrections.
122
//
123
// Revision 1.3  2001/05/27 17:37:48  gorban
124
// Fixed many bugs. Updated spec. Changed FIFO files structure. See CHANGES.txt file.
125
//
126
// Revision 1.2  2001/05/17 18:34:18  gorban
127
// First 'stable' release. Should be sythesizable now. Also added new header.
128
//
129
// Revision 1.0  2001-05-17 21:27:12+02  jacob
130
// Initial revision
131
//
132
//
133
 
134
 
135
 
136
module `VARIANT`TFIFO  (clk,
137
        wb_rst_i, data_in, data_out,
138
// Control signals
139
        push, // push strobe, active high
140
        pop,   // pop strobe, active high
141
// status signals
142
        overrun,
143
        count,
144
        fifo_reset,
145
        reset_status
146
        );
147
 
148
 
149
// FIFO parameters
150
parameter fifo_width = `UART_FIFO_WIDTH;
151
parameter fifo_depth = `UART_FIFO_DEPTH;
152
parameter fifo_pointer_w = `UART_FIFO_POINTER_W;
153
parameter fifo_counter_w = `UART_FIFO_COUNTER_W;
154
 
155
input                           clk;
156
input                           wb_rst_i;
157
input                           push;
158
input                           pop;
159
input   [fifo_width-1:0]        data_in;
160
input                           fifo_reset;
161
input       reset_status;
162
 
163
output  [fifo_width-1:0]        data_out;
164
output                          overrun;
165
output  [fifo_counter_w-1:0]    count;
166
 
167
wire    [fifo_width-1:0]        data_out;
168
 
169
// FIFO pointers
170
reg     [fifo_pointer_w-1:0]    top;
171
reg     [fifo_pointer_w-1:0]    bottom;
172
 
173
reg     [fifo_counter_w-1:0]    count;
174
reg                             overrun;
175
wire [fifo_pointer_w-1:0] top_plus_1 = top + 4'd1;
176
 
177
`VARIANT`RAMINFR
178
  #( .addr_width  ( fifo_pointer_w ),
179
     .data_width  ( fifo_width     ),
180
     .depth       ( fifo_depth     )
181
     ) tfifo (
182
     .clk      ( clk      ),
183
     .we       ( push     ),
184
     .a        ( top      ),
185
     .dpra     ( bottom   ),
186
     .di       ( data_in  ),
187
     .dpo      ( data_out )
188
     );
189
 
190
 
191
always @(posedge clk ) // synchronous FIFO
192
begin
193
        if (wb_rst_i)
194
        begin
195
                top             <=  0;
196
                bottom          <=  0;
197
                count           <=  0;
198
        end
199
        else
200
        if (fifo_reset) begin
201
                top             <=  0;
202
                bottom          <=  0;
203
                count           <=  0;
204
        end
205
  else
206
        begin
207
                case ({push, pop})
208
                2'b10 : if (count
209
                        begin
210
                                top       <=  top_plus_1;
211
                                count     <=  count + 5'd1;
212
                        end
213
                2'b01 : if(count>0)
214
                        begin
215
                                bottom   <=  bottom + 4'd1;
216
                                count    <=  count - 5'd1;
217
                        end
218
                2'b11 : begin
219
                                bottom   <=  bottom + 4'd1;
220
                                top       <=  top_plus_1;
221
                        end
222
    default: ;
223
                endcase
224
        end
225
end   // always
226
 
227
always @(posedge clk ) // synchronous FIFO
228
begin
229
  if (wb_rst_i)
230
    overrun   <=  1'b0;
231
  else
232
  if(fifo_reset | reset_status)
233
    overrun   <=  1'b0;
234
  else
235
  if(push & (count==fifo_depth))
236
    overrun   <=  1'b1;
237
end   // always
238
 
239
endmodule

powered by: WebSVN 2.1.0

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