1 //////////////////////////////////////////////////////////////////////
6 //// This file is part of the "UART 16550 compatible" project ////
7 //// http://www.opencores.org/cores/uart16550/ ////
9 //// Documentation related to this project: ////
10 //// - http://www.opencores.org/cores/uart16550/ ////
12 //// Projects compatibility: ////
14 //// RS232 Protocol ////
15 //// 16550D uart (mostly supported) ////
17 //// Overview (main Features): ////
18 //// UART core WISHBONE interface. ////
20 //// Known problems (limits): ////
21 //// Inserts one wait state on all transfers. ////
22 //// Note affected signals and the way they are affected. ////
28 //// - gorban@opencores.org ////
29 //// - Jacob Gorban ////
30 //// - Igor Mohor (igorm@opencores.org) ////
32 //// Created: 2001/05/12 ////
33 //// Last Updated: 2001/05/17 ////
34 //// (See log for the revision history) ////
37 //////////////////////////////////////////////////////////////////////
39 //// Copyright (C) 2000, 2001 Authors ////
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. ////
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. ////
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 ////
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 ////
62 //////////////////////////////////////////////////////////////////////
64 // CVS Revision History
66 // $Log: not supported by cvs2svn $
67 // Revision 1.16 2002/07/29 21:16:18 gorban
68 // The uart_defines.v file is included again in sources.
70 // Revision 1.15 2002/07/22 23:02:23 gorban
72 // * Possible loss of sync and bad reception of stop bit on slow baud rates fixed.
73 // Problem reported by Kenny.Tung.
74 // * Bad (or lack of ) loopback handling fixed. Reported by Cherry Withers.
77 // * Made FIFO's as general inferrable memory where possible.
78 // So on FPGA they should be inferred as RAM (Distributed RAM on Xilinx).
79 // This saves about 1/3 of the Slice count and reduces P&R and synthesis times.
81 // * Added optional baudrate output (baud_o).
82 // This is identical to BAUDOUT* signal on 16550 chip.
83 // It outputs 16xbit_clock_rate - the divided clock.
84 // It's disabled by default. Define UART_HAS_BAUDRATE_OUTPUT to use.
86 // Revision 1.12 2001/12/19 08:03:34 mohor
89 // Revision 1.11 2001/12/06 14:51:04 gorban
90 // Bug in LSR[0] is fixed.
91 // All WISHBONE signals are now sampled, so another wait-state is introduced on all transfers.
93 // Revision 1.10 2001/12/03 21:44:29 gorban
94 // Updated specification documentation.
95 // Added full 32-bit data bus interface, now as default.
96 // Address is 5-bit wide in 32-bit data bus mode.
97 // Added wb_sel_i input to the core. It's used in the 32-bit mode.
98 // Added debug interface with two 32-bit read-only registers in 32-bit mode.
99 // Bits 5 and 6 of LSR are now only cleared on TX FIFO write.
100 // My small test bench is modified to work with 32-bit mode.
102 // Revision 1.9 2001/10/20 09:58:40 gorban
103 // Small synopsis fixes
105 // Revision 1.8 2001/08/24 21:01:12 mohor
106 // Things connected to parity changed.
107 // Clock devider changed.
109 // Revision 1.7 2001/08/23 16:05:05 mohor
110 // Stop bit bug fixed.
112 // WISHBONE read cycle bug fixed,
113 // OE indicator (Overrun Error) bug fixed.
114 // PE indicator (Parity Error) bug fixed.
115 // Register read bug fixed.
117 // Revision 1.4 2001/05/31 20:08:01 gorban
118 // FIFO changes and other corrections.
120 // Revision 1.3 2001/05/21 19:12:01 gorban
121 // Corrected some Linter messages.
123 // Revision 1.2 2001/05/17 18:34:18 gorban
124 // First 'stable' release. Should be sythesizable now. Also added new header.
126 // Revision 1.0 2001-05-17 21:27:13+02 jacob
131 // UART core WISHBONE interface
133 // Author: Jacob Gorban (jacob.gorban@flextronicssemi.com)
134 // Company: Flextronics Semiconductor
137 `include "uart_defines.v"
139 module uart_wb (clk, wb_rst_i,
140 wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_adr_i,
141 wb_adr_int, wb_dat_i, wb_dat_o, wb_dat8_i, wb_dat8_o, wb_dat32_o, wb_sel_i,
142 we_o, re_o // Write and read enable output for the core
147 // WISHBONE interface
152 input [3:0] wb_sel_i;
153 input [2:0] wb_adr_i; //WISHBONE address line
155 input [7:0] wb_dat_i; //input WISHBONE bus
156 output [7:0] wb_dat_o;
161 output [2:0] wb_adr_int; // internal signal for address bus
162 input [7:0] wb_dat8_o; // internal 8 bit output to be put into wb_dat_o
163 output [7:0] wb_dat8_i;
164 input [31:0] wb_dat32_o; // 32 bit data output (for debug interface)
172 wire [7:0] wb_dat8_o;
173 wire [2:0] wb_adr_int; // internal signal for address bus
179 reg wre ;// timing control signal for write or read enable
183 always @(posedge clk or posedge wb_rst_i)
191 if (wb_stb_is & wb_cyc_is) begin
217 assign we_o = wb_we_is & wb_stb_is & wb_cyc_is & wre ; //WE for registers
218 assign re_o = ~wb_we_is & wb_stb_is & wb_cyc_is & wre ; //RE for registers
220 // Sample input signals
221 always @(posedge clk or posedge wb_rst_i)
229 wb_adr_is <= wb_adr_i;
231 wb_cyc_is <= wb_cyc_i;
232 wb_stb_is <= wb_stb_i;
233 wb_dat_is <= wb_dat_i;
236 always @(posedge clk or posedge wb_rst_i)
240 wb_dat_o <= wb_dat8_o;
243 wb_dat8_i = wb_dat_is;
245 assign wb_adr_int = wb_adr_is;