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

Subversion Repositories uart16550

[/] [uart16550/] [trunk/] [rtl/] [verilog/] [uart_wb.v] - Blame information for rev 79

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

Line No. Rev Author Line
1 27 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 33 gorban
////  uart_wb.v                                                   ////
4 27 mohor
////                                                              ////
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 WISHBONE interface.                               ////
19
////                                                              ////
20
////  Known problems (limits):                                    ////
21
////  Inserts one wait state on all transfers.                    ////
22
////  Note affected signals and the way they are affected.        ////
23
////                                                              ////
24
////  To Do:                                                      ////
25
////  Nothing.                                                    ////
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 73 gorban
// Revision 1.12  2001/12/19 08:03:34  mohor
68
// Warnings cleared.
69
//
70 64 mohor
// Revision 1.11  2001/12/06 14:51:04  gorban
71
// Bug in LSR[0] is fixed.
72
// All WISHBONE signals are now sampled, so another wait-state is introduced on all transfers.
73
//
74 50 gorban
// Revision 1.10  2001/12/03 21:44:29  gorban
75
// Updated specification documentation.
76
// Added full 32-bit data bus interface, now as default.
77
// Address is 5-bit wide in 32-bit data bus mode.
78
// Added wb_sel_i input to the core. It's used in the 32-bit mode.
79
// Added debug interface with two 32-bit read-only registers in 32-bit mode.
80
// Bits 5 and 6 of LSR are now only cleared on TX FIFO write.
81
// My small test bench is modified to work with 32-bit mode.
82
//
83 48 gorban
// Revision 1.9  2001/10/20 09:58:40  gorban
84
// Small synopsis fixes
85
//
86 33 gorban
// Revision 1.8  2001/08/24 21:01:12  mohor
87
// Things connected to parity changed.
88
// Clock devider changed.
89
//
90 29 mohor
// Revision 1.7  2001/08/23 16:05:05  mohor
91
// Stop bit bug fixed.
92
// Parity bug fixed.
93
// WISHBONE read cycle bug fixed,
94
// OE indicator (Overrun Error) bug fixed.
95
// PE indicator (Parity Error) bug fixed.
96
// Register read bug fixed.
97
//
98 27 mohor
// Revision 1.4  2001/05/31 20:08:01  gorban
99
// FIFO changes and other corrections.
100
//
101
// Revision 1.3  2001/05/21 19:12:01  gorban
102
// Corrected some Linter messages.
103
//
104
// Revision 1.2  2001/05/17 18:34:18  gorban
105
// First 'stable' release. Should be sythesizable now. Also added new header.
106
//
107
// Revision 1.0  2001-05-17 21:27:13+02  jacob
108
// Initial revision
109
//
110
//
111
 
112
// UART core WISHBONE interface 
113
//
114
// Author: Jacob Gorban   (jacob.gorban@flextronicssemi.com)
115
// Company: Flextronics Semiconductor
116
//
117
 
118 33 gorban
// synopsys translate_off
119 27 mohor
`include "timescale.v"
120 33 gorban
// synopsys translate_on
121 79 gorban
//`include "uart_defines.v"
122 50 gorban
 
123 48 gorban
module uart_wb (clk, wb_rst_i,
124 50 gorban
        wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_adr_i,
125
        wb_adr_int, wb_dat_i, wb_dat_o, wb_dat8_i, wb_dat8_o, wb_dat32_o, wb_sel_i,
126 27 mohor
        we_o, re_o // Write and read enable output for the core
127 48 gorban
);
128 27 mohor
 
129 48 gorban
input             clk;
130 27 mohor
 
131
// WISHBONE interface   
132 48 gorban
input             wb_rst_i;
133
input             wb_we_i;
134
input             wb_stb_i;
135
input             wb_cyc_i;
136
input [3:0]   wb_sel_i;
137 50 gorban
input [`UART_ADDR_WIDTH-1:0]     wb_adr_i; //WISHBONE address line
138
 
139 48 gorban
`ifdef DATA_BUS_WIDTH_8
140
input [7:0]  wb_dat_i; //input WISHBONE bus 
141
output [7:0] wb_dat_o;
142
reg [7:0]         wb_dat_o;
143
wire [7:0]        wb_dat_i;
144 50 gorban
reg [7:0]         wb_dat_is;
145 48 gorban
`else // for 32 data bus mode
146
input [31:0]  wb_dat_i; //input WISHBONE bus 
147
output [31:0] wb_dat_o;
148
reg [31:0]         wb_dat_o;
149
wire [31:0]   wb_dat_i;
150 50 gorban
reg [31:0]         wb_dat_is;
151
`endif // !`ifdef DATA_BUS_WIDTH_8
152
 
153
output [`UART_ADDR_WIDTH-1:0]    wb_adr_int; // internal signal for address bus
154 48 gorban
input [7:0]   wb_dat8_o; // internal 8 bit output to be put into wb_dat_o
155
output [7:0]  wb_dat8_i;
156
input [31:0]  wb_dat32_o; // 32 bit data output (for debug interface)
157
output            wb_ack_o;
158
output            we_o;
159
output            re_o;
160 27 mohor
 
161 48 gorban
wire                      we_o;
162
reg                       wb_ack_o;
163
reg [7:0]          wb_dat8_i;
164
wire [7:0]         wb_dat8_o;
165 50 gorban
wire [`UART_ADDR_WIDTH-1:0]      wb_adr_int; // internal signal for address bus
166
reg [`UART_ADDR_WIDTH-1:0]       wb_adr_is;
167
reg                                                             wb_we_is;
168
reg                                                             wb_cyc_is;
169
reg                                                             wb_stb_is;
170
reg [3:0]                                                wb_sel_is;
171
wire [3:0]   wb_sel_i;
172
reg                      wre ;// timing control signal for write or read enable
173 27 mohor
 
174 50 gorban
// wb_ack_o FSM
175
reg [1:0]         wbstate;
176
always  @(posedge clk or posedge wb_rst_i)
177
        if (wb_rst_i) begin
178 27 mohor
                wb_ack_o <= #1 1'b0;
179 50 gorban
                wbstate <= #1 0;
180 64 mohor
                wre <= #1 1'b1;
181 50 gorban
        end else
182
                case (wbstate)
183
                        0: begin
184
                                if (wb_stb_is & wb_cyc_is) begin
185
                                        wre <= #1 0;
186
                                        wbstate <= #1 1;
187
                                        wb_ack_o <= #1 1;
188
                                end else begin
189
                                        wre <= #1 1;
190
                                        wb_ack_o <= #1 0;
191
                                end
192
                        end
193
                        1: begin
194
                           wb_ack_o <= #1 0;
195
                                wbstate <= #1 2;
196
                                wre <= #1 0;
197
                        end
198
                        2,3: begin
199
                                wb_ack_o <= #1 0;
200
                                wbstate <= #1 0;
201
                                wre <= #1 0;
202
                        end
203
                endcase
204 27 mohor
 
205 50 gorban
assign we_o =  wb_we_is & wb_stb_is & wb_cyc_is & wre ; //WE for registers      
206
assign re_o = ~wb_we_is & wb_stb_is & wb_cyc_is & wre ; //RE for registers      
207 27 mohor
 
208 50 gorban
// Sample input signals
209
always  @(posedge clk or posedge wb_rst_i)
210
        if (wb_rst_i) begin
211
                wb_adr_is <= #1 0;
212
                wb_we_is <= #1 0;
213
                wb_cyc_is <= #1 0;
214
                wb_stb_is <= #1 0;
215
                wb_dat_is <= #1 0;
216
                wb_sel_is <= #1 0;
217
        end else begin
218
                wb_adr_is <= #1 wb_adr_i;
219
                wb_we_is <= #1 wb_we_i;
220
                wb_cyc_is <= #1 wb_cyc_i;
221
                wb_stb_is <= #1 wb_stb_i;
222
                wb_dat_is <= #1 wb_dat_i;
223
                wb_sel_is <= #1 wb_sel_i;
224
        end
225
 
226 79 gorban
assign wb_adr_int = wb_adr_is;
227
 
228 48 gorban
`ifdef DATA_BUS_WIDTH_8 // 8-bit data bus
229
always @(posedge clk or posedge wb_rst_i)
230
        if (wb_rst_i)
231
                wb_dat_o <= #1 0;
232
        else
233
                wb_dat_o <= #1 wb_dat8_o;
234
 
235 50 gorban
always @(wb_dat_is)
236
        wb_dat8_i = wb_dat_is;
237 48 gorban
 
238
`else // 32-bit bus
239
// put output to the correct byte in 32 bits using select line
240
always @(posedge clk or posedge wb_rst_i)
241
        if (wb_rst_i)
242
                wb_dat_o <= #1 0;
243
        else if (re_o)
244 50 gorban
                case (wb_sel_is)
245 48 gorban
                        4'b0001: wb_dat_o <= #1 {24'b0, wb_dat8_o};
246
                        4'b0010: wb_dat_o <= #1 {16'b0, wb_dat8_o, 8'b0};
247
                        4'b0100: wb_dat_o <= #1 {8'b0, wb_dat8_o, 16'b0};
248
                        4'b1000: wb_dat_o <= #1 {wb_dat8_o, 24'b0};
249
                        4'b1111: wb_dat_o <= #1 wb_dat32_o; // debug interface output
250
                        default: wb_dat_o <= #1 0;
251
                endcase // case(wb_sel_i)
252
 
253 50 gorban
always @(wb_sel_is or wb_dat_is)
254
        case (wb_sel_is)
255
                4'b0001 : wb_dat8_i = wb_dat_is[7:0];
256
                4'b0010 : wb_dat8_i = wb_dat_is[15:8];
257
                4'b0100 : wb_dat8_i = wb_dat_is[23:16];
258
                4'b1000 : wb_dat8_i = wb_dat_is[31:24];
259
                default : wb_dat8_i = wb_dat_is[7:0];
260 48 gorban
        endcase // case(wb_sel_i)
261
 
262
`endif // !`ifdef DATA_BUS_WIDTH_8
263
 
264 27 mohor
endmodule
265 48 gorban
 
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
 

powered by: WebSVN 2.1.0

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