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

Subversion Repositories zap

[/] [zap/] [trunk/] [src/] [testbench/] [External_IP/] [uart16550/] [rtl/] [uart_tfifo.v] - Blame information for rev 43

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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