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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [uart16550/] [uart16550.v] - Blame information for rev 469

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

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
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
////      - Igor Mohor (igorm@opencores.org)                      ////
31
////                                                              ////
32
////  Created:        2001/05/12                                  ////
33
////  Last Updated:   2001/05/17                                  ////
34
////                  (See log for the revision history)          ////
35
////                                                              ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
////                                                              ////
39
//// Copyright (C) 2000, 2001 Authors                             ////
40
////                                                              ////
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 360 julius
// $Log: not supported by cvs2svn $
67 6 julius
// Revision 1.18  2002/07/22 23:02:23  gorban
68
// Bug Fixes:
69
//  * Possible loss of sync and bad reception of stop bit on slow baud rates fixed.
70
//   Problem reported by Kenny.Tung.
71
//  * Bad (or lack of ) loopback handling fixed. Reported by Cherry Withers.
72
//
73
// Improvements:
74
//  * Made FIFO's as general inferrable memory where possible.
75
//  So on FPGA they should be inferred as RAM (Distributed RAM on Xilinx).
76
//  This saves about 1/3 of the Slice count and reduces P&R and synthesis times.
77
//
78
//  * Added optional baudrate output (baud_o).
79
//  This is identical to BAUDOUT* signal on 16550 chip.
80
//  It outputs 16xbit_clock_rate - the divided clock.
81
//  It's disabled by default. Define UART_HAS_BAUDRATE_OUTPUT to use.
82
//
83
// Revision 1.17  2001/12/19 08:40:03  mohor
84
// Warnings fixed (unused signals removed).
85
//
86
// Revision 1.16  2001/12/06 14:51:04  gorban
87
// Bug in LSR[0] is fixed.
88
// All WISHBONE signals are now sampled, so another wait-state is introduced on all transfers.
89
//
90
// Revision 1.15  2001/12/03 21:44:29  gorban
91
// Updated specification documentation.
92
// Added full 32-bit data bus interface, now as default.
93
// Address is 5-bit wide in 32-bit data bus mode.
94
// Added wb_sel_i input to the core. It's used in the 32-bit mode.
95
// Added debug interface with two 32-bit read-only registers in 32-bit mode.
96
// Bits 5 and 6 of LSR are now only cleared on TX FIFO write.
97
// My small test bench is modified to work with 32-bit mode.
98
//
99
// Revision 1.14  2001/11/07 17:51:52  gorban
100
// Heavily rewritten interrupt and LSR subsystems.
101
// Many bugs hopefully squashed.
102
//
103
// Revision 1.13  2001/10/20 09:58:40  gorban
104
// Small synopsis fixes
105
//
106
// Revision 1.12  2001/08/25 15:46:19  gorban
107
// Modified port names again
108
//
109
// Revision 1.11  2001/08/24 21:01:12  mohor
110
// Things connected to parity changed.
111
// Clock devider changed.
112
//
113
// Revision 1.10  2001/08/23 16:05:05  mohor
114
// Stop bit bug fixed.
115
// Parity bug fixed.
116
// WISHBONE read cycle bug fixed,
117
// OE indicator (Overrun Error) bug fixed.
118
// PE indicator (Parity Error) bug fixed.
119
// Register read bug fixed.
120
//
121
// Revision 1.4  2001/05/31 20:08:01  gorban
122
// FIFO changes and other corrections.
123
//
124
// Revision 1.3  2001/05/21 19:12:02  gorban
125
// Corrected some Linter messages.
126
//
127
// Revision 1.2  2001/05/17 18:34:18  gorban
128
// First 'stable' release. Should be sythesizable now. Also added new header.
129
//
130
// Revision 1.0  2001-05-17 21:27:12+02  jacob
131
// Initial revision
132
//
133
//
134
// synopsys translate_off
135
`include "timescale.v"
136
// synopsys translate_on
137
 
138
`include "uart_defines.v"
139
 
140 360 julius
//module uart_top       (
141
module uart16550( // renamed by Julius
142
                  wb_clk_i,
143 44 julius
 
144 360 julius
                  // Wishbone signals
145
                  wb_rst_i, wb_adr_i, wb_dat_i, wb_we_i, wb_dat_o,
146
`ifndef DATA_BUS_WIDTH_8
147
                  wb_sel_i,
148
`endif
149
                  wb_stb_i, wb_cyc_i, wb_ack_o,
150
                  int_o, // interrupt request
151 6 julius
 
152 360 julius
                  // UART       signals
153
                  // serial input/output
154
                  stx_pad_o, srx_pad_i,
155 6 julius
 
156 360 julius
                  // modem signals
157
                  rts_pad_o, cts_pad_i, dtr_pad_o, dsr_pad_i, ri_pad_i,
158
                  dcd_pad_i
159 6 julius
`ifdef UART_HAS_BAUDRATE_OUTPUT
160 360 julius
                  , baud_o
161 6 julius
`endif
162 360 julius
                  );
163 6 julius
 
164 360 julius
   parameter uart_data_width = `UART_DATA_WIDTH;
165
   parameter uart_addr_width = `UART_ADDR_WIDTH;
166 6 julius
 
167 360 julius
   input  wb_clk_i;
168 6 julius
 
169 44 julius
   // WISHBONE interface
170 360 julius
   input  wb_rst_i;
171
   input [uart_addr_width-1:0] wb_adr_i;
172
   input [uart_data_width-1:0] wb_dat_i;
173
   output [uart_data_width-1:0] wb_dat_o;
174
   input                        wb_we_i;
175
   input                        wb_stb_i;
176
   input                        wb_cyc_i;
177
`ifndef DATA_BUS_WIDTH_8
178
   input [3:0]                   wb_sel_i;
179
`endif
180
   output                       wb_ack_o;
181
   output                       int_o;
182 6 julius
 
183 44 julius
   // UART      signals
184 360 julius
   input                        srx_pad_i;
185
   output                       stx_pad_o;
186
   output                       rts_pad_o;
187
   input                        cts_pad_i;
188
   output                       dtr_pad_o;
189
   input                        dsr_pad_i;
190
   input                        ri_pad_i;
191
   input                        dcd_pad_i;
192 6 julius
 
193 44 julius
   // optional baudrate output
194 6 julius
`ifdef UART_HAS_BAUDRATE_OUTPUT
195 360 julius
   output                       baud_o;
196 6 julius
`endif
197
 
198
 
199 360 julius
   wire                         stx_pad_o;
200
   wire                         rts_pad_o;
201
   wire                         dtr_pad_o;
202 6 julius
 
203 360 julius
   wire [uart_addr_width-1:0]    wb_adr_i;
204
   wire [uart_data_width-1:0]    wb_dat_i;
205
   wire [uart_data_width-1:0]    wb_dat_o;
206 6 julius
 
207 360 julius
   wire [7:0]                    wb_dat8_i; // 8-bit internal data input
208
   wire [7:0]                    wb_dat8_o; // 8-bit internal data output
209
   wire [31:0]                   wb_dat32_o; // debug interface 32-bit output
210
   wire [3:0]                    wb_sel_i;  // WISHBONE select signal
211
   wire [uart_addr_width-1:0]    wb_adr_int;
212
   wire                         we_o;   // Write enable for registers
213
   wire                         re_o;   // Read enable for registers
214 44 julius
   //
215
   // MODULE INSTANCES
216
   //
217 6 julius
 
218
`ifdef DATA_BUS_WIDTH_8
219
`else
220 44 julius
   // debug interface wires
221 360 julius
   wire [3:0]                    ier;
222
   wire [3:0]                    iir;
223
   wire [1:0]                    fcr;
224
   wire [4:0]                    mcr;
225
   wire [7:0]                    lcr;
226
   wire [7:0]                    msr;
227
   wire [7:0]                    lsr;
228
   wire [`UART_FIFO_COUNTER_W-1:0] rf_count;
229
   wire [`UART_FIFO_COUNTER_W-1:0] tf_count;
230
   wire [2:0]                       tstate;
231
   wire [3:0]                       rstate;
232 6 julius
`endif
233
 
234
`ifdef DATA_BUS_WIDTH_8
235 44 julius
   ////  WISHBONE interface module
236 360 julius
   uart_wb wb_interface
237
     (
238
      .clk(             wb_clk_i                ),
239
      .wb_rst_i(        wb_rst_i        ),
240
      .wb_dat_i(wb_dat_i),
241
      .wb_dat_o(wb_dat_o),
242
      .wb_dat8_i(wb_dat8_i),
243
      .wb_dat8_o(wb_dat8_o),
244
      .wb_dat32_o(32'b0),
245
      .wb_sel_i(4'b0),
246
      .wb_we_i( wb_we_i         ),
247
      .wb_stb_i(        wb_stb_i        ),
248
      .wb_cyc_i(        wb_cyc_i        ),
249
      .wb_ack_o(        wb_ack_o        ),
250
      .wb_adr_i(wb_adr_i),
251
      .wb_adr_int(wb_adr_int),
252
      .we_o(            we_o            ),
253
      .re_o(re_o)
254
      );
255 6 julius
`else
256 360 julius
   uart_wb wb_interface
257
     (
258
      .clk(             wb_clk_i                ),
259
      .wb_rst_i(        wb_rst_i        ),
260
      .wb_dat_i(wb_dat_i),
261
      .wb_dat_o(wb_dat_o),
262
      .wb_dat8_i(wb_dat8_i),
263
      .wb_dat8_o(wb_dat8_o),
264
      .wb_sel_i(wb_sel_i),
265
      .wb_dat32_o(wb_dat32_o),
266
      .wb_we_i( wb_we_i         ),
267
      .wb_stb_i(        wb_stb_i        ),
268
      .wb_cyc_i(        wb_cyc_i        ),
269
      .wb_ack_o(        wb_ack_o        ),
270
      .wb_adr_i(wb_adr_i),
271
      .wb_adr_int(wb_adr_int),
272
      .we_o(            we_o            ),
273
      .re_o(re_o)
274
      );
275 6 julius
`endif
276
 
277 44 julius
   // Registers
278 360 julius
   uart_regs regs
279
     (
280
      .clk(             wb_clk_i                ),
281
      .wb_rst_i(        wb_rst_i        ),
282
      .wb_addr_i(       wb_adr_int      ),
283
      .wb_dat_i(        wb_dat8_i       ),
284
      .wb_dat_o(        wb_dat8_o       ),
285
      .wb_we_i( we_o            ),
286
      .wb_re_i(re_o),
287
      .modem_inputs(    {cts_pad_i, dsr_pad_i,
288
                         ri_pad_i,  dcd_pad_i}  ),
289
      .stx_pad_o(               stx_pad_o               ),
290
      .srx_pad_i(               srx_pad_i               ),
291 6 julius
`ifdef DATA_BUS_WIDTH_8
292
`else
293 360 julius
      // debug interface signals        enabled
294
      .ier(ier),
295
      .iir(iir),
296
      .fcr(fcr),
297
      .mcr(mcr),
298
      .lcr(lcr),
299
      .msr(msr),
300
      .lsr(lsr),
301
      .rf_count(rf_count),
302
      .tf_count(tf_count),
303
      .tstate(tstate),
304
      .rstate(rstate),
305 6 julius
`endif
306 360 julius
      .rts_pad_o(               rts_pad_o               ),
307
      .dtr_pad_o(               dtr_pad_o               ),
308
      .int_o(           int_o           )
309 6 julius
`ifdef UART_HAS_BAUDRATE_OUTPUT
310 360 julius
      , .baud_o(baud_o)
311 6 julius
`endif
312
 
313 360 julius
      );
314 6 julius
 
315
`ifdef DATA_BUS_WIDTH_8
316
`else
317 360 julius
   uart_debug_if dbg
318
     (
319
      // Outputs
320
      .wb_dat32_o                                (wb_dat32_o[31:0]),
321
      // Inputs
322
      .wb_adr_i                          (wb_adr_int[`UART_ADDR_WIDTH-1:0]),
323
      .ier                                               (ier[3:0]),
324
      .iir                                               (iir[3:0]),
325
      .fcr                                               (fcr[1:0]),
326
      .mcr                                               (mcr[4:0]),
327
      .lcr                                               (lcr[7:0]),
328
      .msr                                               (msr[7:0]),
329
      .lsr                                               (lsr[7:0]),
330
      .rf_count                          (rf_count[`UART_FIFO_COUNTER_W-1:0]),
331
      .tf_count                          (tf_count[`UART_FIFO_COUNTER_W-1:0]),
332
      .tstate                                    (tstate[2:0]),
333
      .rstate                                    (rstate[3:0]));
334 6 julius
`endif
335
 
336 360 julius
/*
337 44 julius
   initial
338
     begin
339 360 julius
`ifdef DATA_BUS_WIDTH_8
340 44 julius
        $display("(%m) UART INFO: Data bus width is 8. No Debug interface.\n");
341 360 julius
`else
342 44 julius
        $display("(%m) UART INFO: Data bus width is 32. Debug Interface present.\n");
343 360 julius
`endif
344
`ifdef UART_HAS_BAUDRATE_OUTPUT
345 44 julius
        $display("(%m) UART INFO: Has baudrate output\n");
346 360 julius
`else
347 44 julius
        $display("(%m) UART INFO: Doesn't have baudrate output\n");
348 6 julius
`endif
349 44 julius
     end
350 360 julius
*/
351
endmodule
352 6 julius
 
353
 

powered by: WebSVN 2.1.0

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