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

Subversion Repositories uart16550

[/] [uart16550/] [trunk/] [rtl/] [verilog/] [uart_top.v] - Blame information for rev 65

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

Line No. Rev Author Line
1 27 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  uart_top.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 top level.                                        ////
19
////                                                              ////
20
////  Known problems (limits):                                    ////
21
////  Note that transmitter and receiver instances are inside     ////
22
////  the uart_regs.v file.                                       ////
23
////                                                              ////
24
////  To Do:                                                      ////
25
////  Nothing so far.                                             ////
26
////                                                              ////
27
////  Author(s):                                                  ////
28
////      - gorban@opencores.org                                  ////
29
////      - Jacob Gorban                                          ////
30 29 mohor
////      - Igor Mohor (igorm@opencores.org)                      ////
31 27 mohor
////                                                              ////
32
////  Created:        2001/05/12                                  ////
33
////  Last Updated:   2001/05/17                                  ////
34
////                  (See log for the revision history)          ////
35
////                                                              ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
////                                                              ////
39 29 mohor
//// Copyright (C) 2000, 2001 Authors                             ////
40 27 mohor
////                                                              ////
41
//// This source file may be used and distributed without         ////
42
//// restriction provided that this copyright statement is not    ////
43
//// removed from the file and that any derivative work contains  ////
44
//// the original copyright notice and the associated disclaimer. ////
45
////                                                              ////
46
//// This source file is free software; you can redistribute it   ////
47
//// and/or modify it under the terms of the GNU Lesser General   ////
48
//// Public License as published by the Free Software Foundation; ////
49
//// either version 2.1 of the License, or (at your option) any   ////
50
//// later version.                                               ////
51
////                                                              ////
52
//// This source is distributed in the hope that it will be       ////
53
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
54
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
55
//// PURPOSE.  See the GNU Lesser General Public License for more ////
56
//// details.                                                     ////
57
////                                                              ////
58
//// You should have received a copy of the GNU Lesser General    ////
59
//// Public License along with this source; if not, download it   ////
60
//// from http://www.opencores.org/lgpl.shtml                     ////
61
////                                                              ////
62
//////////////////////////////////////////////////////////////////////
63
//
64
// CVS Revision History
65
//
66
// $Log: not supported by cvs2svn $
67 65 mohor
// Revision 1.16  2001/12/06 14:51:04  gorban
68
// Bug in LSR[0] is fixed.
69
// All WISHBONE signals are now sampled, so another wait-state is introduced on all transfers.
70
//
71 50 gorban
// Revision 1.15  2001/12/03 21:44:29  gorban
72
// Updated specification documentation.
73
// Added full 32-bit data bus interface, now as default.
74
// Address is 5-bit wide in 32-bit data bus mode.
75
// Added wb_sel_i input to the core. It's used in the 32-bit mode.
76
// Added debug interface with two 32-bit read-only registers in 32-bit mode.
77
// Bits 5 and 6 of LSR are now only cleared on TX FIFO write.
78
// My small test bench is modified to work with 32-bit mode.
79
//
80 48 gorban
// Revision 1.14  2001/11/07 17:51:52  gorban
81
// Heavily rewritten interrupt and LSR subsystems.
82
// Many bugs hopefully squashed.
83
//
84 37 gorban
// Revision 1.13  2001/10/20 09:58:40  gorban
85
// Small synopsis fixes
86
//
87 33 gorban
// Revision 1.12  2001/08/25 15:46:19  gorban
88
// Modified port names again
89
//
90 30 gorban
// Revision 1.11  2001/08/24 21:01:12  mohor
91
// Things connected to parity changed.
92
// Clock devider changed.
93
//
94 29 mohor
// Revision 1.10  2001/08/23 16:05:05  mohor
95
// Stop bit bug fixed.
96
// Parity bug fixed.
97
// WISHBONE read cycle bug fixed,
98
// OE indicator (Overrun Error) bug fixed.
99
// PE indicator (Parity Error) bug fixed.
100
// Register read bug fixed.
101
//
102 27 mohor
// Revision 1.4  2001/05/31 20:08:01  gorban
103
// FIFO changes and other corrections.
104
//
105
// Revision 1.3  2001/05/21 19:12:02  gorban
106
// Corrected some Linter messages.
107
//
108
// Revision 1.2  2001/05/17 18:34:18  gorban
109
// First 'stable' release. Should be sythesizable now. Also added new header.
110
//
111
// Revision 1.0  2001-05-17 21:27:12+02  jacob
112
// Initial revision
113
//
114
//
115 33 gorban
// synopsys translate_off
116
`include "timescale.v"
117
// synopsys translate_on
118 27 mohor
 
119
`include "uart_defines.v"
120
 
121
module uart_top (
122 30 gorban
        wb_clk_i,
123 27 mohor
 
124
        // Wishbone signals
125 48 gorban
        wb_rst_i, wb_adr_i, wb_dat_i, wb_dat_o, wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_sel_i,
126 27 mohor
        int_o, // interrupt request
127
 
128
        // UART signals
129
        // serial input/output
130
        stx_pad_o, srx_pad_i,
131
 
132
        // modem signals
133
        rts_pad_o, cts_pad_i, dtr_pad_o, dsr_pad_i, ri_pad_i, dcd_pad_i
134
 
135
        );
136
 
137 48 gorban
parameter                                                        uart_data_width = `UART_DATA_WIDTH;
138 27 mohor
parameter                                                        uart_addr_width = `UART_ADDR_WIDTH;
139
 
140 30 gorban
input                                                            wb_clk_i;
141 27 mohor
 
142
// WISHBONE interface
143
input                                                            wb_rst_i;
144 30 gorban
input [uart_addr_width-1:0]       wb_adr_i;
145 27 mohor
input [uart_data_width-1:0]       wb_dat_i;
146
output [uart_data_width-1:0]      wb_dat_o;
147
input                                                            wb_we_i;
148
input                                                            wb_stb_i;
149
input                                                            wb_cyc_i;
150 48 gorban
input [3:0]                                                       wb_sel_i;
151 27 mohor
output                                                           wb_ack_o;
152
output                                                           int_o;
153
 
154
// UART signals
155
input                                                            srx_pad_i;
156
output                                                           stx_pad_o;
157
output                                                           rts_pad_o;
158
input                                                            cts_pad_i;
159
output                                                           dtr_pad_o;
160
input                                                            dsr_pad_i;
161
input                                                            ri_pad_i;
162
input                                                            dcd_pad_i;
163
 
164
wire                                                                     stx_pad_o;
165
wire                                                                     rts_pad_o;
166
wire                                                                     dtr_pad_o;
167
 
168 30 gorban
wire [uart_addr_width-1:0]        wb_adr_i;
169 27 mohor
wire [uart_data_width-1:0]        wb_dat_i;
170
wire [uart_data_width-1:0]        wb_dat_o;
171
 
172 48 gorban
wire [7:0]                                                        wb_dat8_i; // 8-bit internal data input
173
wire [7:0]                                                        wb_dat8_o; // 8-bit internal data output
174
wire [31:0]                                               wb_dat32_o; // debug interface 32-bit output
175
wire [3:0]                                                        wb_sel_i;  // WISHBONE select signal
176 50 gorban
wire [uart_addr_width-1:0]        wb_adr_int;
177 27 mohor
wire                                                                     we_o;  // Write enable for registers
178 48 gorban
wire                                 re_o;      // Read enable for registers
179 27 mohor
//
180
// MODULE INSTANCES
181
//
182
 
183 48 gorban
`ifdef DATA_BUS_WIDTH_8
184
`else
185
// debug interface wires
186
wire    [3:0] ier;
187
wire    [3:0] iir;
188
wire    [1:0] fcr;
189
wire    [4:0] mcr;
190
wire    [7:0] lcr;
191
wire    [7:0] msr;
192
wire    [7:0] lsr;
193
wire    [`UART_FIFO_COUNTER_W-1:0] rf_count;
194
wire    [`UART_FIFO_COUNTER_W-1:0] tf_count;
195
wire    [2:0] tstate;
196
wire    [3:0] rstate;
197
`endif
198
 
199
`ifdef DATA_BUS_WIDTH_8
200 27 mohor
////  WISHBONE interface module
201
uart_wb         wb_interface(
202 30 gorban
                .clk(           wb_clk_i                ),
203 27 mohor
                .wb_rst_i(      wb_rst_i        ),
204 48 gorban
        .wb_dat_i(wb_dat_i),
205
        .wb_dat_o(wb_dat_o),
206
        .wb_dat8_i(wb_dat8_i),
207
        .wb_dat8_o(wb_dat8_o),
208
         .wb_dat32_o(32'b0),
209
         .wb_sel_i(4'b0),
210 27 mohor
                .wb_we_i(       wb_we_i         ),
211
                .wb_stb_i(      wb_stb_i        ),
212
                .wb_cyc_i(      wb_cyc_i        ),
213
                .wb_ack_o(      wb_ack_o        ),
214 50 gorban
        .wb_adr_i(wb_adr_i),
215
        .wb_adr_int(wb_adr_int),
216 27 mohor
                .we_o(          we_o            ),
217
                .re_o(re_o)
218
                );
219 48 gorban
`else // !`ifdef DATA_BUS_WIDTH_8
220
uart_wb         wb_interface(
221
                .clk(           wb_clk_i                ),
222
                .wb_rst_i(      wb_rst_i        ),
223
        .wb_dat_i(wb_dat_i),
224
        .wb_dat_o(wb_dat_o),
225
        .wb_dat8_i(wb_dat8_i),
226
        .wb_dat8_o(wb_dat8_o),
227
         .wb_sel_i(wb_sel_i),
228
         .wb_dat32_o(wb_dat32_o),
229
                .wb_we_i(       wb_we_i         ),
230
                .wb_stb_i(      wb_stb_i        ),
231
                .wb_cyc_i(      wb_cyc_i        ),
232
                .wb_ack_o(      wb_ack_o        ),
233 50 gorban
        .wb_adr_i(wb_adr_i),
234
        .wb_adr_int(wb_adr_int),
235 48 gorban
                .we_o(          we_o            ),
236
                .re_o(re_o)
237
                );
238
`endif // !`ifdef DATA_BUS_WIDTH_8
239 27 mohor
 
240
// Registers
241
uart_regs       regs(
242 37 gorban
        .clk(           wb_clk_i                ),
243
        .wb_rst_i(      wb_rst_i        ),
244 50 gorban
        .wb_addr_i(     wb_adr_int      ),
245 48 gorban
        .wb_dat_i(      wb_dat8_i       ),
246
        .wb_dat_o(      wb_dat8_o       ),
247 37 gorban
        .wb_we_i(       we_o            ),
248
   .wb_re_i(re_o),
249
        .modem_inputs(  {cts_pad_i, dsr_pad_i,
250
        ri_pad_i,  dcd_pad_i}   ),
251
        .stx_pad_o(             stx_pad_o               ),
252
        .srx_pad_i(             srx_pad_i               ),
253 48 gorban
`ifdef DATA_BUS_WIDTH_8
254
`else
255
// debug interface signals      enabled
256
.ier(ier),
257
.iir(iir),
258
.fcr(fcr),
259
.mcr(mcr),
260
.lcr(lcr),
261
.msr(msr),
262
.lsr(lsr),
263
.rf_count(rf_count),
264
.tf_count(tf_count),
265
.tstate(tstate),
266
.rstate(rstate),
267
`endif
268 37 gorban
        .rts_pad_o(             rts_pad_o               ),
269
        .dtr_pad_o(             dtr_pad_o               ),
270
        .int_o(         int_o           )
271
);
272 27 mohor
 
273 48 gorban
`ifdef DATA_BUS_WIDTH_8
274
`else
275
uart_debug_if dbg(/*AUTOINST*/
276
                                                // Outputs
277
                                                .wb_dat32_o                              (wb_dat32_o[31:0]),
278
                                                // Inputs
279 50 gorban
                                                .wb_adr_i                                (wb_adr_int[`UART_ADDR_WIDTH-1:0]),
280 48 gorban
                                                .ier                                             (ier[3:0]),
281
                                                .iir                                             (iir[3:0]),
282
                                                .fcr                                             (fcr[1:0]),
283
                                                .mcr                                             (mcr[4:0]),
284
                                                .lcr                                             (lcr[7:0]),
285
                                                .msr                                             (msr[7:0]),
286
                                                .lsr                                             (lsr[7:0]),
287
                                                .rf_count                                (rf_count[`UART_FIFO_COUNTER_W-1:0]),
288
                                                .tf_count                                (tf_count[`UART_FIFO_COUNTER_W-1:0]),
289
                                                .tstate                                  (tstate[2:0]),
290
                                                .rstate                                  (rstate[3:0]));
291
`endif //  `ifdef DATA_BUS_WIDTH_8
292
 
293 27 mohor
endmodule
294 48 gorban
 
295
 

powered by: WebSVN 2.1.0

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